-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
38 lines (36 loc) · 1.1 KB
/
Copy pathDockerfile
File metadata and controls
38 lines (36 loc) · 1.1 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
# Stage 1: Build frontend
FROM node:20-alpine AS frontend
ENV PNPM_HOME=/pnpm
ENV PATH=$PNPM_HOME:$PATH
WORKDIR /app/web
RUN corepack enable
COPY web/package.json web/pnpm-lock.yaml ./
RUN pnpm install --frozen-lockfile
COPY web/ ./
RUN pnpm build
# Stage 2: Build backend
FROM golang:1.24-alpine AS backend
WORKDIR /app
RUN apk add --no-cache gcc musl-dev
COPY go.mod go.sum ./
RUN go mod download
COPY . .
COPY --from=frontend /app/web/dist ./internal/router/dist
RUN CGO_ENABLED=1 GOOS=linux go build -ldflags="-s -w" -o subdock .
# Stage 3: Runtime
FROM alpine:3.21
WORKDIR /app
RUN addgroup -S -g 1000 subdock \
&& adduser -S -D -H -u 1000 -G subdock subdock \
&& apk add --no-cache ca-certificates tzdata \
&& mkdir -p /data \
&& chown -R subdock:subdock /app /data \
&& chmod 0700 /data
COPY --from=backend --chown=subdock:subdock /app/subdock .
ENV DATA_DIR=/data PORT=8080
EXPOSE 8080
VOLUME /data
USER subdock:subdock
HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
CMD wget -q -T 2 -O /dev/null "http://127.0.0.1:${PORT}/api/config" || exit 1
CMD ["./subdock"]