Skip to content

Commit d3517eb

Browse files
committed
add buildx workflow
1 parent d80da52 commit d3517eb

File tree

4 files changed

+153
-3
lines changed

4 files changed

+153
-3
lines changed

.github/workflows/buildx.yml

Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
name: buildx-qemu-experimental-build
2+
# Building NOT`linux/amd64`images !
3+
4+
on:
5+
push:
6+
pull_request:
7+
schedule:
8+
- cron: '15 6 * * 1'
9+
10+
defaults:
11+
run:
12+
shell: bash
13+
14+
jobs:
15+
16+
make-docker-images:
17+
strategy:
18+
# allowing fails ..
19+
fail-fast: false
20+
matrix:
21+
# expecting:
22+
# - "postgres" docker images OS/ARCH=platforms should be exists
23+
# [ https://hub.docker.com/_/postgres/tags ]
24+
#
25+
# platform='linux/amd64' building with the `main.yml' !
26+
# Not for the `*-master``building. Emulation takes lot of times!
27+
#`
28+
# comments: 2022-09-07
29+
# 'linux/arm/v7' - debian: Unable to locate package postgresql-??-postgis-3;
30+
# 'linux/arm/v6' - debian: Unable to locate package postgresql-??-postgis-3;
31+
# 'linux/s390x' [alpine|debian] failed test.
32+
# 'linux/mips64le' [alpine|debian] failed test.
33+
# ...
34+
#
35+
# succesful tests matrix:
36+
platforms: ['linux/arm64','linux/arm/v7','linux/arm/v6','linux/386','linux/ppc64le']
37+
postgres: ['15beta3']
38+
postgis: ['3.2']
39+
variant: [alpine]
40+
include:
41+
- postgres: '15beta3'
42+
postgis: '3.2'
43+
variant: 'default'
44+
platforms: 'linux/arm64'
45+
- postgres: '15beta3'
46+
postgis: '3.2'
47+
variant: 'default'
48+
platforms: 'linux/ppc64le'
49+
50+
name: ${{ matrix.platforms }} ${{ matrix.postgres }}-${{ matrix.postgis }} ${{ matrix.variant }}
51+
runs-on: ubuntu-latest
52+
53+
env:
54+
VERSION: ${{ matrix.postgres }}-${{ matrix.postgis }}
55+
VARIANT: ${{ matrix.variant }}
56+
57+
steps:
58+
59+
- name: Checkout
60+
uses: actions/checkout@v3
61+
62+
- name: Set up QEMU
63+
uses: docker/setup-qemu-action@v2
64+
65+
- name: Set up Docker Buildx
66+
uses: docker/setup-buildx-action@v2
67+
68+
- name: "docker buildx inspect --bootstrap"
69+
run: docker buildx inspect --bootstrap
70+
71+
- name: "docker buildx ls"
72+
run: docker buildx ls
73+
74+
- name: "Inspect the base alpine image postgres:${{ matrix.postgres }}-alpine3.16"
75+
if: ${{ env.VARIANT == 'alpine' }}
76+
run: docker pull --platform=${{ matrix.platforms }} postgres:${{ matrix.postgres }}-alpine3.16 && docker inspect postgres:${{ matrix.postgres }}-alpine3.16
77+
env:
78+
DOCKER_DEFAULT_PLATFORM: ${{ matrix.platforms }}
79+
PLATFORM: ${{ matrix.platforms }}
80+
81+
- name: Build docker image for ${{ env.VERSION }} ${{ env.VARIANT }} ${{ env.DOCKER_DEFAULT_PLATFORM }}
82+
run: make test
83+
env:
84+
DOCKER_DEFAULT_PLATFORM: ${{ matrix.platforms }}
85+
PLATFORM: ${{ matrix.platforms }}
86+
# Buildx/qemu test need more time
87+
POSTGRES_TEST_TRIES: 42
88+
POSTGRES_TEST_SLEEP: 2
89+
90+
- name: "docker images"
91+
run: docker images
92+
93+
- if: ${{ env.VARIANT == 'default' }}
94+
run: docker inspect postgis/postgis:${{ env.VERSION }}
95+
96+
- if: ${{ env.VARIANT == 'alpine' }}
97+
run: docker inspect postgis/postgis:${{ env.VERSION }}-${{ env.VARIANT }}
98+
99+
- name: Login to dockerhub
100+
uses: docker/login-action@v1
101+
if: ${{ (github.ref == 'refs/heads/master') && (github.event_name != 'pull_request') }}
102+
with:
103+
username: ${{ secrets.DOCKERHUB_USERNAME }}
104+
password: ${{ secrets.DOCKERHUB_ACCESS_TOKEN }}
105+
106+
- name: Push docker image to dockerhub - ${{ matrix.platforms }}
107+
if: ${{ (github.ref == 'refs/heads/master') && (github.event_name != 'pull_request') }}
108+
env:
109+
# platform is important!
110+
DOCKER_DEFAULT_PLATFORM: ${{ matrix.platforms }}
111+
PLATFORM: ${{ matrix.platforms }}
112+
#
113+
DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }}
114+
DOCKERHUB_PASSWORD: ${{ secrets.DOCKERHUB_PASSWORD }}
115+
DOCKERHUB_ACCESS_TOKEN: ${{ secrets.DOCKERHUB_ACCESS_TOKEN }}
116+
run: make push

Dockerfile.alpine.template

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,11 +90,31 @@ RUN set -eux \
9090
&& make -j$(nproc) \
9191
&& make install \
9292
\
93+
# buildx platform check for debug.
94+
&& uname -a \
95+
&& uname -m \
96+
&& cat /proc/cpuinfo \
97+
\
9398
# regress check
9499
&& mkdir /tempdb \
95100
&& chown -R postgres:postgres /tempdb \
96101
&& su postgres -c 'pg_ctl -D /tempdb init' \
97-
&& su postgres -c 'pg_ctl -D /tempdb start' \
102+
\
103+
&& if [ "%%PG_MAJOR%%" == "10" ]; then \
104+
set -eux \
105+
# pg ==10 : testing with huge_pages=off ---> for the buildx/qemu workflow
106+
&& su postgres -c 'pg_ctl -o "--huge_pages=off" -D /tempdb start' \
107+
&& su postgres -c 'psql -c "SHOW HUGE_PAGES;"' \
108+
; \
109+
else \
110+
set -eux \
111+
# pg >=11 : testing with jit=off , huge_pages=off ---> for the buildx/qemu workflow
112+
&& su postgres -c 'pg_ctl -o "--huge_pages=off" -o "--jit=off" -D /tempdb start' \
113+
&& su postgres -c 'psql -c "SHOW HUGE_PAGES;"' \
114+
&& su postgres -c 'psql -c "SHOW JIT;"' \
115+
; \
116+
fi \
117+
\
98118
&& cd regress \
99119
&& make -j$(nproc) check RUNTESTFLAGS=--extension PGUSER=postgres \
100120
#&& make -j$(nproc) check RUNTESTFLAGS=--dumprestore PGUSER=postgres \

Dockerfile.template

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,12 @@ ENV POSTGIS_MAJOR %%POSTGIS_MAJOR%%
66
ENV POSTGIS_VERSION %%POSTGIS_VERSION%%
77

88
RUN apt-get update \
9+
\
10+
# buildx debug info
11+
&& uname -a \
12+
&& uname -m \
13+
&& lscpu \
14+
\
915
&& apt-cache showpkg postgresql-$PG_MAJOR-postgis-$POSTGIS_MAJOR \
1016
&& apt-get install -y --no-install-recommends \
1117
# ca-certificates: for accessing remote raster files;

test/tests/postgis-basics/run.sh

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,11 @@ set -e
33

44
image="$1"
55

6+
# buildx debug:
7+
uname -a
8+
uname -m
9+
cat /proc/cpuinfo
10+
611
export POSTGRES_USER='my cool postgres user'
712
export POSTGRES_PASSWORD='my cool postgres password'
813
export POSTGRES_DB='my cool postgres database'
@@ -24,15 +29,18 @@ psql() {
2429
"$@"
2530
}
2631

27-
tries=10
32+
: ${POSTGRES_TEST_TRIES:=10}
33+
: ${POSTGRES_TEST_SLEEP:=2}
34+
35+
tries="$POSTGRES_TEST_TRIES"
2836
while ! echo 'SELECT 1' | psql &> /dev/null; do
2937
(( tries-- ))
3038
if [ $tries -le 0 ]; then
3139
echo >&2 'postgres failed to accept connections in a reasonable amount of time!'
3240
echo 'SELECT 1' | psql # to hopefully get a useful error message
3341
false
3442
fi
35-
sleep 2
43+
sleep "$POSTGRES_TEST_SLEEP"
3644
done
3745

3846
echo 'SELECT PostGIS_Version()' | psql

0 commit comments

Comments
 (0)