-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
48 lines (33 loc) · 1.32 KB
/
Copy pathDockerfile
File metadata and controls
48 lines (33 loc) · 1.32 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
# syntax=docker/dockerfile:1.7
FROM golang:1.25.11-alpine@sha256:c05ba4b73604069d376c4f41346b05374335b5ca0c46fb6dfede5a59f5196931 AS build
ARG TARGETARCH
ARG TARGETOS=linux
WORKDIR /src
COPY go.mod go.sum ./
RUN --mount=type=cache,target=/go/pkg/mod \
go mod download
COPY . .
ARG VERSION=docker
ARG BUILD_TIME=unknown
RUN --mount=type=cache,target=/go/pkg/mod \
--mount=type=cache,target=/root/.cache/go-build,id=go-build-${TARGETARCH} \
CGO_ENABLED=0 GOOS=${TARGETOS} GOARCH=${TARGETARCH} \
go build \
-trimpath \
-ldflags "-s -w \
-X github.com/radarnex/httpcatch/internal/buildinfo.Version=${VERSION} \
-X github.com/radarnex/httpcatch/internal/buildinfo.BuildTime=${BUILD_TIME}" \
-o /out/httpcatch \
./cmd/httpcatch
RUN mkdir -p /out/var/lib/httpcatch
FROM gcr.io/distroless/static-debian12:nonroot
LABEL org.opencontainers.image.source="https://github.com/radarnex/httpcatch" \
org.opencontainers.image.description="HTTP traffic capture and inspection tool" \
org.opencontainers.image.licenses="MIT"
COPY --from=build /out/httpcatch /usr/local/bin/httpcatch
COPY --from=build --chown=nonroot:nonroot /out/var/lib/httpcatch /var/lib/httpcatch
VOLUME ["/var/lib/httpcatch"]
EXPOSE 8080 8081
USER nonroot:nonroot
ENTRYPOINT ["/usr/local/bin/httpcatch"]
CMD ["serve"]