Skip to content

Commit

Permalink
[revise]: revise dockerfile
Browse files Browse the repository at this point in the history
  • Loading branch information
IMHOJEONG committed Dec 31, 2023
1 parent 8ff0470 commit d4c462b
Showing 1 changed file with 18 additions and 12 deletions.
30 changes: 18 additions & 12 deletions apps/pwrcode-backend/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -33,17 +33,6 @@ WORKDIR /usr/src/app
# Set NODE_ENV environment variable
ENV NODE_ENV production


ARG DATABASE_HOST
ENV DATABASE_HOST ${DATABASE_HOST}
ARG DATABASE_USER
ENV DATABASE_USER ${DATABASE_USER}
ARG DATABASE_PASS
ENV DATABASE_PASS ${DATABASE_PASS}
ARG MEILISEARCH_HOST
ENV MEILISEARCH_HOST ${MEILISEARCH_HOST}


COPY --chown=node:node package*.json ./

# In order to run `npm run build` we need access to the Nest CLI which is a dev dependency. In the previous development stage we ran `npm ci` which installed all dependencies, so we can copy over the node_modules directory from the development image
Expand All @@ -58,7 +47,7 @@ RUN yarn build
# Running `npm ci` removes the existing node_modules directory and passing in --only=production ensures that only the production dependencies are installed. This ensures that the node_modules directory is as optimized as possible
# RUN npm ci --only=production && npm cache clean --force
# RUN npm ci
RUN yarn install
# RUN yarn install

USER node

Expand All @@ -72,5 +61,22 @@ FROM node:18-alpine As production
COPY --chown=node:node --from=build /usr/src/app/node_modules ./node_modules
COPY --chown=node:node --from=build /usr/src/app/dist ./dist

# ENV DATABASE_HOST ${DATABASE_HOST}
ARG DATABASE_HOST
ENV DATABASE_HOST ${DATABASE_HOST}
CMD echo $DATABASE_HOST >> .env.production

ARG DATABASE_USER
ENV DATABASE_USER ${DATABASE_USER}
CMD echo $DATABASE_USER >> .env.production

ARG DATABASE_PASS
ENV DATABASE_PASS ${DATABASE_PASS}
CMD echo $DATABASE_PASS >> .env.production

ARG MEILISEARCH_HOST
ENV MEILISEARCH_HOST ${MEILISEARCH_HOST}
CMD echo $MEILISEARCH_HOST >> .env.production

# Start the server using the production build
CMD [ "node", "dist/main.js" ]

0 comments on commit d4c462b

Please sign in to comment.