69 lines
2.5 KiB
Docker
69 lines
2.5 KiB
Docker
# syntax=docker/dockerfile:1.4
|
|
|
|
# BUILD STAGE
|
|
FROM node:lts-iron AS builder
|
|
|
|
# Establecer el directorio de trabajo
|
|
WORKDIR /api
|
|
|
|
# Copiar los archivos de dependencias
|
|
COPY package.json .
|
|
COPY tsconfig*.json .
|
|
RUN yarn install
|
|
|
|
RUN mkdir -p ./shared
|
|
RUN mkdir -p ./server
|
|
|
|
COPY shared ./shared
|
|
COPY server ./server
|
|
|
|
#CMD pwd && ls -la
|
|
|
|
RUN cd ./shared && yarn install
|
|
RUN cd ./server && yarn install
|
|
|
|
# Ejecutar el build
|
|
# Si hay un error, mostrarlo en detalle.
|
|
RUN cd ./server && yarn run build || { echo 'Error during build'; exit 1; }
|
|
|
|
# Copiar plantillas
|
|
RUN mkdir -p /api/dist/server/src/contexts/sales/infrastructure/express/controllers/quotes/reportQuote/reporter/templates/quote/
|
|
COPY server/src/contexts/sales/infrastructure/express/controllers/quotes/reportQuote/reporter/templates/quote/* /api/dist/server/src/contexts/sales/infrastructure/express/controllers/quotes/reportQuote/reporter/templates/quote
|
|
|
|
# FINAL STAGE (Producción)
|
|
FROM node:lts-iron AS prod
|
|
|
|
# Configure default locale (important for chrome-headless-shell).
|
|
ENV LANG es_ES.UTF-8
|
|
|
|
# Descargar chromium
|
|
#ENV PUPPETEER_SKIP_CHROMIUM_DOWNLOAD false
|
|
|
|
# Install Google Chrome Stable and fonts
|
|
# Note: this installs the necessary libs to make the browser work with Puppeteer.
|
|
RUN apt-get update && apt-get install gnupg wget -y && \
|
|
wget --quiet --output-document=- https://dl-ssl.google.com/linux/linux_signing_key.pub | gpg --dearmor > /etc/apt/trusted.gpg.d/google-archive.gpg && \
|
|
sh -c 'echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google.list' && \
|
|
apt-get update && \
|
|
apt-get install google-chrome-stable -y --no-install-recommends && \
|
|
rm -rf /var/lib/apt/lists/*
|
|
|
|
RUN apt-get update && apt-get install -y libnss3 libnspr4 libatk1.0-0 libatk-bridge2.0-0 libcups2 libdrm2 libxkbcommon0 libxcomposite1 libxdamage1 libxfixes3 libxrandr2 libgbm1 libasound2 libcairo2 libpango-1.0-0
|
|
|
|
# Install puppeteer so it's available in the container.
|
|
RUN yarn add puppeteer \
|
|
# Add user so we don't need --no-sandbox.
|
|
# same layer as npm install to keep re-chowned files from using up several hundred MBs more space
|
|
&& groupadd -r pptruser && useradd -r -g pptruser -G audio,video pptruser \
|
|
&& mkdir -p /home/pptruser/Downloads \
|
|
&& chown -R pptruser:pptruser /home/pptruser \
|
|
&& chown -R pptruser:pptruser /node_modules \
|
|
&& chown -R pptruser:pptruser /package.json \
|
|
&& chown -R pptruser:pptruser /package-lock.json
|
|
|
|
# Run everything after as non-privileged user.
|
|
USER pptruser
|
|
|
|
CMD ["google-chrome-stable"]
|
|
|