Skip to content

Commit

Permalink
Merge pull request #1433 from hairyhenderson/remove-slim
Browse files Browse the repository at this point in the history
Removing slim (UPX-compressed) binary/image support
  • Loading branch information
hairyhenderson authored Jun 19, 2022
2 parents 6b79f2a + 08cdb02 commit cc6e050
Show file tree
Hide file tree
Showing 6 changed files with 5 additions and 174 deletions.
9 changes: 0 additions & 9 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down
45 changes: 0 additions & 45 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
41 changes: 4 additions & 37 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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/*
Expand All @@ -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 $< > $@

Expand All @@ -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) \
Expand All @@ -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) \
Expand All @@ -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 \
Expand Down Expand Up @@ -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:
3 changes: 1 addition & 2 deletions docs/content/installing.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down
33 changes: 0 additions & 33 deletions hooks/build

This file was deleted.

48 changes: 0 additions & 48 deletions hooks/post_push

This file was deleted.

0 comments on commit cc6e050

Please sign in to comment.