Skip to content

Commit

Permalink
fix: add production target to api
Browse files Browse the repository at this point in the history
  • Loading branch information
Emnaghz committed Sep 27, 2024
1 parent d47deeb commit d0da7ce
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 12 deletions.
1 change: 1 addition & 0 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ jobs:
uses: docker/build-push-action@v6
with:
context: ./api/
target: production
file: ./api/Dockerfile
platforms: linux/amd64,linux/arm64
push: true
Expand Down
38 changes: 26 additions & 12 deletions api/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,32 +4,46 @@ WORKDIR /app

COPY . .

FROM node:18-alpine AS installer
RUN npm update -g npm

RUN npm config set registry https://registry.npmjs.com/

RUN npm run preinstall

RUN npm i --verbose --maxsockets 6

RUN npm run build


FROM node:18-alpine AS production

WORKDIR /app

COPY --from=builder /app/package*.json ./
COPY --from=builder /app/ .
COPY --from=builder /app/node_modules ./node_modules

COPY --from=builder /app/merge-extensions-deps.js ./

COPY --from=builder /app/src/extensions ./src/extensions
ENV NODE_ENV=production

COPY --from=builder /app/patches ./patches
# Run npm prune to remove dev dependencies
RUN npm prune --production

RUN npm update -g npm
EXPOSE 3000

RUN npm config set registry https://registry.npmjs.com/
CMD ["npm", "run", "start:prod"]

RUN npm i --verbose --maxsockets 6

FROM node:18-alpine AS runner
FROM node:18-alpine AS development

WORKDIR /app

COPY --from=installer /app/ .
COPY --from=builder /app/package*.json ./
COPY --from=builder /app/ .

ENV NODE_ENV=development

COPY . .
RUN npm install

EXPOSE 3000

CMD [ "npm", "run" , "start:dev" ]
CMD ["npm", "run", "start:dev"]
1 change: 1 addition & 0 deletions docker/docker-compose.dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ services:
api:
build:
context: ../api
target: development
pull_policy: build
ports:
- ${API_PORT}:3000
Expand Down

0 comments on commit d0da7ce

Please sign in to comment.