Skip to content

Commit

Permalink
fix: update dockerfile to npm i instead of copy deps
Browse files Browse the repository at this point in the history
  • Loading branch information
temarusanov committed Oct 9, 2023
1 parent a53f602 commit 3b1d43d
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 14 deletions.
13 changes: 6 additions & 7 deletions apps/api/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,19 +1,18 @@
# Install dependencies only when needed
FROM docker.io/node:lts-alpine as deps
# Check https://github.com/nodejs/docker-node/tree/b4117f9333da4138b03a546ec926ef50a31506c3#nodealpine
# to understand why libc6-compat might be needed.
FROM docker.io/node:16-alpine as deps
RUN apk add --no-cache libc6-compat
WORKDIR /usr/src/app
COPY ./node_modules ./node_modules

# Production image, copy all the files and run nest
COPY package*.json ./
RUN npm install --only=production --ignore-scripts

FROM docker.io/node:lts-alpine as runner
RUN apk add --no-cache dumb-init
ENV NODE_ENV production
ENV PORT 3000
WORKDIR /usr/src/app
COPY --from=deps /usr/src/app/node_modules ./node_modules
COPY ./node_modules/@prisma ./node_modules/@prisma
COPY dist/apps/api .
RUN chown -R node:node .
EXPOSE 3000
CMD ["dumb-init", "node", "main.js"]
CMD ["dumb-init", "node", "main.js"]
14 changes: 7 additions & 7 deletions apps/gateway/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
# Install dependencies only when needed
FROM docker.io/node:lts-alpine as deps
# Check https://github.com/nodejs/docker-node/tree/b4117f9333da4138b03a546ec926ef50a31506c3#nodealpine
# to understand why libc6-compat might be needed.
FROM docker.io/node:16-alpine as deps
RUN apk add --no-cache libc6-compat
WORKDIR /usr/src/app
COPY ./node_modules ./node_modules

# Production image, copy all the files and run nest
COPY package*.json ./
RUN npm install --only=production --ignore-scripts

FROM docker.io/node:lts-alpine as runner
RUN apk add --no-cache dumb-init
ENV NODE_ENV production
ENV PORT 3000
WORKDIR /usr/src/app
COPY --from=deps /usr/src/app/node_modules ./node_modules
COPY ./node_modules/@prisma ./node_modules/@prisma
COPY dist/apps/gateway .
RUN chown -R node:node .
EXPOSE 3000
CMD ["dumb-init", "node", "main.js"]
CMD ["dumb-init", "node", "main.js"]

0 comments on commit 3b1d43d

Please sign in to comment.