generated from mezotv/Discord-Bot-Template
-
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Made the Dockerfile production ready. Multiple build steps. Saved 126.1MB.
- Loading branch information
Showing
5 changed files
with
28 additions
and
20 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 |
---|---|---|
|
@@ -4,4 +4,6 @@ node_modules | |
npm-debug.log | ||
README.md | ||
.git | ||
.env | ||
.env | ||
docker-compose.yaml | ||
dist |
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 |
---|---|---|
@@ -1,13 +1,24 @@ | ||
FROM node:18-alpine | ||
WORKDIR / | ||
|
||
FROM node:18-slim AS base | ||
ENV PNPM_HOME="/pnpm" | ||
ENV PATH="$PNPM_HOME:$PATH" | ||
#Hook into pnpm without installing pnpm. (magic) (https://nodejs.org/docs/latest-v18.x/api/corepack.html) | ||
RUN corepack enable | ||
WORKDIR /usr/src/app | ||
COPY package*.json pnpm-lock.yaml* ./ | ||
RUN npm i -g pnpm | ||
|
||
RUN pnpm install | ||
#Create node_modules files without dev dependencies. | ||
FROM base AS prod_dependencies | ||
RUN --mount=type=cache,id=pnpm,target=/pnpm/store pnpm install --prod --frozen-lockfile | ||
|
||
#Generate the dist directory. | ||
FROM base AS builder | ||
COPY . . | ||
|
||
RUN --mount=type=cache,id=pnpm,target=/pnpm/store pnpm install --frozen-lockfile | ||
RUN pnpm run build | ||
|
||
CMD pnpm run start | ||
#Final image | ||
FROM base | ||
WORKDIR /usr/src/app | ||
COPY --from=prod_dependencies /usr/src/app/node_modules ./node_modules | ||
COPY --from=builder /usr/src/app/dist ./dist | ||
CMD [ "pnpm", "run", "start" ] |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.