|
| 1 | +name: Build Docker image for building PGlite |
| 2 | + |
| 3 | +concurrency: |
| 4 | + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} |
| 5 | + cancel-in-progress: true |
| 6 | + |
| 7 | +on: |
| 8 | + workflow_dispatch: |
| 9 | + inputs: |
| 10 | + message: |
| 11 | + description: 'Build PGlite builder Docker image' |
| 12 | + push: |
| 13 | + branches: ['main'] |
| 14 | + pull_request: |
| 15 | + |
| 16 | +env: |
| 17 | + DOCKERHUB_REPO: electricsql |
| 18 | + IMAGE_NAME: pglite-builder |
| 19 | + |
| 20 | +jobs: |
| 21 | + build: |
| 22 | + name: Build Docker image |
| 23 | + runs-on: ubuntu-22.04 |
| 24 | + environment: PGlite Build Parameters |
| 25 | + env: |
| 26 | + PG_VERSION: ${{ vars.PG_VERSION }} |
| 27 | + SDK_VERSION: ${{ vars.PYTHON_WASM_SDK_VERSION }} |
| 28 | + steps: |
| 29 | + - name: Log build parameters |
| 30 | + run: | |
| 31 | + echo "Building with PG_VERSION=${PG_VERSION} and SDK_VERSION=${SDK_VERSION}" |
| 32 | +
|
| 33 | + - name: Set image name and tag |
| 34 | + id: set-image-name |
| 35 | + run: | |
| 36 | + echo "IMGNAME=${{ env.DOCKERHUB_REPO }}/${{ env.IMAGE_NAME }}" >> $GITHUB_ENV |
| 37 | + echo "IMGTAG=${{ env.PG_VERSION }}-${{ env.SDK_VERSION }}" >> $GITHUB_ENV |
| 38 | +
|
| 39 | + - name: Check if image exists already |
| 40 | + id: image-exists |
| 41 | + run: | |
| 42 | + docker manifest inspect ${{ env.IMGNAME }}:${{ env.IMGTAG }} > /dev/null 2>&1 && echo "exists=true" || echo "exists=false" |
| 43 | + continue-on-error: true |
| 44 | + shell: bash |
| 45 | + |
| 46 | + - name: Set output for image-exists |
| 47 | + id: set-output |
| 48 | + run: | |
| 49 | + echo "::set-output name=exists::$(docker manifest inspect ${{ env.IMGNAME }}:${{ env.IMGTAG }} > /dev/null 2>&1 && echo true || echo false)" |
| 50 | + shell: bash |
| 51 | + |
| 52 | + - uses: actions/checkout@v4 |
| 53 | + if: steps.image-exists.outputs.exists == 'false' |
| 54 | + |
| 55 | + - name: Build and push Docker image |
| 56 | + if: steps.image-exists.outputs.exists == 'false' |
| 57 | + run: | |
| 58 | + export PGLITE_BUILDER_IMAGE_NAME="${DOCKERHUB_REPO}/${IMAGE_NAME}" |
| 59 | + export BUILDER_VERSION="${PG_VERSION}-${SDK_VERSION}" |
| 60 | + docker buildx build --platform linux/arm64/v8,linux/amd64 --push |
| 61 | + --build-arg PG_VERSION=$PG_VERSION |
| 62 | + --build-arg SDK_VERSION=$SDK_VERSION |
| 63 | + -t $${PGLITE_BUILDER_IMAGE_NAME}:$${BUILDER_VERSION} |
| 64 | + -t $${PGLITE_BUILDER_IMAGE_NAME}:latest |
| 65 | + . |
0 commit comments