fix: add production target to api

This commit is contained in:
Emnaghz 2024-09-27 11:22:18 +01:00 committed by Mohamed Marrouchi
parent 604dd5aa0c
commit 99c5765e6f
3 changed files with 32 additions and 16 deletions

View File

@ -66,6 +66,7 @@ jobs:
uses: docker/build-push-action@v6
with:
context: ./api/
target: production
file: ./api/Dockerfile
platforms: linux/amd64,linux/arm64
push: true

View File

@ -4,32 +4,46 @@ WORKDIR /app
COPY . .
FROM node:18-alpine AS installer
WORKDIR /app
COPY --from=builder /app/package*.json ./
COPY --from=builder /app/merge-extensions-deps.js ./
COPY --from=builder /app/src/extensions ./src/extensions
COPY --from=builder /app/patches ./patches
RUN npm update -g npm
RUN npm config set registry https://registry.npmjs.com/
RUN npm run preinstall
RUN npm i --verbose --maxsockets 6
FROM node:18-alpine AS runner
RUN npm run build
FROM node:18-alpine AS production
WORKDIR /app
COPY --from=installer /app/ .
COPY --from=builder /app/package*.json ./
COPY --from=builder /app/ .
COPY --from=builder /app/node_modules ./node_modules
COPY . .
ENV NODE_ENV=production
# Run npm prune to remove dev dependencies
RUN npm prune --production
EXPOSE 3000
CMD [ "npm", "run" , "start:dev" ]
CMD ["npm", "run", "start:prod"]
FROM node:18-alpine AS development
WORKDIR /app
COPY --from=builder /app/package*.json ./
COPY --from=builder /app/ .
ENV NODE_ENV=development
RUN npm install
EXPOSE 3000
CMD ["npm", "run", "start:dev"]

View File

@ -13,6 +13,7 @@ services:
api:
build:
context: ../api
target: development
pull_policy: build
ports:
- ${API_PORT}:3000