From 9214290ef67d8ac2a960ac10d634a91854ccdb20 Mon Sep 17 00:00:00 2001 From: Sean Slattery Date: Tue, 28 Nov 2023 12:38:12 -0600 Subject: [PATCH] Switch from alpine to distroless, add -extldflags static --- .goreleaser.yml | 4 ++-- Makefile | 2 +- docker/Dockerfile | 11 +++++++++++ 3 files changed, 14 insertions(+), 3 deletions(-) create mode 100644 docker/Dockerfile diff --git a/.goreleaser.yml b/.goreleaser.yml index 197107d9..94e77739 100644 --- a/.goreleaser.yml +++ b/.goreleaser.yml @@ -34,7 +34,7 @@ builds: - goos: freebsd goarch: "386" ldflags: - - -s -w -X github.com/DopplerHQ/cli/pkg/version.ProgramVersion=v{{.Version}} + - -extldflags "-static" -s -w -X github.com/DopplerHQ/cli/pkg/version.ProgramVersion=v{{.Version}} archives: - @@ -105,7 +105,7 @@ changelog: - Merge branch dockers: - - dockerfile: docker/alpine + - dockerfile: docker/Dockerfile goos: linux goarch: amd64 ids: diff --git a/Makefile b/Makefile index dbd20d6b..c1b31dd8 100644 --- a/Makefile +++ b/Makefile @@ -1,7 +1,7 @@ .PHONY: build release test build: - go build -o doppler -ldflags="-X github.com/DopplerHQ/cli/pkg/version.ProgramVersion=dev-$(shell git rev-parse --abbrev-ref HEAD)-$(shell git rev-parse --short HEAD)" main.go + GGO_ENABLED=0 go build -o doppler -ldflags="-extldflags "-static" -X github.com/DopplerHQ/cli/pkg/version.ProgramVersion=dev-$(shell git rev-parse --abbrev-ref HEAD)-$(shell git rev-parse --short HEAD)" main.go test: go test ./pkg/... -v diff --git a/docker/Dockerfile b/docker/Dockerfile new file mode 100644 index 00000000..00137bce --- /dev/null +++ b/docker/Dockerfile @@ -0,0 +1,11 @@ +FROM debian:12-slim as build +RUN apt-get update \ + && apt-get install -y \ + tini \ + && rm -rf /var/lib/apt/lists/* + +FROM gcr.io/distroless/static-debian12:latest-amd64 +COPY --from=build /usr/bin/tini-static /usr/bin/tini-static + +COPY doppler /bin/doppler +ENTRYPOINT ["/usr/bin/tini-static", "--", "/bin/doppler"]