From de676c0d4a158d8d6469e8f70aac2d5a2b33ae5a Mon Sep 17 00:00:00 2001 From: Peter Deme Date: Mon, 16 Jan 2023 09:57:13 +0100 Subject: [PATCH] Add ARM build (#13) --- .github/workflows/build.yml | 86 +++++++++ .github/workflows/deploy-preproduction.yml | 182 ++++++++++++------ .../workflows/deploy-production-latest.yml | 182 ++++++++++++------ .github/workflows/deploy-production.yml | 182 ++++++++++++------ base-alpine/Dockerfile | 15 +- base-debian/Dockerfile | 18 +- dotnet/Dockerfile | 9 +- golang/Dockerfile | 10 +- javascript/Dockerfile | 3 +- python/Dockerfile | 5 +- 10 files changed, 490 insertions(+), 202 deletions(-) create mode 100644 .github/workflows/build.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..a0ec228 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,86 @@ +name: Build + +on: + push: + branches-ignore: [main] + +concurrency: + group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} + cancel-in-progress: true + +env: + REPOSITORY_BASE_PATH: spaceliftbuild + +jobs: + build: + if: ${{ github.ref_type != 'tag' }} + name: 🚧 ${{ matrix.lang }} on ${{ matrix.arch }} + runs-on: ubuntu-latest + strategy: + fail-fast: false + max-parallel: 2 # ECR has pretty aggressive rate limiting 😪 + matrix: + arch: [amd64, arm64] + lang: [javascript, python, golang, dotnet] + + env: + BASE_IMAGE_NAME: ${{ (matrix.lang == 'javascript' || matrix.lang == 'golang') && 'runner-pulumi-base-alpine' || 'runner-pulumi-base-debian' }} + MAIN_IMAGE_FULL_NAME: runner-pulumi-${{ matrix.lang }}-${{ matrix.arch }}:${{ github.sha }} + + steps: + - name: Checkout + uses: actions/checkout@main + + - name: Get latest Pulumi version + id: latest_version + uses: tdemin/find-latest-tag@v1 + with: + repo: https://github.com/pulumi/pulumi.git + tag: 'v[0-9]+.[0-9]+\.[0-9]+' + + - name: Set up QEMU + uses: docker/setup-qemu-action@v2 + if: matrix.arch == 'arm64' + with: + platforms: linux/arm64 + + # Building doesn't work with buildx here because of + # a stupid behavior: + # https://github.com/moby/moby/issues/42893#issuecomment-1241274246 + # So we use plain docker commands. + + - name: Build base image (Alpine or Debian) + env: + CONTEXT: ${{ (matrix.lang == 'javascript' || matrix.lang == 'golang') && 'base-alpine' || 'base-debian' }} + run: | + docker build \ + --build-arg PULUMI_VERSION=${{ steps.latest_version.outputs.tag }} \ + --build-arg TARGETARCH=${{ matrix.arch }} \ + --platform linux/${{ matrix.arch }} \ + -t ${{ env.REPOSITORY_BASE_PATH }}/${{ env.BASE_IMAGE_NAME }}:${{ github.sha }} \ + $CONTEXT + + - name: Build main image + run: | + docker build \ + --build-arg REPOSITORY_BASE_PATH=${{ env.REPOSITORY_BASE_PATH }} \ + --build-arg RELEASE_VERSION=${{ github.sha }} \ + --platform linux/${{ matrix.arch }} \ + -t ${{ env.MAIN_IMAGE_FULL_NAME }} \ + ${{ matrix.lang }} + + - name: Pulumi binary sanity test + run: | + docker run --rm ${{ env.MAIN_IMAGE_FULL_NAME }} pulumi about + + - name: ${{ matrix.lang }} sanity test + run: | + if [ "${{ matrix.lang }}" == "javascript" ]; then + docker run --rm ${{ env.MAIN_IMAGE_FULL_NAME }} node --version + elif [ "${{ matrix.lang }}" == "python" ]; then + docker run --rm ${{ env.MAIN_IMAGE_FULL_NAME }} python --version + elif [ "${{ matrix.lang }}" == "golang" ]; then + docker run --rm ${{ env.MAIN_IMAGE_FULL_NAME }} go version + elif [ "${{ matrix.lang }}" == "dotnet" ]; then + docker run --rm ${{ env.MAIN_IMAGE_FULL_NAME }} dotnet --version + fi diff --git a/.github/workflows/deploy-preproduction.yml b/.github/workflows/deploy-preproduction.yml index 14bc8ea..e6c7cec 100644 --- a/.github/workflows/deploy-preproduction.yml +++ b/.github/workflows/deploy-preproduction.yml @@ -18,9 +18,19 @@ jobs: runs-on: ubuntu-latest steps: - name: Check out repository code - uses: actions/checkout@master + uses: actions/checkout@main + + - name: Set up QEMU + uses: docker/setup-qemu-action@v2 + with: + platforms: linux/arm64 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + - name: Set env run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV + - name: Set env run: echo "PULUMI_VERSION=${RELEASE_VERSION#dev-}" >> $GITHUB_ENV @@ -40,24 +50,33 @@ jobs: env: REPOSITORY_BASE_PATH: ${{ secrets.PREPROD_REPOSITORY_BASE_PATH }} - - name: Build the image - run: cd base-alpine && docker build --build-arg PULUMI_VERSION=${PULUMI_VERSION} --tag ${REPOSITORY_BASE_PATH}/runner-pulumi-base-alpine:${RELEASE_VERSION} . - env: - REPOSITORY_BASE_PATH: ${{ secrets.PREPROD_REPOSITORY_BASE_PATH }} - - - name: Push the image to ECR - run: docker push ${REPOSITORY_BASE_PATH}/runner-pulumi-base-alpine:${RELEASE_VERSION} - env: - REPOSITORY_BASE_PATH: ${{ secrets.PREPROD_REPOSITORY_BASE_PATH }} + - name: Build and push the image + uses: docker/build-push-action@v3 + with: + push: true + platforms: linux/amd64,linux/arm64 + context: base-alpine + build-args: PULUMI_VERSION=${{ env.PULUMI_VERSION }} + tags: ${{ secrets.PREPROD_REPOSITORY_BASE_PATH }}/runner-pulumi-base-alpine:${{ env.RELEASE_VERSION }} base-debian: name: Build and deploy the base Debian image runs-on: ubuntu-latest steps: - name: Check out repository code - uses: actions/checkout@master + uses: actions/checkout@main + + - name: Set up QEMU + uses: docker/setup-qemu-action@v2 + with: + platforms: linux/arm64 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + - name: Set env run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV + - name: Set env run: echo "PULUMI_VERSION=${RELEASE_VERSION#dev-}" >> $GITHUB_ENV @@ -77,15 +96,14 @@ jobs: env: REPOSITORY_BASE_PATH: ${{ secrets.PREPROD_REPOSITORY_BASE_PATH }} - - name: Build the image - run: cd base-debian && docker build --build-arg PULUMI_VERSION=${PULUMI_VERSION} --tag ${REPOSITORY_BASE_PATH}/runner-pulumi-base-debian:${RELEASE_VERSION} . - env: - REPOSITORY_BASE_PATH: ${{ secrets.PREPROD_REPOSITORY_BASE_PATH }} - - - name: Push the image to ECR - run: docker push ${REPOSITORY_BASE_PATH}/runner-pulumi-base-debian:${RELEASE_VERSION} - env: - REPOSITORY_BASE_PATH: ${{ secrets.PREPROD_REPOSITORY_BASE_PATH }} + - name: Build and push the image + uses: docker/build-push-action@v3 + with: + push: true + platforms: linux/amd64,linux/arm64 + context: base-debian + build-args: PULUMI_VERSION=${{ env.PULUMI_VERSION }} + tags: ${{ secrets.PREPROD_REPOSITORY_BASE_PATH }}/runner-pulumi-base-debian:${{ env.RELEASE_VERSION }} javascript: needs: @@ -94,9 +112,19 @@ jobs: runs-on: ubuntu-latest steps: - name: Check out repository code - uses: actions/checkout@master + uses: actions/checkout@main + + - name: Set up QEMU + uses: docker/setup-qemu-action@v2 + with: + platforms: linux/arm64 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + - name: Set env run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV + - name: Set env run: echo "PULUMI_VERSION=${RELEASE_VERSION#dev-}" >> $GITHUB_ENV @@ -116,15 +144,16 @@ jobs: env: REPOSITORY_BASE_PATH: ${{ secrets.PREPROD_REPOSITORY_BASE_PATH }} - - name: Build the image - run: cd javascript && docker build --build-arg REPOSITORY_BASE_PATH=${REPOSITORY_BASE_PATH} --build-arg RELEASE_VERSION=${RELEASE_VERSION} --tag ${REPOSITORY_BASE_PATH}/runner-pulumi-javascript:${RELEASE_VERSION} . - env: - REPOSITORY_BASE_PATH: ${{ secrets.PREPROD_REPOSITORY_BASE_PATH }} - - - name: Push the image to ECR - run: docker push ${REPOSITORY_BASE_PATH}/runner-pulumi-javascript:${RELEASE_VERSION} - env: - REPOSITORY_BASE_PATH: ${{ secrets.PREPROD_REPOSITORY_BASE_PATH }} + - name: Build and push the image + uses: docker/build-push-action@v3 + with: + push: true + platforms: linux/amd64,linux/arm64 + context: javascript + build-args: | + REPOSITORY_BASE_PATH=${{ secrets.PREPROD_REPOSITORY_BASE_PATH }} + RELEASE_VERSION=${{ env.RELEASE_VERSION }} + tags: ${{ secrets.PREPROD_REPOSITORY_BASE_PATH }}/runner-pulumi-javascript:${{ env.RELEASE_VERSION }} golang: needs: @@ -133,9 +162,19 @@ jobs: runs-on: ubuntu-latest steps: - name: Check out repository code - uses: actions/checkout@master + uses: actions/checkout@main + + - name: Set up QEMU + uses: docker/setup-qemu-action@v2 + with: + platforms: linux/arm64 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + - name: Set env run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV + - name: Set env run: echo "PULUMI_VERSION=${RELEASE_VERSION#dev-}" >> $GITHUB_ENV @@ -155,15 +194,16 @@ jobs: env: REPOSITORY_BASE_PATH: ${{ secrets.PREPROD_REPOSITORY_BASE_PATH }} - - name: Build the image - run: cd golang && docker build --build-arg REPOSITORY_BASE_PATH=${REPOSITORY_BASE_PATH} --build-arg RELEASE_VERSION=${RELEASE_VERSION} --tag ${REPOSITORY_BASE_PATH}/runner-pulumi-golang:${RELEASE_VERSION} . - env: - REPOSITORY_BASE_PATH: ${{ secrets.PREPROD_REPOSITORY_BASE_PATH }} - - - name: Push the image to ECR - run: docker push ${REPOSITORY_BASE_PATH}/runner-pulumi-golang:${RELEASE_VERSION} - env: - REPOSITORY_BASE_PATH: ${{ secrets.PREPROD_REPOSITORY_BASE_PATH }} + - name: Build and push the image + uses: docker/build-push-action@v3 + with: + push: true + platforms: linux/amd64,linux/arm64 + context: golang + build-args: | + REPOSITORY_BASE_PATH=${{ secrets.PREPROD_REPOSITORY_BASE_PATH }} + RELEASE_VERSION=${{ env.RELEASE_VERSION }} + tags: ${{ secrets.PREPROD_REPOSITORY_BASE_PATH }}/runner-pulumi-golang:${{ env.RELEASE_VERSION }} python: needs: @@ -172,9 +212,19 @@ jobs: runs-on: ubuntu-latest steps: - name: Check out repository code - uses: actions/checkout@master + uses: actions/checkout@main + + - name: Set up QEMU + uses: docker/setup-qemu-action@v2 + with: + platforms: linux/arm64 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + - name: Set env run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV + - name: Set env run: echo "PULUMI_VERSION=${RELEASE_VERSION#dev-}" >> $GITHUB_ENV @@ -194,15 +244,16 @@ jobs: env: REPOSITORY_BASE_PATH: ${{ secrets.PREPROD_REPOSITORY_BASE_PATH }} - - name: Build the image - run: cd python && docker build --build-arg REPOSITORY_BASE_PATH=${REPOSITORY_BASE_PATH} --build-arg RELEASE_VERSION=${RELEASE_VERSION} --tag ${REPOSITORY_BASE_PATH}/runner-pulumi-python:${RELEASE_VERSION} . - env: - REPOSITORY_BASE_PATH: ${{ secrets.PREPROD_REPOSITORY_BASE_PATH }} - - - name: Push the image to ECR - run: docker push ${REPOSITORY_BASE_PATH}/runner-pulumi-python:${RELEASE_VERSION} - env: - REPOSITORY_BASE_PATH: ${{ secrets.PREPROD_REPOSITORY_BASE_PATH }} + - name: Build and push the image + uses: docker/build-push-action@v3 + with: + push: true + platforms: linux/amd64,linux/arm64 + context: python + build-args: | + REPOSITORY_BASE_PATH=${{ secrets.PREPROD_REPOSITORY_BASE_PATH }} + RELEASE_VERSION=${{ env.RELEASE_VERSION }} + tags: ${{ secrets.PREPROD_REPOSITORY_BASE_PATH }}/runner-pulumi-python:${{ env.RELEASE_VERSION }} dotnet: needs: @@ -211,9 +262,19 @@ jobs: runs-on: ubuntu-latest steps: - name: Check out repository code - uses: actions/checkout@master + uses: actions/checkout@main + + - name: Set up QEMU + uses: docker/setup-qemu-action@v2 + with: + platforms: linux/arm64 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + - name: Set env run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV + - name: Set env run: echo "PULUMI_VERSION=${RELEASE_VERSION#dev-}" >> $GITHUB_ENV @@ -233,12 +294,13 @@ jobs: env: REPOSITORY_BASE_PATH: ${{ secrets.PREPROD_REPOSITORY_BASE_PATH }} - - name: Build the image - run: cd dotnet && docker build --build-arg REPOSITORY_BASE_PATH=${REPOSITORY_BASE_PATH} --build-arg RELEASE_VERSION=${RELEASE_VERSION} --tag ${REPOSITORY_BASE_PATH}/runner-pulumi-dotnet:${RELEASE_VERSION} . - env: - REPOSITORY_BASE_PATH: ${{ secrets.PREPROD_REPOSITORY_BASE_PATH }} - - - name: Push the image to ECR - run: docker push ${REPOSITORY_BASE_PATH}/runner-pulumi-dotnet:${RELEASE_VERSION} - env: - REPOSITORY_BASE_PATH: ${{ secrets.PREPROD_REPOSITORY_BASE_PATH }} + - name: Build and push the image + uses: docker/build-push-action@v3 + with: + push: true + platforms: linux/amd64,linux/arm64 + context: dotnet + build-args: | + REPOSITORY_BASE_PATH=${{ secrets.PREPROD_REPOSITORY_BASE_PATH }} + RELEASE_VERSION=${{ env.RELEASE_VERSION }} + tags: ${{ secrets.PREPROD_REPOSITORY_BASE_PATH }}/runner-pulumi-dotnet:${{ env.RELEASE_VERSION }} diff --git a/.github/workflows/deploy-production-latest.yml b/.github/workflows/deploy-production-latest.yml index 9a7b313..95c59c8 100644 --- a/.github/workflows/deploy-production-latest.yml +++ b/.github/workflows/deploy-production-latest.yml @@ -18,9 +18,19 @@ jobs: runs-on: ubuntu-latest steps: - name: Check out repository code - uses: actions/checkout@master + uses: actions/checkout@main + + - name: Set up QEMU + uses: docker/setup-qemu-action@v2 + with: + platforms: linux/arm64 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + - name: Set env run: echo "RELEASE_VERSION=latest" >> $GITHUB_ENV + - name: Set env run: echo "PULUMI_VERSION=${GITHUB_REF#refs/*/latest-}" >> $GITHUB_ENV @@ -40,24 +50,33 @@ jobs: env: REPOSITORY_BASE_PATH: ${{ secrets.REPOSITORY_BASE_PATH }} - - name: Build the image - run: cd base-alpine && docker build --build-arg PULUMI_VERSION=${PULUMI_VERSION} --tag ${REPOSITORY_BASE_PATH}/runner-pulumi-base-alpine:${RELEASE_VERSION} . - env: - REPOSITORY_BASE_PATH: ${{ secrets.REPOSITORY_BASE_PATH }} - - - name: Push the image to ECR - run: docker push ${REPOSITORY_BASE_PATH}/runner-pulumi-base-alpine:${RELEASE_VERSION} - env: - REPOSITORY_BASE_PATH: ${{ secrets.REPOSITORY_BASE_PATH }} + - name: Build and push the image + uses: docker/build-push-action@v3 + with: + push: true + platforms: linux/amd64,linux/arm64 + context: base-alpine + build-args: PULUMI_VERSION=${{ env.PULUMI_VERSION }} + tags: ${{ secrets.REPOSITORY_BASE_PATH }}/runner-pulumi-base-alpine:${{ env.RELEASE_VERSION }} base-debian: name: Build and deploy the base Debian image runs-on: ubuntu-latest steps: - name: Check out repository code - uses: actions/checkout@master + uses: actions/checkout@main + + - name: Set up QEMU + uses: docker/setup-qemu-action@v2 + with: + platforms: linux/arm64 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + - name: Set env run: echo "RELEASE_VERSION=latest" >> $GITHUB_ENV + - name: Set env run: echo "PULUMI_VERSION=${GITHUB_REF#refs/*/latest-}" >> $GITHUB_ENV @@ -77,15 +96,14 @@ jobs: env: REPOSITORY_BASE_PATH: ${{ secrets.REPOSITORY_BASE_PATH }} - - name: Build the image - run: cd base-debian && docker build --build-arg PULUMI_VERSION=${PULUMI_VERSION} --tag ${REPOSITORY_BASE_PATH}/runner-pulumi-base-debian:${RELEASE_VERSION} . - env: - REPOSITORY_BASE_PATH: ${{ secrets.REPOSITORY_BASE_PATH }} - - - name: Push the image to ECR - run: docker push ${REPOSITORY_BASE_PATH}/runner-pulumi-base-debian:${RELEASE_VERSION} - env: - REPOSITORY_BASE_PATH: ${{ secrets.REPOSITORY_BASE_PATH }} + - name: Build and push the image + uses: docker/build-push-action@v3 + with: + push: true + platforms: linux/amd64,linux/arm64 + context: base-debian + build-args: PULUMI_VERSION=${{ env.PULUMI_VERSION }} + tags: ${{ secrets.REPOSITORY_BASE_PATH }}/runner-pulumi-base-debian:${{ env.RELEASE_VERSION }} javascript: needs: @@ -94,9 +112,19 @@ jobs: runs-on: ubuntu-latest steps: - name: Check out repository code - uses: actions/checkout@master + uses: actions/checkout@main + + - name: Set up QEMU + uses: docker/setup-qemu-action@v2 + with: + platforms: linux/arm64 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + - name: Set env run: echo "RELEASE_VERSION=latest" >> $GITHUB_ENV + - name: Set env run: echo "PULUMI_VERSION=${GITHUB_REF#refs/*/latest-}" >> $GITHUB_ENV @@ -116,15 +144,16 @@ jobs: env: REPOSITORY_BASE_PATH: ${{ secrets.REPOSITORY_BASE_PATH }} - - name: Build the image - run: cd javascript && docker build --build-arg REPOSITORY_BASE_PATH=${REPOSITORY_BASE_PATH} --build-arg RELEASE_VERSION=${RELEASE_VERSION} --tag ${REPOSITORY_BASE_PATH}/runner-pulumi-javascript:${RELEASE_VERSION} . - env: - REPOSITORY_BASE_PATH: ${{ secrets.REPOSITORY_BASE_PATH }} - - - name: Push the image to ECR - run: docker push ${REPOSITORY_BASE_PATH}/runner-pulumi-javascript:${RELEASE_VERSION} - env: - REPOSITORY_BASE_PATH: ${{ secrets.REPOSITORY_BASE_PATH }} + - name: Build and push the image + uses: docker/build-push-action@v3 + with: + push: true + platforms: linux/amd64,linux/arm64 + context: javascript + build-args: | + REPOSITORY_BASE_PATH=${{ secrets.REPOSITORY_BASE_PATH }} + RELEASE_VERSION=${{ env.RELEASE_VERSION }} + tags: ${{ secrets.REPOSITORY_BASE_PATH }}/runner-pulumi-javascript:${{ env.RELEASE_VERSION }} golang: needs: @@ -133,9 +162,19 @@ jobs: runs-on: ubuntu-latest steps: - name: Check out repository code - uses: actions/checkout@master + uses: actions/checkout@main + + - name: Set up QEMU + uses: docker/setup-qemu-action@v2 + with: + platforms: linux/arm64 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + - name: Set env run: echo "RELEASE_VERSION=latest" >> $GITHUB_ENV + - name: Set env run: echo "PULUMI_VERSION=${GITHUB_REF#refs/*/latest-}" >> $GITHUB_ENV @@ -155,15 +194,16 @@ jobs: env: REPOSITORY_BASE_PATH: ${{ secrets.REPOSITORY_BASE_PATH }} - - name: Build the image - run: cd golang && docker build --build-arg REPOSITORY_BASE_PATH=${REPOSITORY_BASE_PATH} --build-arg RELEASE_VERSION=${RELEASE_VERSION} --tag ${REPOSITORY_BASE_PATH}/runner-pulumi-golang:${RELEASE_VERSION} . - env: - REPOSITORY_BASE_PATH: ${{ secrets.REPOSITORY_BASE_PATH }} - - - name: Push the image to ECR - run: docker push ${REPOSITORY_BASE_PATH}/runner-pulumi-golang:${RELEASE_VERSION} - env: - REPOSITORY_BASE_PATH: ${{ secrets.REPOSITORY_BASE_PATH }} + - name: Build and push the image + uses: docker/build-push-action@v3 + with: + push: true + platforms: linux/amd64,linux/arm64 + context: golang + build-args: | + REPOSITORY_BASE_PATH=${{ secrets.REPOSITORY_BASE_PATH }} + RELEASE_VERSION=${{ env.RELEASE_VERSION }} + tags: ${{ secrets.REPOSITORY_BASE_PATH }}/runner-pulumi-golang:${{ env.RELEASE_VERSION }} python: needs: @@ -172,9 +212,19 @@ jobs: runs-on: ubuntu-latest steps: - name: Check out repository code - uses: actions/checkout@master + uses: actions/checkout@main + + - name: Set up QEMU + uses: docker/setup-qemu-action@v2 + with: + platforms: linux/arm64 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + - name: Set env run: echo "RELEASE_VERSION=latest" >> $GITHUB_ENV + - name: Set env run: echo "PULUMI_VERSION=${GITHUB_REF#refs/*/latest-}" >> $GITHUB_ENV @@ -194,15 +244,16 @@ jobs: env: REPOSITORY_BASE_PATH: ${{ secrets.REPOSITORY_BASE_PATH }} - - name: Build the image - run: cd python && docker build --build-arg REPOSITORY_BASE_PATH=${REPOSITORY_BASE_PATH} --build-arg RELEASE_VERSION=${RELEASE_VERSION} --tag ${REPOSITORY_BASE_PATH}/runner-pulumi-python:${RELEASE_VERSION} . - env: - REPOSITORY_BASE_PATH: ${{ secrets.REPOSITORY_BASE_PATH }} - - - name: Push the image to ECR - run: docker push ${REPOSITORY_BASE_PATH}/runner-pulumi-python:${RELEASE_VERSION} - env: - REPOSITORY_BASE_PATH: ${{ secrets.REPOSITORY_BASE_PATH }} + - name: Build and push the image + uses: docker/build-push-action@v3 + with: + push: true + platforms: linux/amd64,linux/arm64 + context: python + build-args: | + REPOSITORY_BASE_PATH=${{ secrets.REPOSITORY_BASE_PATH }} + RELEASE_VERSION=${{ env.RELEASE_VERSION }} + tags: ${{ secrets.REPOSITORY_BASE_PATH }}/runner-pulumi-python:${{ env.RELEASE_VERSION }} dotnet: needs: @@ -211,9 +262,19 @@ jobs: runs-on: ubuntu-latest steps: - name: Check out repository code - uses: actions/checkout@master + uses: actions/checkout@main + + - name: Set up QEMU + uses: docker/setup-qemu-action@v2 + with: + platforms: linux/arm64 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + - name: Set env run: echo "RELEASE_VERSION=latest" >> $GITHUB_ENV + - name: Set env run: echo "PULUMI_VERSION=${GITHUB_REF#refs/*/latest-}" >> $GITHUB_ENV @@ -233,12 +294,13 @@ jobs: env: REPOSITORY_BASE_PATH: ${{ secrets.REPOSITORY_BASE_PATH }} - - name: Build the image - run: cd dotnet && docker build --build-arg REPOSITORY_BASE_PATH=${REPOSITORY_BASE_PATH} --build-arg RELEASE_VERSION=${RELEASE_VERSION} --tag ${REPOSITORY_BASE_PATH}/runner-pulumi-dotnet:${RELEASE_VERSION} . - env: - REPOSITORY_BASE_PATH: ${{ secrets.REPOSITORY_BASE_PATH }} - - - name: Push the image to ECR - run: docker push ${REPOSITORY_BASE_PATH}/runner-pulumi-dotnet:${RELEASE_VERSION} - env: - REPOSITORY_BASE_PATH: ${{ secrets.REPOSITORY_BASE_PATH }} + - name: Build and push the image + uses: docker/build-push-action@v3 + with: + push: true + platforms: linux/amd64,linux/arm64 + context: dotnet + build-args: | + REPOSITORY_BASE_PATH=${{ secrets.REPOSITORY_BASE_PATH }} + RELEASE_VERSION=${{ env.RELEASE_VERSION }} + tags: ${{ secrets.REPOSITORY_BASE_PATH }}/runner-pulumi-dotnet:${{ env.RELEASE_VERSION }} diff --git a/.github/workflows/deploy-production.yml b/.github/workflows/deploy-production.yml index bfd0785..2ff54e5 100644 --- a/.github/workflows/deploy-production.yml +++ b/.github/workflows/deploy-production.yml @@ -18,9 +18,19 @@ jobs: runs-on: ubuntu-latest steps: - name: Check out repository code - uses: actions/checkout@master + uses: actions/checkout@main + + - name: Set up QEMU + uses: docker/setup-qemu-action@v2 + with: + platforms: linux/arm64 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + - name: Set env run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV + - name: Set env run: echo "PULUMI_VERSION=${RELEASE_VERSION}" >> $GITHUB_ENV @@ -40,24 +50,33 @@ jobs: env: REPOSITORY_BASE_PATH: ${{ secrets.REPOSITORY_BASE_PATH }} - - name: Build the image - run: cd base-alpine && docker build --build-arg PULUMI_VERSION=${PULUMI_VERSION} --tag ${REPOSITORY_BASE_PATH}/runner-pulumi-base-alpine:${RELEASE_VERSION} . - env: - REPOSITORY_BASE_PATH: ${{ secrets.REPOSITORY_BASE_PATH }} - - - name: Push the image to ECR - run: docker push ${REPOSITORY_BASE_PATH}/runner-pulumi-base-alpine:${RELEASE_VERSION} - env: - REPOSITORY_BASE_PATH: ${{ secrets.REPOSITORY_BASE_PATH }} + - name: Build and push the image + uses: docker/build-push-action@v3 + with: + push: true + platforms: linux/amd64,linux/arm64 + context: base-alpine + build-args: PULUMI_VERSION=${{ env.PULUMI_VERSION }} + tags: ${{ secrets.REPOSITORY_BASE_PATH }}/runner-pulumi-base-alpine:${{ env.RELEASE_VERSION }} base-debian: name: Build and deploy the base Debian image runs-on: ubuntu-latest steps: - name: Check out repository code - uses: actions/checkout@master + uses: actions/checkout@main + + - name: Set up QEMU + uses: docker/setup-qemu-action@v2 + with: + platforms: linux/arm64 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + - name: Set env run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV + - name: Set env run: echo "PULUMI_VERSION=${RELEASE_VERSION}" >> $GITHUB_ENV @@ -77,15 +96,14 @@ jobs: env: REPOSITORY_BASE_PATH: ${{ secrets.REPOSITORY_BASE_PATH }} - - name: Build the image - run: cd base-debian && docker build --build-arg PULUMI_VERSION=${PULUMI_VERSION} --tag ${REPOSITORY_BASE_PATH}/runner-pulumi-base-debian:${RELEASE_VERSION} . - env: - REPOSITORY_BASE_PATH: ${{ secrets.REPOSITORY_BASE_PATH }} - - - name: Push the image to ECR - run: docker push ${REPOSITORY_BASE_PATH}/runner-pulumi-base-debian:${RELEASE_VERSION} - env: - REPOSITORY_BASE_PATH: ${{ secrets.REPOSITORY_BASE_PATH }} + - name: Build and push the image + uses: docker/build-push-action@v3 + with: + push: true + platforms: linux/amd64,linux/arm64 + context: base-debian + build-args: PULUMI_VERSION=${{ env.PULUMI_VERSION }} + tags: ${{ secrets.REPOSITORY_BASE_PATH }}/runner-pulumi-base-debian:${{ env.RELEASE_VERSION }} javascript: needs: @@ -94,9 +112,19 @@ jobs: runs-on: ubuntu-latest steps: - name: Check out repository code - uses: actions/checkout@master + uses: actions/checkout@main + + - name: Set up QEMU + uses: docker/setup-qemu-action@v2 + with: + platforms: linux/arm64 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + - name: Set env run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV + - name: Set env run: echo "PULUMI_VERSION=${RELEASE_VERSION}" >> $GITHUB_ENV @@ -116,15 +144,16 @@ jobs: env: REPOSITORY_BASE_PATH: ${{ secrets.REPOSITORY_BASE_PATH }} - - name: Build the image - run: cd javascript && docker build --build-arg REPOSITORY_BASE_PATH=${REPOSITORY_BASE_PATH} --build-arg RELEASE_VERSION=${RELEASE_VERSION} --tag ${REPOSITORY_BASE_PATH}/runner-pulumi-javascript:${RELEASE_VERSION} . - env: - REPOSITORY_BASE_PATH: ${{ secrets.REPOSITORY_BASE_PATH }} - - - name: Push the image to ECR - run: docker push ${REPOSITORY_BASE_PATH}/runner-pulumi-javascript:${RELEASE_VERSION} - env: - REPOSITORY_BASE_PATH: ${{ secrets.REPOSITORY_BASE_PATH }} + - name: Build and push the image + uses: docker/build-push-action@v3 + with: + push: true + platforms: linux/amd64,linux/arm64 + context: javascript + build-args: | + REPOSITORY_BASE_PATH=${{ secrets.REPOSITORY_BASE_PATH }} + RELEASE_VERSION=${{ env.RELEASE_VERSION }} + tags: ${{ secrets.REPOSITORY_BASE_PATH }}/runner-pulumi-javascript:${{ env.RELEASE_VERSION }} golang: needs: @@ -133,9 +162,19 @@ jobs: runs-on: ubuntu-latest steps: - name: Check out repository code - uses: actions/checkout@master + uses: actions/checkout@main + + - name: Set up QEMU + uses: docker/setup-qemu-action@v2 + with: + platforms: linux/arm64 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + - name: Set env run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV + - name: Set env run: echo "PULUMI_VERSION=${RELEASE_VERSION}" >> $GITHUB_ENV @@ -155,15 +194,16 @@ jobs: env: REPOSITORY_BASE_PATH: ${{ secrets.REPOSITORY_BASE_PATH }} - - name: Build the image - run: cd golang && docker build --build-arg REPOSITORY_BASE_PATH=${REPOSITORY_BASE_PATH} --build-arg RELEASE_VERSION=${RELEASE_VERSION} --tag ${REPOSITORY_BASE_PATH}/runner-pulumi-golang:${RELEASE_VERSION} . - env: - REPOSITORY_BASE_PATH: ${{ secrets.REPOSITORY_BASE_PATH }} - - - name: Push the image to ECR - run: docker push ${REPOSITORY_BASE_PATH}/runner-pulumi-golang:${RELEASE_VERSION} - env: - REPOSITORY_BASE_PATH: ${{ secrets.REPOSITORY_BASE_PATH }} + - name: Build and push the image + uses: docker/build-push-action@v3 + with: + push: true + platforms: linux/amd64,linux/arm64 + context: golang + build-args: | + REPOSITORY_BASE_PATH=${{ secrets.REPOSITORY_BASE_PATH }} + RELEASE_VERSION=${{ env.RELEASE_VERSION }} + tags: ${{ secrets.REPOSITORY_BASE_PATH }}/runner-pulumi-golang:${{ env.RELEASE_VERSION }} python: needs: @@ -172,9 +212,19 @@ jobs: runs-on: ubuntu-latest steps: - name: Check out repository code - uses: actions/checkout@master + uses: actions/checkout@main + + - name: Set up QEMU + uses: docker/setup-qemu-action@v2 + with: + platforms: linux/arm64 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + - name: Set env run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV + - name: Set env run: echo "PULUMI_VERSION=${RELEASE_VERSION}" >> $GITHUB_ENV @@ -194,15 +244,16 @@ jobs: env: REPOSITORY_BASE_PATH: ${{ secrets.REPOSITORY_BASE_PATH }} - - name: Build the image - run: cd python && docker build --build-arg REPOSITORY_BASE_PATH=${REPOSITORY_BASE_PATH} --build-arg RELEASE_VERSION=${RELEASE_VERSION} --tag ${REPOSITORY_BASE_PATH}/runner-pulumi-python:${RELEASE_VERSION} . - env: - REPOSITORY_BASE_PATH: ${{ secrets.REPOSITORY_BASE_PATH }} - - - name: Push the image to ECR - run: docker push ${REPOSITORY_BASE_PATH}/runner-pulumi-python:${RELEASE_VERSION} - env: - REPOSITORY_BASE_PATH: ${{ secrets.REPOSITORY_BASE_PATH }} + - name: Build and push the image + uses: docker/build-push-action@v3 + with: + push: true + platforms: linux/amd64,linux/arm64 + context: python + build-args: | + REPOSITORY_BASE_PATH=${{ secrets.REPOSITORY_BASE_PATH }} + RELEASE_VERSION=${{ env.RELEASE_VERSION }} + tags: ${{ secrets.REPOSITORY_BASE_PATH }}/runner-pulumi-python:${{ env.RELEASE_VERSION }} dotnet: needs: @@ -211,9 +262,19 @@ jobs: runs-on: ubuntu-latest steps: - name: Check out repository code - uses: actions/checkout@master + uses: actions/checkout@main + + - name: Set up QEMU + uses: docker/setup-qemu-action@v2 + with: + platforms: linux/arm64 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + - name: Set env run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV + - name: Set env run: echo "PULUMI_VERSION=${RELEASE_VERSION}" >> $GITHUB_ENV @@ -233,12 +294,13 @@ jobs: env: REPOSITORY_BASE_PATH: ${{ secrets.REPOSITORY_BASE_PATH }} - - name: Build the image - run: cd dotnet && docker build --build-arg REPOSITORY_BASE_PATH=${REPOSITORY_BASE_PATH} --build-arg RELEASE_VERSION=${RELEASE_VERSION} --tag ${REPOSITORY_BASE_PATH}/runner-pulumi-dotnet:${RELEASE_VERSION} . - env: - REPOSITORY_BASE_PATH: ${{ secrets.REPOSITORY_BASE_PATH }} - - - name: Push the image to ECR - run: docker push ${REPOSITORY_BASE_PATH}/runner-pulumi-dotnet:${RELEASE_VERSION} - env: - REPOSITORY_BASE_PATH: ${{ secrets.REPOSITORY_BASE_PATH }} + - name: Build and push the image + uses: docker/build-push-action@v3 + with: + push: true + platforms: linux/amd64,linux/arm64 + context: dotnet + build-args: | + REPOSITORY_BASE_PATH=${{ secrets.REPOSITORY_BASE_PATH }} + RELEASE_VERSION=${{ env.RELEASE_VERSION }} + tags: ${{ secrets.REPOSITORY_BASE_PATH }}/runner-pulumi-dotnet:${{ env.RELEASE_VERSION }} diff --git a/base-alpine/Dockerfile b/base-alpine/Dockerfile index b3ccea8..c1682e8 100644 --- a/base-alpine/Dockerfile +++ b/base-alpine/Dockerfile @@ -1,9 +1,18 @@ FROM public.ecr.aws/spacelift/runner-terraform ARG PULUMI_VERSION +ARG TARGETARCH USER root WORKDIR /home/spacelift -RUN wget "https://get.pulumi.com/releases/sdk/pulumi-${PULUMI_VERSION}-linux-x64.tar.gz" -RUN tar -xf pulumi-${PULUMI_VERSION}-linux-x64.tar.gz -RUN mv pulumi/* /usr/local/bin/ + +RUN if [ "$TARGETARCH" = "arm64" ]; then \ + wget -q "https://get.pulumi.com/releases/sdk/pulumi-${PULUMI_VERSION}-linux-arm64.tar.gz" && \ + tar -xf pulumi-${PULUMI_VERSION}-linux-arm64.tar.gz; \ + else \ + wget -q "https://get.pulumi.com/releases/sdk/pulumi-${PULUMI_VERSION}-linux-x64.tar.gz" && \ + tar -xf pulumi-${PULUMI_VERSION}-linux-x64.tar.gz; \ + fi; \ + mv pulumi/* /usr/local/bin/; \ + rm -rf pulumi-${PULUMI_VERSION}*.tar.gz + USER spacelift diff --git a/base-debian/Dockerfile b/base-debian/Dockerfile index 722e95c..5f96b65 100644 --- a/base-debian/Dockerfile +++ b/base-debian/Dockerfile @@ -1,14 +1,22 @@ FROM debian:latest ARG PULUMI_VERSION +ARG TARGETARCH RUN echo "hosts: files dns" > /etc/nsswitch.conf \ && adduser --disabled-password --uid=1983 spacelift USER root WORKDIR /home/spacelift -RUN apt-get update -RUN apt-get install -y wget procps -RUN wget "https://get.pulumi.com/releases/sdk/pulumi-${PULUMI_VERSION}-linux-x64.tar.gz" -RUN tar -xf pulumi-${PULUMI_VERSION}-linux-x64.tar.gz -RUN mv pulumi/* /usr/local/bin/ +RUN apt-get update && apt-get install -y wget procps + +RUN if [ "$TARGETARCH" = "arm64" ]; then \ + wget -q "https://get.pulumi.com/releases/sdk/pulumi-${PULUMI_VERSION}-linux-arm64.tar.gz" && \ + tar -xf pulumi-${PULUMI_VERSION}-linux-arm64.tar.gz; \ + else \ + wget -q "https://get.pulumi.com/releases/sdk/pulumi-${PULUMI_VERSION}-linux-x64.tar.gz" && \ + tar -xf pulumi-${PULUMI_VERSION}-linux-x64.tar.gz; \ + fi; \ + mv pulumi/* /usr/local/bin/; \ + rm -rf pulumi-${PULUMI_VERSION}*.tar.gz + USER spacelift diff --git a/dotnet/Dockerfile b/dotnet/Dockerfile index 69412ba..a9e4821 100644 --- a/dotnet/Dockerfile +++ b/dotnet/Dockerfile @@ -1,14 +1,15 @@ -ARG RELEASE_VERSION ARG REPOSITORY_BASE_PATH - +ARG RELEASE_VERSION FROM ${REPOSITORY_BASE_PATH}/runner-pulumi-base-debian:${RELEASE_VERSION} USER root RUN apt-get install -y icu-devtools USER spacelift -RUN wget https://dot.net/v1/dotnet-install.sh + +RUN wget -q https://dot.net/v1/dotnet-install.sh RUN chmod 777 dotnet-install.sh -RUN ./dotnet-install.sh -c Current +RUN ./dotnet-install.sh -c STS + SHELL ["/bin/sh", "-c"] ENV DOTNET_ROOT="/home/spacelift/.dotnet" ENV PATH="$PATH:/home/spacelift/.dotnet" diff --git a/golang/Dockerfile b/golang/Dockerfile index baf2bd7..a692078 100644 --- a/golang/Dockerfile +++ b/golang/Dockerfile @@ -1,11 +1,11 @@ -ARG RELEASE_VERSION ARG REPOSITORY_BASE_PATH - -FROM golang:1.19-alpine3.16 as golang-source - +ARG RELEASE_VERSION FROM ${REPOSITORY_BASE_PATH}/runner-pulumi-base-alpine:${RELEASE_VERSION} + USER root WORKDIR /home/spacelift -COPY --from=golang-source /usr/local/go /usr/local/go + +COPY --from=golang:1.19-alpine /usr/local/go/ /usr/local/go/ ENV PATH=${PATH}:/usr/local/go/bin + USER spacelift diff --git a/javascript/Dockerfile b/javascript/Dockerfile index f3acea4..c408974 100644 --- a/javascript/Dockerfile +++ b/javascript/Dockerfile @@ -1,6 +1,5 @@ -ARG RELEASE_VERSION ARG REPOSITORY_BASE_PATH - +ARG RELEASE_VERSION FROM ${REPOSITORY_BASE_PATH}/runner-pulumi-base-alpine:${RELEASE_VERSION} USER root diff --git a/python/Dockerfile b/python/Dockerfile index e02070f..251b278 100644 --- a/python/Dockerfile +++ b/python/Dockerfile @@ -1,10 +1,9 @@ -ARG RELEASE_VERSION ARG REPOSITORY_BASE_PATH - +ARG RELEASE_VERSION FROM ${REPOSITORY_BASE_PATH}/runner-pulumi-base-debian:${RELEASE_VERSION} USER root RUN apt-get install -y git python3 python3-pip python3-dev python3-venv && ln -sf python3 /usr/bin/python RUN pip3 install --no-cache --upgrade pip setuptools wheel -USER spacelift ENV PATH="$PATH:./.pulumi/bin" +USER spacelift