diff --git a/.github/workflows/dev_builds.yml b/.github/workflows/dev_builds.yml index 53ceb1c..e8bc0cb 100644 --- a/.github/workflows/dev_builds.yml +++ b/.github/workflows/dev_builds.yml @@ -10,12 +10,22 @@ jobs: runs-on: ubuntu-20.04 steps: - uses: actions/checkout@v2 - - name: Build setup image - run: make build + + - name: Set up QEMU + uses: docker/setup-qemu-action@v1 + + - name: Set up Buildx + id: buildx + uses: docker/setup-buildx-action@v1 + + - name: Show Buildx platforms + run: echo ${{ steps.buildx.outputs.platforms }} + - name: Login to AWS public ECR run: make login env: AWS_ACCESS_KEY_ID: ${{ secrets.AWS_PUBLIC_ECR_ACCESS_KEY_ID }} AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_PUBLIC_ECR_SECRET_ACCESS_KEY }} - - name: Push setup image - run: make push + + - name: Build and push image + run: make build-push-multiplatform diff --git a/.github/workflows/release_builds.yml b/.github/workflows/release_builds.yml index ee5ccf9..1ecdc9a 100644 --- a/.github/workflows/release_builds.yml +++ b/.github/workflows/release_builds.yml @@ -13,17 +13,29 @@ jobs: runs-on: ubuntu-20.04 steps: - uses: actions/checkout@v2 + - name: Extract tag id: extract_tag run: echo "::set-output name=tag::$(echo ${GITHUB_REF#refs/tags/v})" + - name: Print tag run: echo "Running release build for ${{ steps.extract_tag.outputs.tag }}" - - name: Build kubernetes-setup - run: make build BUILD_TAG=${{ steps.extract_tag.outputs.tag }} + + - name: Set up QEMU + uses: docker/setup-qemu-action@v1 + + - name: Set up Buildx + id: buildx + uses: docker/setup-buildx-action@v1 + + - name: Show Buildx platforms + run: echo ${{ steps.buildx.outputs.platforms }} + - name: Login to AWS public ECR run: make login env: AWS_ACCESS_KEY_ID: ${{ secrets.AWS_PUBLIC_ECR_ACCESS_KEY_ID }} AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_PUBLIC_ECR_SECRET_ACCESS_KEY }} + - name: Push kubernetes-setup image - run: make push BUILD_TAG=${{ steps.extract_tag.outputs.tag }} + run: make build-push-multiplatform BUILD_TAG=${{ steps.extract_tag.outputs.tag }} diff --git a/Dockerfile b/Dockerfile index e231aa4..fa3b03d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,13 +1,18 @@ FROM alpine:3.13 ENV TERRAFORM_VERSION=0.13.6 +ARG TARGETPLATFORM RUN apk add --no-cache \ bash \ curl \ jq \ && apk upgrade \ - && curl -o terraform.zip https://releases.hashicorp.com/terraform/${TERRAFORM_VERSION}/terraform_${TERRAFORM_VERSION}_linux_amd64.zip \ + && if [ "${TARGETPLATFORM}" = "linux/amd64" ]; then TERRAFORM_PLATFORM="linux_amd64"; fi; \ + if [ "${TARGETPLATFORM}" = "linux/arm/v7" ]; then TERRAFORM_PLATFORM="linux_arm"; fi; \ + if [ "${TARGETPLATFORM}" = "linux/arm64" ]; then TERRAFORM_PLATFORM="linux_arm64"; fi; \ + if [ "${TERRAFORM_PLATFORM}" = "" ]; then TERRAFORM_PLATFORM="${TARGETPLATFORM}"; fi \ + && curl -o terraform.zip https://releases.hashicorp.com/terraform/${TERRAFORM_VERSION}/terraform_${TERRAFORM_VERSION}_${TERRAFORM_PLATFORM}.zip \ && unzip terraform.zip \ && mv terraform /usr/local/bin/ \ && rm terraform.zip \ diff --git a/Makefile b/Makefile index 68436f3..2afb0c1 100644 --- a/Makefile +++ b/Makefile @@ -18,3 +18,11 @@ push: login: aws ecr-public get-login-password --region us-east-1 \ | docker login --username AWS --password-stdin $(ECR_URL) + +build-push-multiplatform: + docker buildx build \ + --push \ + --platform linux/amd64,linux/arm/v7,linux/arm64 \ + --build-arg BUILD_TAG=$(BUILD_TAG) \ + --tag $(REPO_URL):$(BUILD_TAG) \ + . diff --git a/README.md b/README.md index 1f217b1..f8d6199 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,25 @@ # sumologic-kubernetes-setup Setup image for the [Sumologic Kubernetes Collection](https://github.com/SumoLogic/sumologic-kubernetes-collection) + +The images are pushed to [public.ecr.aws/sumologic/kubernetes-setup](https://gallery.ecr.aws/sumologic/kubernetes-setup). + +The images are built for the following architectures: + +- `linux/amd64` +- `linux/arm/v7` +- `linux/arm64/v8` + +## Build + +To build image only for the build host's architecture: + +```shell +make build +``` + +To build multi-platform image and push it to a registry: + +```shell +make build-push-multiplatform REPO_URL=my-repo/setup BUILD_TAG=custom-tag +```