Makefile: only build dev version of binary/docker

The Docker images release-light and release-full are not to be built
locally from a dev build, but from a release, and the commands to build
those images are only referenced in CI, so we don't need to ship them as
part of the makefile.
In addition, those images are not straightforward to build from the
Makefile, as they require quite a few things from the environment, as
well as the binary installed in a specific location, which is never
setup by the rest of the Makefile.

Therefore, we opted to simplify the Makefile so that it only builds
docker-dev for local use.
pull/12552/head
Lucas Bajolet 3 years ago committed by Lucas Bajolet
parent c6da777715
commit 55854f5537

@ -27,57 +27,6 @@ COPY bin/packer /bin/packer
ENTRYPOINT ["/bin/packer"]
# Official docker image that includes binaries from releases.hashicorp.com.
# This downloads the release from releases.hashicorp.com and therefore requires that
# the release is published before building the Docker image.
FROM docker.mirror.hashicorp.services/alpine:latest as official
# This is the release of Packer to pull in.
ARG PRODUCT_VERSION
LABEL name="Packer" \
maintainer="HashiCorp Packer Team <packer@hashicorp.com>" \
vendor="HashiCorp" \
version=$PRODUCT_VERSION \
release=$PRODUCT_VERSION \
summary="Packer is a tool for creating identical machine images for multiple platforms from a single source configuration." \
description="Packer is a tool for creating identical machine images for multiple platforms from a single source configuration. Please submit issues to https://github.com/hashicorp/packer/issues"
# This is the location of the releases.
ENV HASHICORP_RELEASES=https://releases.hashicorp.com
RUN set -eux && \
apk add --no-cache git bash wget openssl gnupg xorriso && \
gpg --keyserver keyserver.ubuntu.com --recv-keys C874011F0AB405110D02105534365D9472D7468F && \
mkdir -p /tmp/build && \
cd /tmp/build && \
apkArch="$(apk --print-arch)" && \
case "${apkArch}" in \
aarch64) packerArch='arm64' ;; \
armhf) packerArch='arm' ;; \
x86) packerArch='386' ;; \
x86_64) packerArch='amd64' ;; \
*) echo >&2 "error: unsupported architecture: ${apkArch} (see ${HASHICORP_RELEASES}/packer/${PRODUCT_VERSION}/)" && exit 1 ;; \
esac && \
wget ${HASHICORP_RELEASES}/packer/${PRODUCT_VERSION}/packer_${PRODUCT_VERSION}_linux_${packerArch}.zip && \
wget ${HASHICORP_RELEASES}/packer/${PRODUCT_VERSION}/packer_${PRODUCT_VERSION}_SHA256SUMS && \
wget ${HASHICORP_RELEASES}/packer/${PRODUCT_VERSION}/packer_${PRODUCT_VERSION}_SHA256SUMS.sig && \
gpg --batch --verify packer_${PRODUCT_VERSION}_SHA256SUMS.sig packer_${PRODUCT_VERSION}_SHA256SUMS && \
grep packer_${PRODUCT_VERSION}_linux_${packerArch}.zip packer_${PRODUCT_VERSION}_SHA256SUMS | sha256sum -c && \
unzip -d /tmp/build packer_${PRODUCT_VERSION}_linux_${packerArch}.zip && \
cp /tmp/build/packer /bin/packer && \
cd /tmp && \
rm -rf /tmp/build && \
gpgconf --kill all && \
apk del gnupg openssl && \
rm -rf /root/.gnupg && \
# Tiny smoke test to ensure the binary we downloaded runs
packer version
ENTRYPOINT ["/bin/packer"]
# Light docker image which can be used to run the binary from a container.
# This image builds from the locally generated binary in ./bin/, and from CI-built binaries within CI.
# To generate the local binary, run `make dev`.

@ -71,41 +71,22 @@ dev: ## Build and install a development build
# Docker build variables and targets
REGISTRY_NAME?=docker.io/hashicorp
IMAGE_NAME=packer
VERSION?=1.7.10
IMAGE_TAG=$(REGISTRY_NAME)/$(IMAGE_NAME):$(VERSION)
IMAGE_TAG_DEV=$(REGISTRY_NAME)/$(IMAGE_NAME):latest-$(shell git rev-parse --short HEAD)
docker: docker-official
docker-light: docker-official
# Builds from the releases.hashicorp.com official binary
docker-official:
docker build \
--tag $(IMAGE_TAG) \
--tag hashicorp/packer:latest \
--target=official \
--build-arg VERSION=$(VERSION) \
.
IMAGE_TAG_DEV=$(REGISTRY_NAME)/$(IMAGE_NAME):latest-$(GIT_COMMIT)
# Builds multiarch from the releases.hashicorp.com official binary
docker-multiarch-official:
docker buildx build \
--tag $(IMAGE_TAG) \
--tag hashicorp/packer:latest \
--target=official \
--build-arg VERSION=$(VERSION) \
--platform linux/amd64,linux/arm64 \
.
docker: docker-dev
# Builds from the locally generated binary in ./bin/
# To generate the local binary, run `make dev`
docker-dev: export GOOS=linux
docker-dev: export GOARCH=amd64
docker-dev: dev
docker-dev:
@GOOS=linux \
GOARCH=amd64 \
CGO_ENABLED=0 \
go build -ldflags '$(GOLDFLAGS)' -o bin/packer .
@docker build \
--tag $(IMAGE_TAG_DEV) \
--target=dev \
.
@rm -f bin/packer # Clean up the Linux/amd64 binary to avoid conficts on other OS/archs
lint: install-lint-deps ## Lint Go code
@if [ ! -z $(PKG_NAME) ]; then \

Loading…
Cancel
Save