forked from hunvreus/pagescms
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
46 lines (27 loc) · 922 Bytes
/
Copy pathDockerfile
File metadata and controls
46 lines (27 loc) · 922 Bytes
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
FROM node:22-bookworm-slim AS dependencies
WORKDIR /app
COPY package.json package-lock.json ./
RUN npm ci
FROM node:22-bookworm-slim AS builder
WORKDIR /app
ENV NEXT_TELEMETRY_DISABLED=1
COPY --from=dependencies /app/node_modules ./node_modules
COPY . .
# Pages CMS validates BASE_URL while Next.js collects page data.
ARG BASE_URL
ENV BASE_URL=${BASE_URL}
# Run Next directly so package.json's postbuild migration
# does not try to connect to PostgreSQL during image creation.
RUN npx next build
FROM node:22-bookworm-slim AS runner
WORKDIR /app
ENV NODE_ENV=production
ENV NEXT_TELEMETRY_DISABLED=1
ENV HOSTNAME=0.0.0.0
ENV PORT=3000
RUN groupadd --system --gid 1001 nodejs \
&& useradd --system --uid 1001 --gid nodejs pagescms
COPY --from=builder --chown=pagescms:nodejs /app ./
USER pagescms
EXPOSE 3000
CMD ["sh", "-c", "npm run db:migrate && npm run start -- --hostname 0.0.0.0 --port 3000"]