From d3f9aa2ae7a6e2c4bce1c18ae32498104c386869 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johan=20Bergstro=CC=88m?= Date: Mon, 29 Apr 2019 17:25:34 -0400 Subject: [PATCH] Build a docker container Use debian/distroless (glibc) as a base which in general gives slightly higher performance than alpine (musl) while trading off container size (about 10mb). The build phase makes the assumption that any capnproto-files are pre-processed before building in-docker. --- Dockerfile | 12 ++++++++++++ Makefile | 4 ++++ 2 files changed, 16 insertions(+) create mode 100644 Dockerfile diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 00000000..7a142e6b --- /dev/null +++ b/Dockerfile @@ -0,0 +1,12 @@ +FROM golang:1.12 as builder +WORKDIR /go/src/github.com/cloudflare/cloudflared/ +RUN apt-get update && apt-get install -y --no-install-recommends upx +# Run after `apt-get update` to improve rebuild scenarios +COPY . . +RUN make cloudflared +RUN upx --no-progress cloudflared + +FROM gcr.io/distroless/base +COPY --from=builder /go/src/github.com/cloudflare/cloudflared/cloudflared /usr/local/bin/ +ENTRYPOINT ["cloudflared", "--no-autoupdate"] +CMD ["version"] diff --git a/Makefile b/Makefile index fb11ede1..da63e656 100644 --- a/Makefile +++ b/Makefile @@ -31,6 +31,10 @@ clean: cloudflared: tunnel-deps go build -v $(VERSION_FLAGS) $(IMPORT_PATH)/cmd/cloudflared +.PHONY: container +container: + docker build -t cloudflare/cloudflared:"$(VERSION)" . + .PHONY: test test: vet go test -v -race $(VERSION_FLAGS) ./...