Skip to content

Build and Push Rootfs Docker Image #27

Build and Push Rootfs Docker Image

Build and Push Rootfs Docker Image #27

Workflow file for this run

name: Build and Push Rootfs Docker Image
on:
push:
branches:
- main
paths:
- 'Dockerfile'
workflow_dispatch:
permissions:
# This is required for configure-aws-credentials to request an OIDC JWT ID token to access AWS resources later on.
# More info: https://docs.github.com/en/actions/deployment/security-hardening-your-deployments/about-security-hardening-with-openid-connect#adding-permissions-settings
id-token: write
contents: write
jobs:
build-rootfs-image:
runs-on: ubuntu-latest
strategy:
matrix:
# finch only supports amd64 for windows
arch: ['amd64']
platform: ['common']
steps:
- name: Generate Timestamp
id: timestamp
run: echo "::set-output name=value::$(date +%s)"
- name: configure aws credentials
uses: aws-actions/configure-aws-credentials@e3dd6a429d7300a6a4c196c26e071d42e0343502 # v4.0.2
with:
aws-region: ${{ secrets.REGION }}
role-to-assume: ${{ secrets.ROLE }}
role-session-name: rootfs-ecr-image-upload-session
- name: Login to Amazon ECR
uses: aws-actions/amazon-ecr-login@v2
- name: checkout repo
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
with:
fetch-depth: 0
persist-credentials: false
- name: Set up QEMU
uses: docker/setup-qemu-action@68827325e0b33c7199eb31dd4e31fbe9023e06e3 # v3.0.0
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@d70bba72b1f3fd22344832f00baa16ece964efeb # v3.3.0
- name: Build Image
uses: docker/build-push-action@31159d49c0d4756269a0940a750801a1ea5d7003 # v6.1.0
with:
platforms: linux/${{ matrix.arch }}
push: false
load: true # load the image into Docker so we can create a container from it
tags: finch-rootfs-image-production:intermediate
- name: Tag and Push Container Image
run: |
TIMESTAMP=${{ steps.timestamp.outputs.value }}
docker tag finch-rootfs-image-production:intermediate ${{ secrets.ROOTFS_IMAGE_ECR_REPOSITORY_NAME }}:${{ matrix.arch }}-"$TIMESTAMP"
docker push ${{ secrets.ROOTFS_IMAGE_ECR_REPOSITORY_NAME }}:${{ matrix.arch }}-"$TIMESTAMP"
- name: Create, Compress, and Upload Rootfs
run: |
TIMESTAMP=${{ steps.timestamp.outputs.value }}
docker container create --platform linux/${{ matrix.arch }} --name ${{ matrix.arch }}-rootfs finch-rootfs-image-production:intermediate
docker container export -o finch-rootfs-production-${{ matrix.arch }}.tar ${{ matrix.arch }}-rootfs
compressed_archive=finch-rootfs-production-${{ matrix.arch }}-"$TIMESTAMP".tar.gz
gzip -9 -c finch-rootfs-production-${{ matrix.arch }}.tar > $compressed_archive
sha512sum $compressed_archive | cut -d " " -f 1 > $compressed_archive.sha512sum
ARCHPATH="x86-64"
if [ ${{ matrix.arch }} == "arm64" ]; then
ARCHPATH="aarch64"
fi
# Upload tarball and shasum to S3
aws s3 cp ./finch-rootfs-production-${{ matrix.arch }}-"$TIMESTAMP".tar.gz* s3://${{ secrets.DEPENDENCY_BUCKET_NAME }}/${{ matrix.platform }}/$ARCHPATH/