Presupuestador_web/Dockerfile.server

79 lines
2.6 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 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-24 11:41:25 +00:00
# Copiar logo por defecto
2024-09-24 12:20:47 +00:00
RUN mkdir -p /api/dist/uploads/images/
2024-09-24 11:41:25 +00:00
COPY server/uploads/images/* /api/dist/uploads/images
2024-09-24 15:36:45 +00:00
#CMD ls -la /api/dist/uploads/images
# 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.
# Install latest chrome dev package and fonts to support major charsets (Chinese, Japanese, Arabic, Hebrew, Thai and a few others)
# Note: this installs the necessary libs to make the bundled version of Chromium that Puppeteer
# installs, work.
RUN apt-get update \
&& apt-get install -y wget gnupg \
&& wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add - \
&& 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 -y google-chrome-stable fonts-ipafont-gothic fonts-wqy-zenhei fonts-thai-tlwg fonts-kacst fonts-freefont-ttf libxss1 \
--no-install-recommends \
&& rm -rf /var/lib/apt/lists/*
WORKDIR /api
# Copiar los archivos del build desde la fase anterior
COPY --from=builder /api/dist .
COPY --from=builder /api/server/package.json .
COPY --from=builder /api/server/tsconfig.production.json ./tsconfig.json
2024-09-24 15:46:59 +00:00
RUN ls -la /api/uploads/images
2024-09-24 15:36:45 +00:00
# Instalar sólo las dependencias de producción en el servidor
2024-09-24 15:46:59 +00:00
RUN yarn install --production
2024-09-24 15:36:45 +00:00
# Exponer el puerto que la API usa
2024-09-24 15:46:59 +00:00
EXPOSE 3001
2024-09-24 15:36:45 +00:00
# Comando para correr la aplicación
2024-09-24 15:46:59 +00:00
CMD node -r ts-node/register/transpile-only -r tsconfig-paths/register ./server/src/index.js
2024-09-24 15:36:45 +00:00