Skip to content

Commit 82950a8

Browse files
committedAug 14, 2024
Add docker image build workflow
1 parent 0d031ad commit 82950a8

File tree

2 files changed

+68
-2
lines changed

2 files changed

+68
-2
lines changed
 
+65
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
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+
.

‎.github/workflows/build_wasm_postgres.yml

+3-2
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,10 @@ jobs:
1212
build:
1313
name: Build WASM Postgres
1414
runs-on: ubuntu-22.04
15+
environment: PGlite Build Parameters
1516
env:
16-
PGVERSION: 16.3
17-
SDK_VERSION: 3.1.65.6bi
17+
PGVERSION: ${{ vars.PG_VERSION }}
18+
SDK_VERSION: ${{ vars.PYTHON_WASM_SDK_VERSION }}
1819
SDK_ARCHIVE: python3.12-wasm-sdk-Ubuntu-22.04.tar.lz4
1920
SDKROOT: /opt/python-wasm-sdk
2021
SYS_PYTHON: /usr/bin/python3

0 commit comments

Comments
 (0)
Failed to load comments.