2019-12-17 01:25:17 +00:00
|
|
|
# use a builder image for building cloudflare
|
2020-05-29 01:06:27 +00:00
|
|
|
ARG TARGET_GOOS
|
|
|
|
ARG TARGET_GOARCH
|
2024-05-07 10:19:58 +00:00
|
|
|
FROM golang:1.22.2 as builder
|
2020-05-29 01:06:27 +00:00
|
|
|
ENV GO111MODULE=on \
|
|
|
|
CGO_ENABLED=0 \
|
|
|
|
TARGET_GOOS=${TARGET_GOOS} \
|
|
|
|
TARGET_GOARCH=${TARGET_GOARCH}
|
2024-01-08 10:34:40 +00:00
|
|
|
|
2019-04-29 21:25:34 +00:00
|
|
|
WORKDIR /go/src/github.com/cloudflare/cloudflared/
|
2019-12-17 01:25:17 +00:00
|
|
|
|
|
|
|
# copy our sources into the builder image
|
2019-04-29 21:25:34 +00:00
|
|
|
COPY . .
|
2019-12-17 01:25:17 +00:00
|
|
|
|
2024-01-08 10:34:40 +00:00
|
|
|
RUN .teamcity/install-cloudflare-go.sh
|
|
|
|
|
2019-12-17 01:25:17 +00:00
|
|
|
# compile cloudflared
|
2024-01-09 21:55:45 +00:00
|
|
|
RUN PATH="/tmp/go/bin:$PATH" make cloudflared
|
2019-04-29 21:25:34 +00:00
|
|
|
|
2019-12-17 01:25:17 +00:00
|
|
|
# use a distroless base image with glibc
|
2022-08-12 15:01:32 +00:00
|
|
|
FROM gcr.io/distroless/base-debian11:nonroot
|
2019-12-17 01:25:17 +00:00
|
|
|
|
2022-08-18 05:08:01 +00:00
|
|
|
LABEL org.opencontainers.image.source="https://github.com/cloudflare/cloudflared"
|
|
|
|
|
2019-12-17 01:25:17 +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
|
|
|
|
|
2024-06-08 14:18:52 +00:00
|
|
|
# set health-check
|
|
|
|
HEALTHCHECK &{["CMD-SHELL" "curl --fail http://127.0.0.1:80/ || exit 1"] "1m0s" "40s" "0s" '\n'}
|
|
|
|
|
2019-12-17 01:25:17 +00:00
|
|
|
# command / entrypoint of container
|
2019-04-29 21:25:34 +00:00
|
|
|
ENTRYPOINT ["cloudflared", "--no-autoupdate"]
|
|
|
|
CMD ["version"]
|