Skip to content

Commit 68c108c

Browse files
committed
chore: ubuntu 18 postgres .deb install compat
1 parent ec228b7 commit 68c108c

File tree

7 files changed

+29
-33
lines changed

7 files changed

+29
-33
lines changed

.github/workflows/ami-build-ubuntu-18.yml

+6-4
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@ jobs:
2424
include:
2525
- runner: arm-runner
2626
arch: arm64
27-
ubuntu: focal
27+
ubuntu_release: bionic
28+
ubuntu_version: 18.04
2829
mcpu: neoverse-n1
2930
runs-on: ${{ matrix.runner }}
3031
timeout-minutes: 150
@@ -74,18 +75,19 @@ jobs:
7475
file: docker/Dockerfile
7576
target: pg-deb
7677
build-args: |
77-
ubuntu_release=${{ matrix.ubuntu }}
78+
ubuntu_release=${{ matrix.ubuntu_release }}
79+
ubuntu_release_no=${{ matrix.ubuntu_version }}
7880
postgresql_major=${{ steps.version.outputs.postgresql_major }}
7981
postgresql_release=${{ steps.version.outputs.postgresql_release }}
8082
CPPFLAGS=-mcpu=${{ matrix.mcpu }}
81-
tags: supabase/postgres:deb
83+
tags: supabase/postgres:deb-u18
8284
platforms: linux/${{ matrix.arch }}
8385
cache-from: type=gha
8486
cache-to: type=gha,mode=max
8587
- name: Extract Postgres deb
8688
run: |
8789
mkdir -p /tmp/build ansible/files/postgres
88-
docker save supabase/postgres:deb | tar xv -C /tmp/build
90+
docker save supabase/postgres:deb-u18 | tar xv -C /tmp/build
8991
for layer in /tmp/build/*/layer.tar; do
9092
tar xvf "$layer" -C ansible/files/postgres --strip-components 1
9193
done

.github/workflows/ami-release.yml

+4-2
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ jobs:
1616
include:
1717
- runner: arm-runner
1818
arch: arm64
19-
ubuntu: focal
19+
ubuntu_release: focal
20+
ubuntu_version: 20.04
2021
mcpu: neoverse-n1
2122
runs-on: ${{ matrix.runner }}
2223
timeout-minutes: 150
@@ -66,7 +67,8 @@ jobs:
6667
file: docker/Dockerfile
6768
target: pg-deb
6869
build-args: |
69-
ubuntu_release=${{ matrix.ubuntu }}
70+
ubuntu_release=${{ matrix.ubuntu_release }}
71+
ubuntu_release_no=${{ matrix.ubuntu_version }}
7072
postgresql_major=${{ steps.version.outputs.postgresql_major }}
7173
postgresql_release=${{ steps.version.outputs.postgresql_release }}
7274
CPPFLAGS=-mcpu=${{ matrix.mcpu }}

ansible/files/admin_api_scripts/pg_upgrade_initiate.sh

+6-21
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,9 @@ cleanup() {
7373
mv /var/lib/postgresql.bak /var/lib/postgresql
7474
fi
7575

76-
if [ -L /usr/lib/postgresql/lib/aarch64/libpq.so.5 ]; then
77-
rm /usr/lib/postgresql/lib/aarch64/libpq.so.5
76+
if [ -L "/usr/share/postgresql/${PGVERSION}" ]; then
77+
rm "/usr/share/postgresql/${PGVERSION}"
78+
mv "/usr/share/postgresql/${PGVERSION}.bak" "/usr/share/postgresql/${PGVERSION}"
7879
fi
7980

8081
if [ "$IS_DRY_RUN" = false ]; then
@@ -148,7 +149,6 @@ function initiate_upgrade {
148149
PGDATANEW="$MOUNT_POINT/pgdata"
149150
PG_UPGRADE_BIN_DIR="/tmp/pg_upgrade_bin/$PGVERSION"
150151
PGBINNEW="$PG_UPGRADE_BIN_DIR/bin"
151-
PGLIBNEW="$PG_UPGRADE_BIN_DIR/lib"
152152
PGSHARENEW="$PG_UPGRADE_BIN_DIR/share"
153153

154154
# running upgrade using at least 1 cpu core
@@ -168,12 +168,6 @@ function initiate_upgrade {
168168

169169
chown -R postgres:postgres "/tmp/pg_upgrade_bin/$PGVERSION"
170170

171-
# Make latest libpq available to pg_upgrade
172-
mkdir -p /usr/lib/postgresql/lib/aarch64
173-
if [ ! -L /usr/lib/postgresql/lib/aarch64/libpq.so.5 ]; then
174-
ln -s "$PGLIBNEW/libpq.so.5" /usr/lib/postgresql/lib/aarch64/libpq.so.5
175-
fi
176-
177171
# upgrade job outputs a log in the cwd; needs write permissions
178172
mkdir -p /tmp/pg_upgrade/
179173
chown -R postgres:postgres /tmp/pg_upgrade/
@@ -243,19 +237,10 @@ EOF
243237
if [ "$IS_DRY_RUN" = true ]; then
244238
UPGRADE_COMMAND="$UPGRADE_COMMAND --check"
245239
else
246-
mv /var/lib/postgresql /var/lib/postgresql.bak
247-
ln -s "$PGSHARENEW" /var/lib/postgresql
248-
249-
if [ ! -L /var/lib/postgresql.bak/data ]; then
250-
if [ -L /var/lib/postgresql/data ]; then
251-
rm /var/lib/postgresql/data
252-
fi
253-
ln -s /var/lib/postgresql.bak/data /var/lib/postgresql/data
254-
fi
255-
256-
if [ ! -L /var/lib/postgresql/data ]; then
257-
ln -s /data/pgdata /var/lib/postgresql/data
240+
if [ -d "/usr/share/postgresql/${PGVERSION}" ]; then
241+
mv "/usr/share/postgresql/${PGVERSION}" "/usr/share/postgresql/${PGVERSION}.bak"
258242
fi
243+
ln -s "$PGSHARENEW" "/usr/share/postgresql/${PGVERSION}"
259244

260245
echo "9. Stopping postgres; running pg_upgrade"
261246
systemctl stop postgresql

ansible/tasks/internal/collect-pg-binaries.yml

+7-1
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,18 @@
66
- name: Collect Postgres binaries - collect binaries and libraries
77
copy:
88
remote_src: yes
9-
src: /usr/lib/postgresql/{{ item }}/
9+
src: /usr/lib/postgresql/{{ postgresql_major }}/{{ item }}/
1010
dest: /tmp/pg_binaries/{{ postgresql_major }}/{{ item }}/
1111
with_items:
1212
- bin
1313
- lib
1414

15+
- name: Collect Postgres libraries - collect libraries which are not in /usr/lib/postgresql/lib
16+
copy:
17+
remote_src: yes
18+
src: /usr/lib/postgresql/lib/
19+
dest: /tmp/pg_binaries/{{ postgresql_major }}/lib/
20+
1521
- name: Collect Postgres binaries - collect shared files
1622
copy:
1723
remote_src: yes

ansible/tasks/internal/supautils.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
- clang-12
1616
update_cache: yes
1717
cache_valid_time: 3600
18-
when: ansible_distribution_version != "18.04"
18+
when: ansible_distribution_version == "18.04"
1919

2020
- name: supautils - download latest release
2121
get_url:

common.vars.pkr.hcl

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
postgres-version = "15.1.0.98-rc0"
1+
postgres-version = "15.1.0.98-rc3"

docker/Dockerfile

+4-3
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ ARG ubuntu_release=focal
22
FROM ubuntu:${ubuntu_release} as base
33

44
ARG ubuntu_release
5+
ARG ubuntu_release_no
56
ARG postgresql_major=15
67
ARG postgresql_release=${postgresql_major}.1
78

@@ -39,8 +40,8 @@ RUN apt-get build-dep -y postgresql-common pgdg-keyring && \
3940
dpkg-scanpackages . > Packages && \
4041
apt-get -o Acquire::GzipIndexes=false update
4142

42-
RUN apt-get build-dep -y "postgresql-${postgresql_major}=${postgresql_release}-1.pgdg20.04+1" && \
43-
apt-get source --compile "postgresql-${postgresql_major}=${postgresql_release}-1.pgdg20.04+1" && \
43+
RUN apt-get build-dep -y "postgresql-${postgresql_major}=${postgresql_release}-1.pgdg${ubuntu_release_no}+1" && \
44+
apt-get source --compile "postgresql-${postgresql_major}=${postgresql_release}-1.pgdg${ubuntu_release_no}+1" && \
4445
dpkg-scanpackages . > Packages && \
4546
apt-get -o Acquire::GzipIndexes=false update
4647

@@ -60,7 +61,7 @@ RUN echo "deb [ trusted=yes ] file:///tmp/build ./" > /etc/apt/sources.list.d/te
6061
apt-get -o Acquire::GzipIndexes=false update && \
6162
apt-get install -y --no-install-recommends postgresql-common && \
6263
sed -ri 's/#(create_main_cluster) .*$/\1 = false/' /etc/postgresql-common/createcluster.conf && \
63-
apt-get install -y --no-install-recommends "postgresql-${postgresql_major}=${postgresql_release}-1.pgdg20.04+1" && \
64+
apt-get install -y --no-install-recommends "postgresql-${postgresql_major}=${postgresql_release}-1.pgdg${ubuntu_release_no}+1" && \
6465
rm -rf /var/lib/apt/lists/* && \
6566
rm -rf /tmp/build /etc/apt/sources.list.d/temp.list
6667

0 commit comments

Comments
 (0)