-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
55 lines (43 loc) · 1.91 KB
/
Copy pathDockerfile
File metadata and controls
55 lines (43 loc) · 1.91 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
49
50
51
52
53
54
55
# syntax=docker/dockerfile:1.12
FROM --platform=$BUILDPLATFORM golang:1.27.0-alpine@sha256:4c9fe60190a2a3350ddc51de80d0224b8a6698d12bdfc999fee45ea9d6c46dbc AS build
RUN apk add --no-cache ca-certificates
WORKDIR /src
COPY go.mod go.sum ./
RUN --mount=type=cache,target=/go/pkg/mod \
go mod download
COPY cmd/rule-bot-client ./cmd/rule-bot-client
COPY internal/client ./internal/client
ARG TARGETOS
ARG TARGETARCH
ARG TARGETVARIANT
ARG VERSION=dev
ARG COMMIT=unknown
ARG BUILD_DATE=unknown
RUN --mount=type=cache,target=/go/pkg/mod \
--mount=type=cache,target=/root/.cache/go-build \
set -eu; \
export CGO_ENABLED=0 GOOS="$TARGETOS" GOARCH="$TARGETARCH"; \
if [ "$TARGETARCH" = "arm" ]; then export GOARM="${TARGETVARIANT#v}"; fi; \
go build -buildvcs=false -trimpath \
-ldflags="-s -w -buildid= \
-X github.com/Aethersailor/Rule-Bot-Client/internal/client.BuildVersion=$VERSION \
-X github.com/Aethersailor/Rule-Bot-Client/internal/client.BuildCommit=$COMMIT \
-X github.com/Aethersailor/Rule-Bot-Client/internal/client.BuildDate=$BUILD_DATE" \
-o /out/rule-bot-client ./cmd/rule-bot-client
FROM scratch
ARG VERSION=dev
ARG COMMIT=unknown
ARG BUILD_DATE=unknown
LABEL org.opencontainers.image.title="Rule-Bot Client" \
org.opencontainers.image.description="Lightweight final MATCH-rule domain collector" \
org.opencontainers.image.source="https://github.com/Aethersailor/Rule-Bot-Client" \
org.opencontainers.image.licenses="AGPL-3.0-only" \
org.opencontainers.image.version="$VERSION" \
org.opencontainers.image.revision="$COMMIT" \
org.opencontainers.image.created="$BUILD_DATE"
COPY --from=build /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ca-certificates.crt
COPY --from=build --chown=10001:10001 /out/rule-bot-client /rule-bot-client
USER 10001:10001
WORKDIR /data
ENTRYPOINT ["/rule-bot-client"]
CMD ["--config", "/data/config.json"]