-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
26 lines (19 loc) · 836 Bytes
/
Dockerfile
File metadata and controls
26 lines (19 loc) · 836 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
FROM golang:1.24-alpine AS build
WORKDIR /src
COPY go.mod go.sum ./
RUN go mod download
COPY . .
# Build ONLY the main package under /cmd (not ./...)
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -trimpath -ldflags="-s -w" -o /app ./cmd
FROM gcr.io/distroless/static:nonroot
# Keep defaults like "./geolite/GeoLite2-City.mmdb" working:
# distroless default WORKDIR is "/" so "./geolite/..." => "/geolite/..."
COPY --from=build /app /app
# Bake the mmdbs into the image at /geolite
COPY --chown=nonroot:nonroot geolite/GeoLite2-ASN.mmdb /geolite/GeoLite2-ASN.mmdb
COPY --chown=nonroot:nonroot geolite/GeoLite2-City.mmdb /geolite/GeoLite2-City.mmdb
# optional if you use it later:
# COPY --chown=nonroot:nonroot geolite/GeoLite2-Country.mmdb /geolite/GeoLite2-Country.mmdb
EXPOSE 8080
USER nonroot:nonroot
ENTRYPOINT ["/app"]