-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
dd5d6a3
commit 04e275f
Showing
2 changed files
with
18 additions
and
24 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,6 @@ | ||
node_modules | ||
Dockerfile | ||
.git | ||
.gitignore | ||
dist/** | ||
README.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 |
---|---|---|
@@ -1,39 +1,27 @@ | ||
FROM node:20-slim as base | ||
FROM node:20 AS base | ||
|
||
ENV PNPM_HOME="/root/.local/share/pnpm" | ||
ENV PATH="${PATH}:${PNPM_HOME}" | ||
FROM base AS deps | ||
|
||
RUN corepack enable | ||
RUN pnpm add -g fastify-cli | ||
|
||
FROM base as dependencies | ||
|
||
WORKDIR /app | ||
COPY package.json pnpm-lock.yaml tsconfig.json ./ | ||
RUN --mount=type=cache,id=pnpm,target=/root/.local/share/pnpm/store pnpm fetch --frozen-lockfile --prod | ||
COPY package.json pnpm-lock.yaml ./ | ||
RUN --mount=type=cache,id=pnpm,target=/root/.local/share/pnpm/store pnpm fetch --frozen-lockfile | ||
RUN --mount=type=cache,id=pnpm,target=/root/.local/share/pnpm/store pnpm install --frozen-lockfile --prod | ||
|
||
FROM base as build | ||
FROM base AS build | ||
|
||
RUN corepack enable | ||
WORKDIR /app | ||
COPY package.json pnpm-lock.yaml tsconfig.json ./ | ||
COPY package.json pnpm-lock.yaml ./ | ||
RUN --mount=type=cache,id=pnpm,target=/root/.local/share/pnpm/store pnpm fetch --frozen-lockfile | ||
RUN --mount=type=cache,id=pnpm,target=/root/.local/share/pnpm/store pnpm install --frozen-lockfile | ||
COPY src/ ./src | ||
RUN pnpm build:ts | ||
COPY . . | ||
RUN pnpm build | ||
|
||
FROM base | ||
|
||
WORKDIR /app | ||
COPY --from=dependencies /app/node_modules /app/node_modules | ||
COPY --from=deps /app/node_modules /app/node_modules | ||
COPY --from=build /app/dist /app/dist | ||
EXPOSE 3000 | ||
CMD ["fastify", "start", "-l", "info", "dist/app.js"] | ||
|
||
#FROM node:20-slim as build | ||
# | ||
#RUN corepack enable | ||
#WORKDIR /app | ||
#COPY package.json pnpm-lock.yaml ./ | ||
#RUN --mount=type=cache,id=pnpm,target=/root/.local/share/pnpm/store pnpm fetch --frozen-lockfile | ||
#RUN --mount=type=cache,id=pnpm,target=/root/.local/share/pnpm/store pnpm install --frozen-lockfile --prod | ||
ENV NODE_ENV production | ||
CMD ["node", "./dist/index.js"] |