-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add: create Dockerfile and .dockerignore for containerization
- Loading branch information
1 parent
a81ad48
commit cdc95dc
Showing
2 changed files
with
59 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# Folders | ||
|
||
coverage/ | ||
dist/ | ||
node_modules/ | ||
out/ | ||
test/ | ||
|
||
# Files | ||
|
||
.dockerignore | ||
.editorconfig | ||
.env | ||
.gitignore | ||
.lintstagedrc | ||
.prettierrc | ||
commitlint.config.js | ||
Dockerfile | ||
eslint.config.mjs | ||
nest-cli.json | ||
\*.md |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
FROM node:20.17.0-alpine AS base | ||
RUN addgroup -S backend && \ | ||
adduser -S backend -G backend | ||
|
||
#-------------------------------------------------- | ||
|
||
FROM base AS base-dev | ||
RUN npm install -g --ignore-scripts pnpm | ||
|
||
#-------------------------------------------------- | ||
|
||
FROM base-dev AS build | ||
WORKDIR /app | ||
COPY package.json pnpm-lock.yaml tsconfig.json tsconfig.build.json ./ | ||
RUN pnpm install --frozen-lockfile --ignore-scripts | ||
COPY ./src ./src | ||
RUN pnpm run build --webpack | ||
|
||
#-------------------------------------------------- | ||
|
||
FROM base-dev AS production-dev | ||
ARG NODE_ENV=production | ||
WORKDIR /app | ||
COPY package.json pnpm-lock.yaml ./ | ||
RUN pnpm install --frozen-lockfile --prod --ignore-scripts && \ | ||
pnpm cache delete | ||
|
||
#-------------------------------------------------- | ||
|
||
FROM base AS production | ||
ARG NODE_ENV=production | ||
WORKDIR /app | ||
COPY --from=production-dev /app/node_modules ./node_modules | ||
COPY --from=build /app/dist ./ | ||
COPY package.json ./ | ||
USER backend | ||
ENTRYPOINT ["node", "main.js"] | ||
EXPOSE 3000 |