2022-02-25 18:56:20 -05:00
# ========================================================================
#
# This Dockerfile contains multiple targets.
# Use 'docker build --target=<name> .' to build one.
# e.g. `docker build --target=release-light .`
#
2022-08-17 20:45:26 -04:00
# All non-dev targets have a PRODUCT_VERSION argument that must be provided
# via --build-arg=PRODUCT_VERSION=<version> when building.
# e.g. --build-arg PRODUCT_VERSION=1.11.2
2022-02-25 18:56:20 -05:00
#
# For local dev and testing purposes, please build and use the `dev` docker image.
#
# ========================================================================
2018-10-24 17:02:36 -04:00
2022-02-25 18:56:20 -05:00
# Development docker image primarily used for development and debugging.
# This image builds from the locally generated binary in ./bin/.
# To generate the local binary, run `make dev`.
FROM docker.mirror.hashicorp.services/alpine:latest as dev
2018-10-24 17:02:36 -04:00
2022-02-25 18:56:20 -05:00
RUN apk add --no-cache git bash openssl ca-certificates
2018-10-24 17:02:36 -04:00
2022-02-25 18:56:20 -05:00
COPY bin/packer /bin/packer
2018-10-24 17:02:36 -04:00
2022-02-25 18:56:20 -05:00
ENTRYPOINT [ "/bin/packer" ]
2018-10-24 17:02:36 -04:00
2022-02-25 18:56:20 -05:00
# 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.
2022-08-17 20:45:26 -04:00
ARG PRODUCT_VERSION
2022-02-25 18:56:20 -05:00
LABEL name = "Packer" \
maintainer = "HashiCorp Packer Team <packer@hashicorp.com>" \
vendor = "HashiCorp" \
2022-08-17 20:45:26 -04:00
version = $PRODUCT_VERSION \
release = $PRODUCT_VERSION \
2022-02-25 18:56:20 -05:00
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 && \
2022-10-25 18:08:19 -04:00
apk add --no-cache git bash wget openssl gnupg xorriso && \
2022-02-25 18:56:20 -05:00
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' ; ; \
2022-08-17 20:45:26 -04:00
*) echo >& 2 " error: unsupported architecture: ${ apkArch } (see ${ HASHICORP_RELEASES } /packer/ ${ PRODUCT_VERSION } /) " && exit 1 ; ; \
2022-02-25 18:56:20 -05:00
esac && \
2022-08-17 20:45:26 -04:00
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 && \
2022-02-25 18:56:20 -05:00
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`.
# This image is published to DockerHub under the `light`, `light-$VERSION`, and `latest` tags.
FROM docker.mirror.hashicorp.services/alpine:latest as release-light
2022-08-17 20:45:26 -04:00
ARG PRODUCT_VERSION
2022-02-25 18:56:20 -05:00
ARG BIN_NAME
# TARGETARCH and TARGETOS are set automatically when --platform is provided.
ARG TARGETOS TARGETARCH
LABEL name = "Packer" \
maintainer = "HashiCorp Packer Team <packer@hashicorp.com>" \
vendor = "HashiCorp" \
2022-08-17 20:45:26 -04:00
version = $PRODUCT_VERSION \
release = $PRODUCT_VERSION \
2022-02-25 18:56:20 -05:00
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"
2022-10-25 18:08:19 -04:00
RUN apk add --no-cache git bash wget openssl gnupg xorriso
2022-02-25 18:56:20 -05:00
COPY dist/$TARGETOS /$TARGETARCH /$BIN_NAME /bin/
ENTRYPOINT [ "/bin/packer" ]
# Set default target to 'dev'.
2022-08-17 20:45:26 -04:00
FROM dev