Repository navigation
Expand file tree
/
Copy pathDockerfile
More file actions
45 lines (33 loc) · 1.55 KB
/
Copy pathDockerfile
File metadata and controls
45 lines (33 loc) · 1.55 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
# Build Stage. Pin the patched toolchain used by release builds.
FROM golang:1.25-bookworm AS builder
WORKDIR /app
# Copy dependency files
COPY go.mod go.sum ./
RUN go mod download
# Copy source code
COPY . .
# Build the application
# CGO_ENABLED=0 results in a static binary (no dependencies on host libraries)
# GOOS=linux ensures we build for Linux regardless of the host OS
ARG VERSION=dev
ARG BUILD_DATE=unknown
RUN CGO_ENABLED=0 GOOS=linux go build -trimpath -ldflags="-s -w -X main.Version=${VERSION} -X main.BuildDate=${BUILD_DATE}" -o /aegis ./cmd/aegis-server && \
CGO_ENABLED=0 GOOS=linux go build -trimpath -ldflags="-s -w -X main.Version=${VERSION} -X main.BuildDate=${BUILD_DATE}" -o /aegis-updater ./cmd/aegis-updater && \
mkdir -p /runtime/data/tls/certs /runtime/data/tls/acme
# Run Stage
FROM gcr.io/distroless/static-debian12
WORKDIR /var/lib/aegis
# Copy binary from builder
COPY --from=builder /aegis /aegis
COPY --from=builder /aegis-updater /aegis-updater
COPY --from=builder --chown=nonroot:nonroot /runtime/ /var/lib/aegis/
COPY --from=builder --chown=nonroot:nonroot /app/web/ /var/lib/aegis/web/
COPY --from=builder --chown=nonroot:nonroot /app/data/rules/ /var/lib/aegis/data/rules/
COPY --from=builder --chown=nonroot:nonroot /app/data/rules/ /var/lib/aegis/rules/
# Copy configuration (if present in context, otherwise user must mount it)
# Mount the installation config at /var/lib/aegis/config.yaml or set
# AEGIS_CONFIG to another mounted path.
EXPOSE 8080 8081
VOLUME ["/var/lib/aegis/data"]
USER nonroot:nonroot
ENTRYPOINT ["/aegis"]