2022-08-12 15:01:32 +00:00
|
|
|
# use a builder image for building cloudflare
|
2023-12-11 11:58:19 +00:00
|
|
|
FROM golang:1.21.5 as builder
|
2022-08-12 15:01:32 +00:00
|
|
|
ENV GO111MODULE=on \
|
|
|
|
CGO_ENABLED=0
|
|
|
|
|
|
|
|
WORKDIR /go/src/github.com/cloudflare/cloudflared/
|
|
|
|
|
|
|
|
# copy our sources into the builder image
|
|
|
|
COPY . .
|
|
|
|
|
2024-01-08 10:34:40 +00:00
|
|
|
RUN .teamcity/install-cloudflare-go.sh
|
|
|
|
|
2022-08-12 15:01:32 +00:00
|
|
|
# compile cloudflared
|
2024-01-09 21:55:45 +00:00
|
|
|
RUN GOOS=linux GOARCH=amd64 PATH="/tmp/go/bin:$PATH" make cloudflared
|
2022-08-12 15:01:32 +00:00
|
|
|
|
|
|
|
# use a distroless base image with glibc
|
|
|
|
FROM gcr.io/distroless/base-debian11:nonroot
|
|
|
|
|
2022-08-18 05:08:01 +00:00
|
|
|
LABEL org.opencontainers.image.source="https://github.com/cloudflare/cloudflared"
|
|
|
|
|
2022-08-12 15:01:32 +00:00
|
|
|
# copy our compiled binary
|
|
|
|
COPY --from=builder --chown=nonroot /go/src/github.com/cloudflare/cloudflared/cloudflared /usr/local/bin/
|
|
|
|
|
|
|
|
# run as non-privileged user
|
|
|
|
USER nonroot
|
|
|
|
|
|
|
|
# command / entrypoint of container
|
|
|
|
ENTRYPOINT ["cloudflared", "--no-autoupdate"]
|
|
|
|
CMD ["version"]
|