-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
98 lines (69 loc) · 3.1 KB
/
Copy pathDockerfile
File metadata and controls
98 lines (69 loc) · 3.1 KB
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
# syntax=docker/dockerfile:1.7
ARG NODE_VERSION=22-alpine
ARG PNPM_VERSION=10.31.0
ARG TURBO_VERSION=2.9.14
# ---- base ------------------------------------------------------------------
FROM node:${NODE_VERSION} AS base
RUN corepack enable && \
corepack prepare pnpm@${PNPM_VERSION} --activate && \
npm install -g turbo@${TURBO_VERSION}
ENV CI=true
ENV NEXT_TELEMETRY_DISABLED=1
# ---- pruner ----------------------------------------------------------------
FROM base AS pruner
WORKDIR /app
COPY . .
RUN turbo prune @ever-works/web --docker
# ---- installer / builder ---------------------------------------------------
FROM base AS installer
WORKDIR /app
ENV NODE_ENV=build
ENV STANDALONE_BUILD=true
ENV NODE_OPTIONS="--max-old-space-size=4096"
RUN apk add --no-cache git libc6-compat python3 make g++ pkgconfig
COPY --from=pruner /app/out/json/ .
COPY --from=pruner /app/out/pnpm-lock.yaml ./pnpm-lock.yaml
# Configure the npm registry: prefer the internal Verdaccio cache (VERDACCIO_REGISTRY
# build-arg, anonymous) so CI installs pull through our in-cluster mirror instead of
# public npm. Empty (e.g. a fork, or any build that doesn't set it) → public npm,
# leaving existing behavior unchanged. The pnpm-lock.yaml rewrite is best-effort
# (non-fatal): a path mismatch degrades to public downloads rather than breaking the
# build, and pnpm still verifies integrity hashes, so Verdaccio (a transparent proxy)
# resolves to byte-identical tarballs.
ARG VERDACCIO_REGISTRY=""
RUN if [ -n "$VERDACCIO_REGISTRY" ]; then \
echo "registry=${VERDACCIO_REGISTRY}" >> /app/.npmrc && \
{ sed -i "s|https://registry.npmjs.org|${VERDACCIO_REGISTRY%/}|g" /app/pnpm-lock.yaml 2>/dev/null || true; }; \
fi
RUN --mount=type=cache,id=pnpm-store,target=/root/.local/share/pnpm/store \
pnpm install --frozen-lockfile
COPY --from=pruner /app/out/full/ .
ARG DATA_REPOSITORY=""
ENV DATA_REPOSITORY=${DATA_REPOSITORY}
RUN --mount=type=secret,id=gh_token \
sh -c 'if [ -s /run/secrets/gh_token ]; then export GH_TOKEN=$(cat /run/secrets/gh_token); fi; \
pnpm exec turbo build --filter=@ever-works/web...'
# ---- runner ----------------------------------------------------------------
FROM node:${NODE_VERSION} AS runner
WORKDIR /app
ARG GITHUB_REPOSITORY=""
ARG GITHUB_SHA=""
LABEL org.opencontainers.image.source="https://github.com/${GITHUB_REPOSITORY}"
LABEL org.opencontainers.image.revision="${GITHUB_SHA}"
LABEL org.opencontainers.image.title="${GITHUB_REPOSITORY}"
ENV NODE_ENV=production
ENV NEXT_TELEMETRY_DISABLED=1
ENV PORT=3000
ENV HOSTNAME=0.0.0.0
RUN apk add --no-cache libc6-compat && \
mkdir -p /app/apps/web/.next/cache/images && \
chown -R node:node /app
COPY --from=installer --chown=node:node /app/apps/web/.next/standalone ./
COPY --from=installer --chown=node:node /app/apps/web/.next/static ./apps/web/.next/static
COPY --from=installer --chown=node:node /app/apps/web/public ./apps/web/public
COPY --from=installer --chown=node:node /app/apps/web/messages ./apps/web/messages
VOLUME /app/apps/web/.next/cache
USER node
WORKDIR /app/apps/web
EXPOSE 3000
CMD ["node", "server.js"]