From 1e57a63c5576dfc18a67597f59cd9922e5646340 Mon Sep 17 00:00:00 2001 From: David Arranz Date: Fri, 6 Sep 2024 19:46:38 +0200 Subject: [PATCH] . --- server/Dockerfile | 33 +++++++++++++-------------------- 1 file changed, 13 insertions(+), 20 deletions(-) diff --git a/server/Dockerfile b/server/Dockerfile index 4aab07a..2d25e94 100644 --- a/server/Dockerfile +++ b/server/Dockerfile @@ -1,41 +1,34 @@ # syntax=docker/dockerfile:1.4 -# BUILD +# BUILD STAGE FROM node:lts-iron AS builder -# set our node environment, either development or production -# defaults to production, compose overrides this to development on build and run -ARG NODE_ENV=production -ENV NODE_ENV $NODE_ENV - # Establecer el directorio de trabajo WORKDIR /api -COPY package.json ./ -COPY yarn.lock ./ +# Copiar los archivos de dependencias +COPY package.json yarn.lock ./ +# Instalar dependencias RUN yarn install -# Copiar el código de la aplicación +# Copiar el resto del código de la aplicación COPY . . -RUN yarn -RUN yarn run build +# Ejecutar el build +# Si hay un error, mostrarlo en detalle. +RUN yarn run build || { echo 'Error during build'; exit 1; } -# RUN - -FROM builder AS prod +# FINAL STAGE +FROM node:lts-iron AS prod WORKDIR /api -#COPY package.json yarn.lock ./ -#RUN yarn install --production - -COPY --from=builder /dist ./dist +# Copiar el código compilado de la fase anterior +COPY --from=builder /api/dist ./dist # Exponer el puerto que la API usa EXPOSE 3000 # Comando para correr la aplicación -#CMD ["node", "dist/server/index.js"] -RUN yarn run start \ No newline at end of file +CMD ["yarn", "run", "start"]