Presupuestador_web/Dockerfile.server

67 lines
2.4 KiB
Docker
Raw Normal View History

2024-09-06 16:10:45 +00:00
# syntax=docker/dockerfile:1.4
2024-09-06 17:46:38 +00:00
# BUILD STAGE
2024-09-04 10:24:41 +00:00
FROM node:lts-iron AS builder
2024-08-01 14:55:30 +00:00
# Establecer el directorio de trabajo
2024-09-08 10:40:49 +00:00
WORKDIR /api
2024-08-01 14:55:30 +00:00
2024-09-08 11:01:29 +00:00
# Copiar los archivos de dependencias
COPY package.json .
COPY tsconfig*.json .
2024-09-08 18:03:32 +00:00
RUN yarn install
2024-09-08 09:56:46 +00:00
2024-09-08 11:07:05 +00:00
RUN mkdir -p ./shared
RUN mkdir -p ./server
COPY shared ./shared
COPY server ./server
2024-09-04 10:24:41 +00:00
2024-09-08 11:08:16 +00:00
#CMD pwd && ls -la
2024-09-08 18:03:32 +00:00
RUN cd ./shared && yarn install
RUN cd ./server && yarn install
2024-09-07 12:16:37 +00:00
2024-09-06 17:46:38 +00:00
# Ejecutar el build
# Si hay un error, mostrarlo en detalle.
2024-09-08 11:09:57 +00:00
RUN cd ./server && yarn run build || { echo 'Error during build'; exit 1; }
2024-09-04 10:24:41 +00:00
2024-09-13 10:58:51 +00:00
# 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
2024-09-08 18:03:32 +00:00
# FINAL STAGE (Producción)
FROM node:lts-iron AS prod
2024-09-13 14:29:07 +00:00
# Configure default locale (important for chrome-headless-shell).
ENV LANG es_ES.UTF-8
2024-09-13 14:43:46 +00:00
# Descargar chromium
2024-09-13 14:52:36 +00:00
#ENV PUPPETEER_SKIP_CHROMIUM_DOWNLOAD false
2024-09-13 14:29:07 +00:00
# Install Google Chrome Stable and fonts
# Note: this installs the necessary libs to make the browser work with Puppeteer.
2024-09-13 14:35:56 +00:00
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/*
2024-09-13 14:29:07 +00:00
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
2024-09-13 14:55:07 +00:00
# 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
RUN groupadd -r pptruser && useradd -r -g pptruser -G audio,video pptruser \
2024-09-13 14:52:36 +00:00
&& 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
2024-09-08 18:49:54 +00:00
2024-09-13 14:52:36 +00:00
# Run everything after as non-privileged user.
USER pptruser
2024-09-08 18:03:32 +00:00
2024-09-13 14:52:36 +00:00
CMD ["google-chrome-stable"]
2024-09-08 18:13:22 +00:00