-
-
Notifications
You must be signed in to change notification settings - Fork 109
Expand file tree
/
Copy pathDockerfile
More file actions
74 lines (57 loc) · 2.83 KB
/
Copy pathDockerfile
File metadata and controls
74 lines (57 loc) · 2.83 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
# syntax=docker/dockerfile:1.7
# ZenNotes self-hosted build from the monorepo.
#
# Stages:
# 1. web-build -> npm workspace install + Vite build for apps/web
# 2. server-build -> Go build for apps/server with the web bundle embedded
# 3. runtime -> minimal image with only the server binary
# Base images pinned by digest. Refresh with Renovate/Dependabot or by
# running `docker inspect --format='{{index .RepoDigests 0}}' <image>`
# after a deliberate `docker pull` of the desired floating tag.
# web-build emits a platform-agnostic static bundle, so always run it on the
# native build platform (never under emulation) regardless of the target arch.
FROM --platform=$BUILDPLATFORM node:22-alpine@sha256:8ea2348b068a9544dae7317b4f3aafcdc032df1647bb7d768a05a5cad1a7683f AS web-build
WORKDIR /app
COPY package.json package-lock.json turbo.json tsconfig.base.json tsconfig.json tailwind.config.js postcss.config.js ./
COPY apps/web/package.json apps/web/package.json
COPY packages/app-core/package.json packages/app-core/package.json
COPY packages/bridge-contract/package.json packages/bridge-contract/package.json
COPY packages/shared-domain/package.json packages/shared-domain/package.json
COPY packages/shared-ui/package.json packages/shared-ui/package.json
COPY apps/desktop/package.json apps/desktop/package.json
COPY apps/server/package.json apps/server/package.json
RUN npm ci --no-audit --no-fund --loglevel=error
COPY apps apps
COPY packages packages
RUN npm run build --workspace @zennotes/web
# Run the Go toolchain on the native build platform and cross-compile to the
# target arch (CGO is off, so this is a fast pure-Go cross-build — no QEMU).
FROM --platform=$BUILDPLATFORM golang:1.26-alpine@sha256:3ad57304ad93bbec8548a0437ad9e06a455660655d9af011d58b993f6f615648 AS server-build
WORKDIR /app
COPY apps/server/go.mod apps/server/go.sum ./apps/server/
WORKDIR /app/apps/server
RUN go mod download
WORKDIR /app
COPY apps/server apps/server
COPY --from=web-build /app/apps/web/dist/ /app/apps/server/web/dist/
# TARGETARCH is provided by buildx (e.g. amd64, arm64) for the image being built.
ARG TARGETARCH
ENV CGO_ENABLED=0 \
GOOS=linux \
GOARCH=$TARGETARCH \
GOFLAGS=-trimpath
WORKDIR /app/apps/server
RUN go build -ldflags="-s -w" -o /out/zennotes-server ./cmd/zennotes-server
FROM scratch
LABEL org.opencontainers.image.title="ZenNotes" \
org.opencontainers.image.description="Self-hosted ZenNotes web/server bundle from the monorepo." \
org.opencontainers.image.source="https://github.com/ZenNotes/zennotes"
COPY --from=server-build /out/zennotes-server /zennotes-server
ENV ZENNOTES_BIND=0.0.0.0:7878 \
ZENNOTES_CONFIG_PATH=/data/server.json \
ZENNOTES_DEFAULT_VAULT_PATH=/workspace \
ZENNOTES_BROWSE_ROOTS=/workspace
USER 65532:65532
EXPOSE 7878
VOLUME ["/workspace", "/data"]
ENTRYPOINT ["/zennotes-server"]