From 08cdb02164b4c3f2d72ffff20730d126955444d3 Mon Sep 17 00:00:00 2001 From: Dave Henderson Date: Sat, 18 Jun 2022 14:12:54 -0400 Subject: [PATCH] Removing slim (UPX-compressed) binary/image support Signed-off-by: Dave Henderson --- .github/workflows/docker.yml | 9 ------- Dockerfile | 45 --------------------------------- Makefile | 41 +++--------------------------- docs/content/installing.md | 3 +-- hooks/build | 33 ------------------------- hooks/post_push | 48 ------------------------------------ 6 files changed, 5 insertions(+), 174 deletions(-) delete mode 100755 hooks/build delete mode 100755 hooks/post_push diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index ed6ee7920..6c3c1ec9b 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -55,7 +55,6 @@ jobs: make docker-multi COMMIT=${{ github.sha }} DOCKER_REPO=localhost:5000/gomplate BUILDX_ACTION=--push docker buildx imagetools create --dry-run -t localhost:5000/gomplate:dev localhost:5000/gomplate:latest - docker buildx imagetools create --dry-run -t localhost:5000/gomplate:dev-slim localhost:5000/gomplate:slim docker buildx imagetools create --dry-run -t localhost:5000/gomplate:dev-alpine localhost:5000/gomplate:alpine if: github.repository != 'hairyhenderson/gomplate' || (github.ref != 'refs/heads/main' && env.is_tag != 'true') - name: Login to GHCR @@ -88,10 +87,6 @@ jobs: docker buildx imagetools create -t ${repo}:${git_tag} ${repo}:latest docker buildx imagetools create -t ${repo}:${major_version} ${repo}:latest - docker buildx imagetools create -t ${repo}:stable-slim ${repo}:slim - docker buildx imagetools create -t ${repo}:${git_tag}-slim ${repo}:slim - docker buildx imagetools create -t ${repo}:${major_version}-slim ${repo}:slim - docker buildx imagetools create -t ${repo}:stable-alpine ${repo}:alpine docker buildx imagetools create -t ${repo}:${git_tag}-alpine ${repo}:alpine docker buildx imagetools create -t ${repo}:${major_version}-alpine ${repo}:alpine @@ -102,10 +97,6 @@ jobs: docker buildx imagetools create -t ${repo}:${git_tag} ${repo}:latest docker buildx imagetools create -t ${repo}:${major_version} ${repo}:latest - docker buildx imagetools create -t ${repo}:stable-slim ${repo}:slim - docker buildx imagetools create -t ${repo}:${git_tag}-slim ${repo}:slim - docker buildx imagetools create -t ${repo}:${major_version}-slim ${repo}:slim - docker buildx imagetools create -t ${repo}:stable-alpine ${repo}:alpine docker buildx imagetools create -t ${repo}:${git_tag}-alpine ${repo}:alpine docker buildx imagetools create -t ${repo}:${major_version}-alpine ${repo}:alpine diff --git a/Dockerfile b/Dockerfile index ddd9b17c7..3d7b11e44 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,6 +1,4 @@ # syntax=docker/dockerfile:1.3.1-labs -FROM --platform=linux/amd64 hairyhenderson/upx:3.94 AS upx - FROM --platform=linux/amd64 golang:1.18-alpine AS build ARG TARGETOS @@ -25,27 +23,6 @@ RUN --mount=type=cache,id=go-build-${TARGETOS}-${TARGETARCH}${TARGETVARIANT},tar make build RUN mv bin/gomplate* /bin/ -FROM --platform=linux/amd64 alpine:3.16 AS compress - -ARG TARGETOS -ARG TARGETARCH -ARG TARGETVARIANT - -RUN apk add --no-cache \ - make \ - libgcc libstdc++ ucl - -ENV GOOS=$TARGETOS GOARCH=$TARGETARCH -WORKDIR /go/src/github.com/hairyhenderson/gomplate -COPY Makefile . -RUN mkdir bin - -COPY --from=upx /usr/bin/upx /usr/bin/upx -COPY --from=build bin/* bin/ - -RUN make compress -RUN mv bin/gomplate* /bin/ - FROM scratch AS gomplate-linux ARG VCS_REF @@ -76,32 +53,10 @@ COPY --from=build /bin/gomplate_${TARGETOS}-${TARGETARCH}${TARGETVARIANT} /bin/g ENTRYPOINT [ "/bin/gomplate" ] -FROM scratch AS gomplate-slim-linux - -ARG VCS_REF -ARG TARGETOS -ARG TARGETARCH -ARG TARGETVARIANT - -LABEL org.opencontainers.image.revision=$VCS_REF \ - org.opencontainers.image.source="https://github.com/hairyhenderson/gomplate" - -COPY --from=build /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ca-certificates.crt -COPY --from=compress /bin/gomplate_${TARGETOS}-${TARGETARCH}${TARGETVARIANT}-slim /gomplate - -ENTRYPOINT [ "/gomplate" ] - FROM --platform=windows/amd64 mcr.microsoft.com/windows/nanoserver:2009 AS gomplate-windows ARG TARGETOS ARG TARGETARCH ARG TARGETVARIANT COPY --from=build /bin/gomplate_${TARGETOS}-${TARGETARCH}${TARGETVARIANT}.exe /gomplate.exe -FROM --platform=windows/amd64 mcr.microsoft.com/windows/nanoserver:2009 AS gomplate-slim-windows -ARG TARGETOS -ARG TARGETARCH -ARG TARGETVARIANT -COPY --from=compress /bin/gomplate_${TARGETOS}-${TARGETARCH}${TARGETVARIANT}-slim.exe /gomplate.exe - FROM gomplate-$TARGETOS AS gomplate -FROM gomplate-slim-$TARGETOS AS gomplate-slim diff --git a/Makefile b/Makefile index a627b81aa..0de5ffa74 100644 --- a/Makefile +++ b/Makefile @@ -9,7 +9,6 @@ DOCKER_PLATFORMS ?= $(DOCKER_LINUX_PLATFORMS),windows/amd64 # we just load by default, as a "dry run" BUILDX_ACTION ?= --load TAG_LATEST ?= latest -TAG_SLIM ?= slim TAG_ALPINE ?= alpine ifeq ("$(CI)","true") @@ -39,7 +38,6 @@ endif # platforms := freebsd-amd64 linux-amd64 linux-386 linux-armv5 linux-armv6 linux-armv7 linux-arm64 darwin-amd64 solaris-amd64 windows-amd64.exe windows-386.exe platforms := freebsd-amd64 linux-amd64 linux-386 linux-armv6 linux-armv7 linux-arm64 darwin-amd64 darwin-arm64 solaris-amd64 windows-amd64.exe windows-386.exe -compressed-platforms := linux-amd64-slim linux-armv6-slim linux-armv7-slim linux-arm64-slim darwin-amd64-slim windows-amd64-slim.exe clean: rm -Rf $(PREFIX)/bin/* @@ -53,26 +51,6 @@ $(PREFIX)/bin/%.zip: $(PREFIX)/bin/% $(PREFIX)/bin/$(PKG_NAME)_windows-%.zip: $(PREFIX)/bin/$(PKG_NAME)_windows-%.exe @zip -j $@ $^ -compress-all: $(patsubst %,$(PREFIX)/bin/$(PKG_NAME)_%,$(compressed-platforms)) - -UPX_VERSION := $(shell upx --version | head -n1 | cut -f2 -d\ ) -UPX_REQUIRED_VERSION := 3.94 - - -ifeq ($(UPX_REQUIRED_VERSION),$(UPX_VERSION)) -$(PREFIX)/bin/$(PKG_NAME)_%-slim: $(PREFIX)/bin/$(PKG_NAME)_% - upx --lzma $< -o $@ -$(PREFIX)/bin/$(PKG_NAME)_windows-%-slim.exe: $(PREFIX)/bin/$(PKG_NAME)_windows-%.exe - upx --lzma $< -o $@ -else -$(PREFIX)/bin/$(PKG_NAME)_%-slim: - $(error Wrong upx version - need $(UPX_REQUIRED_VERSION)) - -$(PREFIX)/bin/$(PKG_NAME)_windows-%-slim.exe: - $(error Wrong upx version - need $(UPX_REQUIRED_VERSION)) -endif - - $(PREFIX)/bin/$(PKG_NAME)_%_checksum_sha256.txt: $(PREFIX)/bin/$(PKG_NAME)_% @sha256sum $< > $@ @@ -83,21 +61,16 @@ $(PREFIX)/bin/checksums.txt: $(PREFIX)/bin/checksums_sha256.txt @cp $< $@ $(PREFIX)/bin/checksums_sha256.txt: \ - $(patsubst %,$(PREFIX)/bin/$(PKG_NAME)_%_checksum_sha256.txt,$(platforms)) \ - $(patsubst %,$(PREFIX)/bin/$(PKG_NAME)_%_checksum_sha256.txt,$(compressed-platforms)) + $(patsubst %,$(PREFIX)/bin/$(PKG_NAME)_%_checksum_sha256.txt,$(platforms)) @cat $^ > $@ $(PREFIX)/bin/checksums_sha512.txt: \ - $(patsubst %,$(PREFIX)/bin/$(PKG_NAME)_%_checksum_sha512.txt,$(platforms)) \ - $(patsubst %,$(PREFIX)/bin/$(PKG_NAME)_%_checksum_sha512.txt,$(compressed-platforms)) + $(patsubst %,$(PREFIX)/bin/$(PKG_NAME)_%_checksum_sha512.txt,$(platforms)) @cat $^ > $@ $(PREFIX)/%.signed: $(PREFIX)/% @keybase sign < $< > $@ -compress: $(PREFIX)/bin/$(PKG_NAME)_$(GOOS)-$(GOARCH)$(TARGETVARIANT)-slim$(call extension,$(GOOS)) - cp $< $(PREFIX)/bin/$(PKG_NAME)-slim$(call extension,$(GOOS)) - %.iid: Dockerfile @docker build \ --build-arg VCS_REF=$(COMMIT) \ @@ -112,12 +85,6 @@ docker-multi: Dockerfile --tag $(DOCKER_REPO):$(TAG_LATEST) \ --target gomplate \ $(BUILDX_ACTION) . - docker buildx build \ - --build-arg VCS_REF=$(COMMIT) \ - --platform $(DOCKER_PLATFORMS) \ - --tag $(DOCKER_REPO):$(TAG_SLIM) \ - --target gomplate-slim \ - $(BUILDX_ACTION) . docker buildx build \ --build-arg VCS_REF=$(COMMIT) \ --platform $(DOCKER_LINUX_PLATFORMS) \ @@ -131,7 +98,7 @@ docker-multi: Dockerfile build-release: artifacts.cid @docker cp $(shell cat $<):/bin/. bin/ -docker-images: gomplate.iid gomplate-slim.iid +docker-images: gomplate.iid $(PREFIX)/bin/$(PKG_NAME)_%v5$(call extension,$(GOOS)): $(shell find $(PREFIX) -type f -name "*.go") GOOS=$(shell echo $* | cut -f1 -d-) GOARCH=$(shell echo $* | cut -f2 -d- ) GOARM=5 CGO_ENABLED=0 \ @@ -223,6 +190,6 @@ lint: ci-lint: @golangci-lint run --verbose --max-same-issues=0 --max-issues-per-linter=0 --out-format=github-actions -.PHONY: gen-changelog clean test build-x compress-all build-release build test-integration-docker gen-docs lint clean-images clean-containers docker-images +.PHONY: gen-changelog clean test build-x build-release build test-integration-docker gen-docs lint clean-images clean-containers docker-images .DELETE_ON_ERROR: .SECONDARY: diff --git a/docs/content/installing.md b/docs/content/installing.md index 61650e954..f55103009 100644 --- a/docs/content/installing.md +++ b/docs/content/installing.md @@ -48,7 +48,7 @@ _Note: the Alpine version of gomplate may lag behind the latest release of gompl ## use with Docker -A simple way to get started is with one of the [hairyhenderson/gomplate][] Docker images. Images containing [`slim` binaries](#slim-binaries) are tagged as `:slim` or `:vX.Y.Z-slim`. +A simple way to get started is with one of the [hairyhenderson/gomplate][] Docker images. ```console $ docker run hairyhenderson/gomplate:stable --version @@ -98,7 +98,6 @@ RUN apk add --no-cache ca-certificates ## manual install 1. Get the latest `gomplate` for your platform from the [releases][] page - - if available, you may want to download the [`-slim` variant](#slim-binaries) 2. Store the downloaded binary somewhere in your path as `gomplate` (or `gomplate.exe` on Windows) 3. Make sure it's executable (on Linux/macOS) diff --git a/hooks/build b/hooks/build deleted file mode 100755 index d7776ddfc..000000000 --- a/hooks/build +++ /dev/null @@ -1,33 +0,0 @@ -#!/bin/bash -set -exuo pipefail - -echo "======== Build hook running" -export VCS_REF=`git rev-parse --short HEAD` -export DOCKER_REPO=${DOCKER_REPO:-hairyhenderson/gomplate} -export DOCKER_TAG=${DOCKER_TAG:-latest} -export IMAGE_NAME=${IMAGE_NAME:-${DOCKER_REPO}:${DOCKER_TAG}} - -make artifacts.iid -docker tag $(< artifacts.iid) ${DOCKER_REPO}:artifacts - -echo "======== Building $IMAGE_NAME" -make gomplate.iid -docker tag $(< gomplate.iid) ${IMAGE_NAME} - -if [ "$DOCKER_TAG" == "latest" ]; then - export SLIM_TAG="slim" -else - export SLIM_TAG="${DOCKER_TAG}-slim" -fi -echo "======== Building ${DOCKER_REPO}:${SLIM_TAG}" -make gomplate-slim.iid -docker tag $(< gomplate-slim.iid) ${DOCKER_REPO}:${SLIM_TAG} - -if [ "$DOCKER_TAG" == "latest" ]; then - export ALPINE_TAG="alpine" -else - export ALPINE_TAG="${DOCKER_TAG}-alpine" -fi -echo "======== Building ${DOCKER_REPO}:${ALPINE_TAG}" -make gomplate-alpine.iid -docker tag $(< gomplate-alpine.iid) ${DOCKER_REPO}:${ALPINE_TAG} diff --git a/hooks/post_push b/hooks/post_push deleted file mode 100755 index 46f71bfe4..000000000 --- a/hooks/post_push +++ /dev/null @@ -1,48 +0,0 @@ -#!/bin/bash -set -exuo pipefail - -export DOCKER_REPO=${DOCKER_REPO:-hairyhenderson/gomplate} -export DOCKER_TAG=${DOCKER_TAG:-latest} -export IMAGE_NAME=${IMAGE_NAME:-${DOCKER_REPO}:${DOCKER_TAG}} - -docker push ${DOCKER_REPO}:artifacts - -if [ "$DOCKER_TAG" == "latest" ]; then - export SLIM_TAG="slim" - export ALPINE_TAG="alpine" -else - export SLIM_TAG="${DOCKER_TAG}-slim" - export ALPINE_TAG="${DOCKER_TAG}-alpine" -fi - -# Need to push the other images too -docker push $DOCKER_REPO:${SLIM_TAG} -docker push $DOCKER_REPO:${ALPINE_TAG} - -# This magic figures out if we're currently on a tag (i.e. a release). -# We only want to have special tags for releases. -if (git describe --abbrev=0 --exact-match &>/dev/null); then - tag=$(git describe --abbrev=0 --exact-match) - # splits the major version from $tag - assumes it's a 3-part semver - major=${tag%%\.*} - # if we ever want minor tags, this is how - # minor=${tag%\.*} - docker tag $IMAGE_NAME $DOCKER_REPO:${tag} - docker tag $IMAGE_NAME $DOCKER_REPO:stable - docker tag $IMAGE_NAME $DOCKER_REPO:${major} - docker tag $DOCKER_REPO:${SLIM_TAG} $DOCKER_REPO:${tag}-slim - docker tag $DOCKER_REPO:${SLIM_TAG} $DOCKER_REPO:${major}-slim - docker tag $DOCKER_REPO:${SLIM_TAG} $DOCKER_REPO:stable-slim - docker tag $DOCKER_REPO:${ALPINE_TAG} $DOCKER_REPO:${tag}-alpine - docker tag $DOCKER_REPO:${ALPINE_TAG} $DOCKER_REPO:${major}-alpine - docker tag $DOCKER_REPO:${ALPINE_TAG} $DOCKER_REPO:stable-alpine - docker push $DOCKER_REPO:${tag} - docker push $DOCKER_REPO:${major} - docker push $DOCKER_REPO:stable - docker push $DOCKER_REPO:${tag}-slim - docker push $DOCKER_REPO:${major}-slim - docker push $DOCKER_REPO:stable-slim - docker push $DOCKER_REPO:${tag}-alpine - docker push $DOCKER_REPO:${major}-alpine - docker push $DOCKER_REPO:stable-alpine -fi