diff --git a/backend/Dockerfile b/backend/Dockerfile index 0bb5e2d..986a35a 100644 --- a/backend/Dockerfile +++ b/backend/Dockerfile @@ -1,17 +1,29 @@ -FROM node:20 +# Stage 1: Build the application +FROM node:20 AS build WORKDIR /usr/src/app COPY . . +RUN npm install \ + && npm run build + +# Stage 2: Create the final image without source files +FROM node:20 + +WORKDIR /usr/src/app + +# Install dumb-init and dockerize ENV DOCKERIZE_VERSION v0.7.0 -RUN wget -O /usr/local/bin/dumb-init https://github.com/Yelp/dumb-init/releases/download/v1.2.5/dumb-init_1.2.5_$(uname -m) \ +RUN wget -O /usr/local/bin/dumb-init https://github.com/Yelp/dumb-init/releases/download/v1.2.5/dumb-init_1.2.5_$(uname -m) \ && chmod +x /usr/local/bin/dumb-init \ && wget -O /usr/local/bin/dockerize.tar.gz https://github.com/jwilder/dockerize/releases/download/$DOCKERIZE_VERSION/dockerize-linux-$(dpkg --print-architecture)-${DOCKERIZE_VERSION}.tar.gz \ && tar -C /usr/local/bin -xzvf /usr/local/bin/dockerize.tar.gz \ - && rm /usr/local/bin/dockerize.tar.gz \ - && npm install \ - && echo -e "\n\nBulding...\n" \ - && npm run build + && rm /usr/local/bin/dockerize.tar.gz + +# Copy only the necessary build artifacts from the build stage +COPY --from=build /usr/src/app/dist ./dist +COPY --from=build /usr/src/app/node_modules ./node_modules +COPY --from=build /usr/src/app/package.json ./package.json ENV NODE_ENV=production ENV PORT=3000 diff --git a/backend/tsconfig.json b/backend/tsconfig.json index 170c22f..5109439 100644 --- a/backend/tsconfig.json +++ b/backend/tsconfig.json @@ -10,6 +10,5 @@ "emitDecoratorMetadata": true, "skipLibCheck": true, "forceConsistentCasingInFileNames": true, - "sourceMap": true, } }