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
|
2021-09-21 11:06:27 +00:00
|
|
|
FROM golang:1.17.1 as builder
|
2020-05-29 01:06:27 +00:00
|
|
|
ENV GO111MODULE=on \
|
|
|
|
CGO_ENABLED=0 \
|
|
|
|
TARGET_GOOS=${TARGET_GOOS} \
|
|
|
|
TARGET_GOARCH=${TARGET_GOARCH}
|
2019-12-17 01:25:17 +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
|
|
|
|
|
|
|
# compile cloudflared
|
2019-04-29 21:25:34 +00:00
|
|
|
RUN make cloudflared
|
|
|
|
|
2019-12-17 01:25:17 +00:00
|
|
|
# use a distroless base image with glibc
|
|
|
|
FROM gcr.io/distroless/base-debian10:nonroot
|
|
|
|
|
|
|
|
# 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
|
2019-04-29 21:25:34 +00:00
|
|
|
ENTRYPOINT ["cloudflared", "--no-autoupdate"]
|
|
|
|
CMD ["version"]
|
2022-03-30 10:21:05 +00:00
|
|
|
|
|
|
|
# expose metrics server
|
|
|
|
EXPOSE 2000
|