Skip to content

feat: Create arm + x86 Docker images to allow local builds #12

feat: Create arm + x86 Docker images to allow local builds

feat: Create arm + x86 Docker images to allow local builds #12

name: Build Docker image for building PGlite
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
on:
workflow_dispatch:
inputs:
message:
description: 'Build PGlite builder Docker image'
push:
branches: ['main']
paths:
- .buildconfig
pull_request:
paths:
- .buildconfig
env:
BUILD_CONFIG_FILE: .buildconfig
IMGNAME: electricsql/pglite-builder
jobs:
build:
name: Build Docker image
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
- name: Set build parameters
run: cat ${{ env.BUILD_CONFIG_FILE }} >> $GITHUB_ENV
- name: Log build parameters and set image tag
run: |
echo "Building with PG_VERSION=${PG_VERSION} and SDK_VERSION=${SDK_VERSION}"
echo "IMGTAG=${PG_VERSION}_${SDK_VERSION}" >> $GITHUB_ENV
- name: Check if image exists
id: image-exists
run: |
if docker manifest inspect ${{ env.IMGNAME }}:${{ env.IMGTAG }} > /dev/null 2>&1; then
echo "exists=true" >> $GITHUB_OUTPUT
else
echo "exists=false" >> $GITHUB_OUTPUT
fi
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
if: steps.image-exists.outputs.exists == 'false'
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
if: steps.image-exists.outputs.exists == 'false'
- name: Login to Docker Hub
uses: docker/login-action@v3
if: steps.image-exists.outputs.exists == 'false'
with:
username: ${{ vars.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and push
uses: docker/build-push-action@v6
if: steps.image-exists.outputs.exists == 'false'
with:
platforms: linux/amd64,linux/arm64
push: true
build-args: |
PG_VERSION=${{ env.PG_VERSION }}
SDK_VERSION=${{ env.SDK_VERSION }}
tags: |
${{ env.IMGNAME }}:${{ env.IMGTAG }}
${{ env.IMGNAME }}:latest