feat: logger and dockerfile

This commit is contained in:
Hasta Ragil Saputra
2021-11-26 18:42:12 +07:00
parent 1b645380e8
commit 7fdd03c093
12 changed files with 1395 additions and 1148 deletions

45
Dockerfile Normal file
View File

@@ -0,0 +1,45 @@
# PRODUCTION DOCKERFILE
# ---------------------
# This Dockerfile allows to build a Docker image of the NestJS application
# and based on a NodeJS 16 image. The multi-stage mechanism allows to build
# the application in a "builder" stage and then create a lightweight production
# image containing the required dependencies and the JS build files.
#
# Dockerfile best practices
# https://docs.docker.com/develop/develop-images/dockerfile_best-practices/
# Dockerized NodeJS best practices
# https://github.com/nodejs/docker-node/blob/master/docs/BestPractices.md
# https://www.bretfisher.com/node-docker-good-defaults/
# http://goldbergyoni.com/checklist-best-practice-of-node-js-in-production/
FROM node:16-alpine as builder
ENV NODE_ENV build
USER node
WORKDIR /home/node
COPY package.json .
COPY yarn.lock .
RUN yarn install --frozen-lockfile
COPY . /home/node
RUN yarn run build \
&& yarn install --production --ignore-scripts --prefer-offline
# ---
FROM node:16-alpine
ENV NODE_ENV production
USER node
WORKDIR /home/node
COPY --from=builder /home/node/package*.json /home/node/
COPY --from=builder /home/node/node_modules/ /home/node/node_modules/
COPY --from=builder /home/node/dist/ /home/node/dist/
CMD ["node", "dist/main.js"]