Skip to content

Commit

Permalink
feat: support multi-arch docker build (linux/arm64 and linux/amd64) (#…
Browse files Browse the repository at this point in the history
…789)

Signed-off-by: Valentin Torikian <vtorikian@upgrade.com>
  • Loading branch information
vtorikianupgrade committed Mar 11, 2023
1 parent e6c5bac commit 496585f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
9 changes: 5 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -31,18 +31,19 @@ RUN bats acceptance.bats

## EXAMPLES STAGE ##
FROM base as examples
ENV TERRAFORM_VERSION=0.12.28 \
KUSTOMIZE_VERSION=2.0.3
ENV TERRAFORM_VERSION=0.12.31 \
KUSTOMIZE_VERSION=4.5.7

COPY --from=builder /app/conftest /usr/local/bin
COPY examples /examples

WORKDIR /tmp
RUN apk add --no-cache npm make git jq ca-certificates openssl unzip wget && \
wget "https://releases.hashicorp.com/terraform/${TERRAFORM_VERSION}/terraform_${TERRAFORM_VERSION}_linux_${TARGETARCH}.zip" && \
unzip "terraform_${TERRAFORM_VERSION}_linux_amd64.zip" -d /usr/local/bin
unzip "terraform_${TERRAFORM_VERSION}_linux_${TARGETARCH}.zip" -d /usr/local/bin

RUN wget -O /usr/local/bin/kustomize "https://github.com/kubernetes-sigs/kustomize/releases/download/v${KUSTOMIZE_VERSION}/kustomize_${KUSTOMIZE_VERSION}_linux_${TARGETARCH}" && \
RUN wget "https://github.com/kubernetes-sigs/kustomize/releases/download/kustomize%2Fv${KUSTOMIZE_VERSION}/kustomize_v${KUSTOMIZE_VERSION}_linux_${TARGETARCH}.tar.gz" && \
tar xvf kustomize_v${KUSTOMIZE_VERSION}_linux_${TARGETARCH}.tar.gz -C /usr/local/bin && \
chmod +x /usr/local/bin/kustomize

RUN go install cuelang.org/go/cmd/cue@latest
Expand Down
4 changes: 3 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ IMAGE := openpolicyagent/conftest

DOCKER := DOCKER_BUILDKIT=1 docker

DOCKER_PLATFORMS := linux/amd64,linux/arm64

GIT_VERSION := $(shell git describe --abbrev=4 --dirty --always --tags)

## All of the directories that contain tests to be executed
Expand Down Expand Up @@ -70,7 +72,7 @@ examples: ## Builds the examples Docker image.
.PHONY: push
push: ## Pushes the examples and Conftest image to DockerHub. Requires `TAG` parameter.
@test -n "$(TAG)" || (echo "TAG parameter not set." && exit 1)
@$(DOCKER) build . --build-arg VERSION="$(TAG)" -t $(IMAGE):$(TAG)
@$(DOCKER) build . --build-arg VERSION="$(TAG)" -t $(IMAGE):$(TAG) --platform $(DOCKER_PLATFORMS)
@$(DOCKER) build . --target examples -t $(IMAGE):examples
@$(DOCKER) tag $(IMAGE):$(TAG) $(IMAGE):latest
@$(DOCKER) push $(IMAGE):$(TAG)
Expand Down

0 comments on commit 496585f

Please sign in to comment.