Repository navigation
Expand file tree
/
Copy pathDockerfile
More file actions
68 lines (57 loc) · 2.14 KB
/
Copy pathDockerfile
File metadata and controls
68 lines (57 loc) · 2.14 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
# syntax=docker/dockerfile:1
# ==========================================
# Stage 0: Node (vendor frontend assets via npm)
# ==========================================
FROM node:22-alpine AS node-builder
WORKDIR /build/frontend
# Copy only dependency manifests first to leverage Docker layer caching
COPY frontend/package.json frontend/pnpm-lock.yaml* frontend/pnpm-workspace.yaml* ./
COPY frontend/packages/mindmap-engine/package.json packages/mindmap-engine/package.json
RUN corepack enable
RUN --mount=type=cache,target=/root/.local/share/pnpm/store \
pnpm install
# Copy the rest of the frontend source code and build
COPY frontend/ ./
RUN --mount=type=cache,target=/root/.local/share/pnpm/store \
pnpm run build
# ==========================================
# Stage 1: Go Builder
# ==========================================
FROM golang:1.26-alpine AS go-builder
WORKDIR /build
# Copy and download Go dependencies first
COPY go.mod go.sum* ./
RUN --mount=type=cache,target=/go/pkg/mod \
go mod download
# Copy frontend build artifacts just before the Go compilation step
COPY --from=node-builder /build/internal/assets/dist ./internal/assets/dist
# Copy Go source files last, as they change most frequently
COPY cmd/ ./cmd/
COPY internal/ ./internal/
COPY migrations/ ./migrations/
RUN --mount=type=cache,target=/go/pkg/mod \
--mount=type=cache,target=/root/.cache/go-build \
CGO_ENABLED=0 go build -trimpath -ldflags="-s -w" -o solid-mind ./cmd/solid-mind
# ==========================================
# Stage 2: Runtime
# ==========================================
FROM alpine:3.23
WORKDIR /solid-mind
RUN apk add --no-cache \
ca-certificates \
su-exec \
busybox-extras \
tzdata \
bash \
curl \
sqlite
RUN addgroup -g 1000 solid-mind && \
adduser -D -u 1000 -G solid-mind solid-mind
COPY --from=go-builder /build/solid-mind /usr/local/bin/solid-mind
RUN mkdir -p /certs /solid-mind/data
RUN chown -R solid-mind:solid-mind /solid-mind
COPY entrypoint.sh /usr/local/bin/entrypoint.sh
RUN chmod +x /usr/local/bin/entrypoint.sh
EXPOSE 3000
ENTRYPOINT ["/usr/local/bin/entrypoint.sh"]
CMD ["solid-mind", "serve", "--dir=data"]