-
-
Notifications
You must be signed in to change notification settings - Fork 38
Expand file tree
/
Copy pathDockerfile
More file actions
73 lines (48 loc) · 2.18 KB
/
Copy pathDockerfile
File metadata and controls
73 lines (48 loc) · 2.18 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
FROM node:24-bookworm-slim AS base
# build stage
FROM base AS deps
RUN corepack enable && corepack prepare pnpm@9 --activate
WORKDIR /app
COPY package.json pnpm-lock.yaml pnpm-workspace.yaml ./
RUN pnpm install --frozen-lockfile --prod
FROM base AS builder
RUN corepack enable && corepack prepare pnpm@9 --activate
WORKDIR /app
COPY package.json pnpm-lock.yaml pnpm-workspace.yaml ./
RUN pnpm install --frozen-lockfile
COPY . .
RUN sed -i "s/images:/output: 'standalone',images:/" next.config.ts
RUN pnpm run build
# run stage
FROM base AS runner
ENV NODE_ENV=production
ENV HOSTNAME=
RUN echo 'deb http://deb.debian.org/debian bookworm-backports main' >> /etc/apt/sources.list
RUN apt-get update && apt-get install -y \
supervisor curl jq jc borgbackup/bookworm-backports openssh-server gosu && \
apt-get clean && rm -rf /var/lib/apt/lists/*
# Remove the SSH host keys generated by the openssh-server install so the image
# never ships shared host keys. Fresh keys are generated at first boot by the
# entrypoint.
RUN rm -f /etc/ssh/ssh_host_*
# Remove the default 'node' user (UID 1000) to avoid conflicts with PUID=1000
RUN userdel -r node 2>/dev/null || true
RUN groupadd -g 1001 borgwarehouse && useradd -m -u 1001 -g 1001 -p '*' borgwarehouse
RUN cp /etc/ssh/moduli /home/borgwarehouse/
WORKDIR /home/borgwarehouse/app
# App files stay root:root (world-readable). Node runs as borgwarehouse and
# only needs read/execute access. Keeping the code root-owned makes it
# immutable from the running process: a compromised app cannot rewrite its
# own binaries to persist. Writable paths (volumes + $HOME) are chowned at
# runtime by the entrypoint.
COPY --from=builder /app/docker/docker-bw-init.sh /app/LICENSE ./
COPY --from=builder /app/helpers/shells ./helpers/shells
COPY --from=builder /app/.next/standalone ./
COPY --from=builder /app/public ./public
COPY --from=builder /app/.next/static ./.next/static
COPY --from=builder /app/docker/supervisord.conf ./
COPY --from=builder /app/docker/sshd_config ./
# Container starts as root to handle PUID/PGID remapping at runtime.
# The entrypoint drops to borgwarehouse before starting the app.
EXPOSE 3000 22
ENTRYPOINT ["./docker-bw-init.sh"]