Repository navigation
Expand file tree
/
Copy pathDockerfile
More file actions
64 lines (59 loc) · 2.81 KB
/
Copy pathDockerfile
File metadata and controls
64 lines (59 loc) · 2.81 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
# syntax=docker/dockerfile:1
# Nothing is built or installed in here. CI produces the exact contents of each
# image with `node scripts/assemble-images.mjs <web|worker|storybook>` (into
# `out/<target>`, dependencies already installed there) and every stage below
# only COPYs that directory onto a base image. Targets:
# - `app` the Next.js server (plain `next start`, not `output: 'standalone'`
# — standalone's dependency trace repeatedly conflicted with
# Turbopack's content-hashed module ids under Sentry's
# require-patching integrations, crashing the server on boot)
# - `worker` the Payload job runner
# - `storybook` the built Storybook, served statically
ARG NODE_VERSION=26
# ---- app ---------------------------------------------------------------------
FROM node:${NODE_VERSION}-slim AS app
ARG VERSION=""
ARG REVISION=""
ENV NODE_ENV=production \
PORT=3000 \
HOSTNAME=0.0.0.0
LABEL org.opencontainers.image.title="website-app" \
org.opencontainers.image.version="${VERSION}" \
org.opencontainers.image.revision="${REVISION}" \
org.opencontainers.image.source="https://github.com/danielheene/website"
WORKDIR /app
COPY --chown=node:node out/web ./
USER node
EXPOSE 3000
HEALTHCHECK --interval=60s --timeout=10s --retries=3 --start-period=30s \
CMD node -e "fetch('http://localhost:3000/api/health/app').then(r=>process.exit(r.ok?0:1)).catch(()=>process.exit(1))"
CMD ["node_modules/.bin/next", "start"]
# ---- worker ------------------------------------------------------------------
FROM node:${NODE_VERSION}-slim AS worker
ARG VERSION=""
ARG REVISION=""
ENV NODE_ENV=production
LABEL org.opencontainers.image.title="website-worker" \
org.opencontainers.image.version="${VERSION}" \
org.opencontainers.image.revision="${REVISION}" \
org.opencontainers.image.source="https://github.com/danielheene/website"
WORKDIR /app
COPY --chown=node:node out/worker ./
USER node
EXPOSE 3010
HEALTHCHECK --interval=60s --timeout=10s --retries=3 --start-period=30s \
CMD node -e "fetch('http://localhost:3010/health').then(r=>process.exit(r.ok?0:1)).catch(()=>process.exit(1))"
CMD ["node", "scripts/start-worker.mjs"]
# ---- storybook ---------------------------------------------------------------
FROM caddy:2-alpine AS storybook
ARG VERSION=""
ARG REVISION=""
LABEL org.opencontainers.image.title="website-storybook" \
org.opencontainers.image.version="${VERSION}" \
org.opencontainers.image.revision="${REVISION}" \
org.opencontainers.image.source="https://github.com/danielheene/website"
COPY out/storybook /srv
EXPOSE 3020
HEALTHCHECK --interval=60s --timeout=10s --retries=3 --start-period=30s \
CMD wget -q -O /dev/null http://localhost:3020 || exit 1
CMD ["caddy", "file-server", "--root", "/srv", "--listen", ":3020"]