-
-
Notifications
You must be signed in to change notification settings - Fork 106
/
Copy pathci.Dockerfile
40 lines (29 loc) · 1.17 KB
/
ci.Dockerfile
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
# build app
FROM --platform=$BUILDPLATFORM golang:1.23.2-alpine3.20 AS app-builder
RUN apk add --no-cache git tzdata
ENV SERVICE=bitmagnet
WORKDIR /src
# Cache Go modules
COPY go.mod go.sum ./
RUN go mod download
COPY . ./
ARG VERSION=dev
ARG REVISION=dev
ARG BUILDTIME
ARG TARGETOS TARGETARCH TARGETVARIANT
RUN --network=none --mount=target=. \
export GOOS=$TARGETOS; \
export GOARCH=$TARGETARCH; \
[[ "$GOARCH" == "amd64" ]] && export GOAMD64=$TARGETVARIANT; \
[[ "$GOARCH" == "arm" ]] && [[ "$TARGETVARIANT" == "v6" ]] && export GOARM=6; \
[[ "$GOARCH" == "arm" ]] && [[ "$TARGETVARIANT" == "v7" ]] && export GOARM=7; \
echo $GOARCH $GOOS $GOARM$GOAMD64; \
go build -ldflags "-s -w -X github.com/bitmagnet-io/bitmagnet/internal/version.GitTag=${VERSION}" -o /build/bitmagnet main.go
# build runner
FROM alpine:latest AS runner
LABEL org.opencontainers.image.source = "https://github.com/bitmagnet-io/bitmagnet"
LABEL org.opencontainers.image.licenses = "MIT"
LABEL org.opencontainers.image.base.name = "alpine:latest"
RUN apk --no-cache add ca-certificates curl tzdata jq iproute2-ss
COPY --link --from=app-builder /build/bitmagnet* /usr/local/bin/
ENTRYPOINT ["/usr/local/bin/bitmagnet"]