-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
52 lines (38 loc) · 1.4 KB
/
Dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
ARG NODE_IMAGE=docker.io/node:22.12.0-slim
# Base stage
FROM ${NODE_IMAGE} AS base
ARG PNPM_VERSION=9.15.0
ENV PNPM_HOME="/pnpm"
ENV PATH="$PNPM_HOME:$PATH"
WORKDIR /app
RUN corepack enable pnpm && corepack install -g pnpm@${PNPM_VERSION}
COPY --chown=node:root . ./
# Dev stage
FROM base AS dev
RUN --mount=type=cache,id=pnpm,target=/pnpm/store pnpm install --frozen-lockfile
ENTRYPOINT [ "pnpm", "run" ]
CMD [ "dev" ]
# Prod dependencies stage
FROM base AS prod-deps
RUN --mount=type=cache,id=pnpm,target=/pnpm/store pnpm install --prod --frozen-lockfile --ignore-scripts
# Build stage
FROM base AS build
RUN --mount=type=cache,id=pnpm,target=/pnpm/store pnpm install --frozen-lockfile
RUN pnpm run build
# Prod stage
FROM ${NODE_IMAGE} AS prod
ARG APP_VERSION
ENV APP_VERSION=$APP_VERSION
WORKDIR /app
RUN apt update && apt install -y git && rm -rf /var/lib/apt/lists/* \
&& mkdir -p /home/node/logs && chmod 660 -R /home/node/logs \
&& mkdir -p /home/node/.npm && chmod 660 -R /home/node/.npm \
&& chown -R node:root /app \
&& git config --system --add safe.directory '*'
COPY --chown=node:root --from=prod-deps /app/node_modules ./node_modules
COPY --chown=node:root --from=build /app/dist ./dist
COPY --chown=node:root --from=build /app/types ./types
COPY --chown=node:root --from=build /app/bin ./bin
COPY --chown=node:root --from=build /app/package.json ./
USER node
ENTRYPOINT ["/app/bin/docpress.js"]