Skip to content

Commit

Permalink
Add ARM build (#13)
Browse files Browse the repository at this point in the history
  • Loading branch information
peterdeme authored Jan 16, 2023
1 parent e52182c commit de676c0
Show file tree
Hide file tree
Showing 10 changed files with 490 additions and 202 deletions.
86 changes: 86 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -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
182 changes: 122 additions & 60 deletions .github/workflows/deploy-preproduction.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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

Expand All @@ -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:
Expand All @@ -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

Expand All @@ -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:
Expand All @@ -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

Expand All @@ -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:
Expand All @@ -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

Expand All @@ -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:
Expand All @@ -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

Expand All @@ -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 }}
Loading

0 comments on commit de676c0

Please sign in to comment.