From 8093376ecee515f1df28ab1fe4208418dc8fade7 Mon Sep 17 00:00:00 2001 From: Ben Redmond-Benham Date: Wed, 20 Jul 2022 19:58:00 +0100 Subject: [PATCH] build alpine base image (#311) --- Dockerfile | 9 +++++++++ releasing/README.md | 4 ++++ releasing/do-release.sh | 2 ++ 3 files changed, 15 insertions(+) diff --git a/Dockerfile b/Dockerfile index 1fe3fc19..72044ed7 100644 --- a/Dockerfile +++ b/Dockerfile @@ -16,6 +16,15 @@ RUN go build -o /grpcurl \ -ldflags "-w -extldflags \"-static\" -X \"main.version=$(cat VERSION)\"" \ ./cmd/grpcurl +FROM alpine:3 as alpine +WORKDIR / +COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ca-certificates.crt +COPY --from=builder /etc/passwd /etc/passwd +COPY --from=builder /grpcurl /bin/grpcurl +USER grpcurl + +ENTRYPOINT ["/bin/grpcurl"] + # New FROM so we have a nice'n'tiny image FROM scratch WORKDIR / diff --git a/releasing/README.md b/releasing/README.md index e553e2bd..0e0bba2a 100644 --- a/releasing/README.md +++ b/releasing/README.md @@ -59,11 +59,15 @@ To re-run only the Docker Hub release steps, we need to build an image with the # from the root of the repo echo v2.3.4 > VERSION docker build -t fullstorydev/grpcurl:v2.3.4 . +docker build -t fullstorydev/grpcurl:v2.3.4-alpine --target alpine . # now that we have it built, push to Docker Hub docker push fullstorydev/grpcurl:v2.3.4 +docker push fullstorydev/grpcurl:v2.3.4-alpine # push "latest" tag, too docker tag fullstorydev/grpcurl:v2.3.4 fullstorydev/grpcurl:latest +docker tag fullstorydev/grpcurl:v2.3.4-alpine fullstorydev/grpcurl:latest-alpine docker push fullstorydev/grpcurl:latest +docker push fullstorydev/grpcurl:latest-alpine ``` If the `docker push ...` steps fail, you may need to run `docker login`, enter your Docker Hub login credentials, and then try to push again. diff --git a/releasing/do-release.sh b/releasing/do-release.sh index b6020539..eddb0fe0 100755 --- a/releasing/do-release.sh +++ b/releasing/do-release.sh @@ -51,6 +51,8 @@ $PREFIX docker buildx create --use --name multiarch-builder --node multiarch-bui # push to docker hub, both the given version as a tag and for "latest" tag $PREFIX docker buildx build --platform linux/amd64,linux/s390x,linux/arm64,linux/ppc64le --tag fullstorydev/grpcurl:${VERSION} --tag fullstorydev/grpcurl:latest --push --progress plain --no-cache . rm VERSION +$PREFIX docker buildx build --platform linux/amd64,linux/s390x,linux/arm64 --tag fullstorydev/grpcurl:${VERSION}-alpine --tag fullstorydev/grpcurl:latest-alpine --push --progress plain --no-cache --target alpine . +rm VERSION # Homebrew release