-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathDockerfile
More file actions
30 lines (21 loc) · 691 Bytes
/
Dockerfile
File metadata and controls
30 lines (21 loc) · 691 Bytes
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
############ Build stage ############
FROM golang:1.24-alpine AS builder
WORKDIR /src
# Go caching tip: copy the go.mod first so `go mod download` can cache layers
COPY engine/go.mod engine/go.sum ./
RUN go mod download
# Copy the rest of the source
COPY engine .
# Build a small statically linked binary
RUN CGO_ENABLED=0 go build -ldflags="-s -w" -o /out/api-server .
############ Runtime stage ############
FROM alpine:3.20
# Create an unprivileged user (1000:1000 matches compose)
RUN addgroup -g 1000 app && adduser -S -u 1000 -G app app
WORKDIR /app
COPY --from=builder /out/api-server .
EXPOSE 8080
EXPOSE 9000
EXPOSE 443
USER 1000:1000
CMD ["./api-server"]