Skip to content

Commit c795cea

Browse files
pcncdragarciadarorahfsoedirgo
authored
chore: Build Ubuntu 18 binaries (#614)
* chore: create Ubuntu 18 workflow * chore: create Ubuntu 18 workflow * chore: streamline workflow * chore: update * chore: update sources * chore: trigger workflow * chore: more soruces * chore: even more sources * chore: move signed key addition * chore: trust more * chore: get ubuntu codename * chore: refactor llvm support for bionic * chore: fix missing env var * chore: fix ubuntu distro sources * chore: more ubuntu 18 shenanigans * chore: removing incompatible extensions * chore: enable Vault (#598) * chore: re-enable Vault * chore: bump version * chore: version as rc * fix: formatting * chore: build test image from branch * chore: trigger build * chore: remove branch * chore: bump version * Revert "chore: enable Vault (#598)" (#607) This reverts commit a157038. * feat: bump gotrue to v2.57.2 (#609) * feat: remove `disable.vault` suffix from 15.1.0.66 (#610) * chore: enable Vault with safety measures (#611) * chore: re-enable Vault * chore: bump version * chore: version as rc * fix: formatting * chore: build test image from branch * chore: trigger build * chore: remove branch * chore: bump version * chore: add safeguards when enabling Vaault * chore: revert changes * chore: safeguard both pgsodium and vault * chore: bump version * update migrations guidelines * chore: better os-version specific handling * chore: better workflow management * chore: use full version name for Postgres releases * chore: revert to old triggers * chore: bump version * chore: bump adminapi; pg version --------- Co-authored-by: dragarcia <[email protected]> Co-authored-by: Div Arora <[email protected]> Co-authored-by: Stojan Dimitrovski <[email protected]> Co-authored-by: Bobbie Soedirgo <[email protected]>
1 parent 5961647 commit c795cea

22 files changed

+287
-34
lines changed
+87
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
name: Build Ubuntu 18 AMI
2+
3+
on:
4+
push:
5+
branches:
6+
- develop
7+
paths:
8+
- '.github/workflows/ami-build-ubuntu-18.yml'
9+
- 'common.vars.pkr.hcl'
10+
11+
workflow_run:
12+
workflows: [Release AMI]
13+
types:
14+
- completed
15+
16+
workflow_dispatch:
17+
18+
jobs:
19+
build:
20+
runs-on: [self-hosted, X64]
21+
timeout-minutes: 150
22+
permissions:
23+
contents: write
24+
packages: write
25+
id-token: write
26+
27+
steps:
28+
- name: Checkout Repo
29+
uses: actions/checkout@v2
30+
31+
- name: Build AMI
32+
run: |
33+
GIT_SHA=${{github.sha}}
34+
packer build -var "git-head-version=${GIT_SHA}" -var "packer-execution-id=u18-${GITHUB_RUN_ID}" -var-file="development-arm.vars.pkr.hcl" -var-file="common.vars.pkr.hcl" -var-file="legacy.vars.pkr.hcl" amazon-arm64.pkr.hcl
35+
36+
- name: Grab release version
37+
id: process_release_version
38+
run: |
39+
VERSION=$(sed -e 's/postgres-version = "\(.*\)"/\1/g' common.vars.pkr.hcl)
40+
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
41+
42+
- name: List files
43+
id: list_files
44+
run: |
45+
ls -la /tmp/
46+
47+
- name: configure aws credentials - staging
48+
uses: aws-actions/configure-aws-credentials@v1
49+
with:
50+
role-to-assume: ${{ secrets.DEV_AWS_ROLE }}
51+
aws-region: "us-east-1"
52+
53+
- name: Upload pg binaries to s3 staging
54+
run: |
55+
aws s3 cp /tmp/pg_binaries.tar.gz s3://${{ secrets.ARTIFACTS_BUCKET }}/upgrades/postgres/supabase-postgres-${{ steps.process_release_version.outputs.version }}/18.04.tar.gz
56+
57+
- name: configure aws credentials - prod
58+
uses: aws-actions/configure-aws-credentials@v1
59+
with:
60+
role-to-assume: ${{ secrets.PROD_AWS_ROLE }}
61+
aws-region: "us-east-1"
62+
63+
- name: Upload pg binaries to s3 prod
64+
run: |
65+
aws s3 cp /tmp/pg_binaries.tar.gz s3://${{ secrets.PROD_ARTIFACTS_BUCKET }}/upgrades/postgres/supabase-postgres-${{ steps.process_release_version.outputs.version }}/18.04.tar.gz
66+
67+
- name: Deregister image
68+
if: ${{ always() }}
69+
continue-on-error: true
70+
run: |
71+
IMAGE_IDS=$(aws ec2 describe-images --filters "Name=name,Values=builder-supabase-postgres-u18-*" --query "Images[] .ImageId" --output text)
72+
for IMAGE_ID in $IMAGE_IDS; do
73+
SNAPSHOTS=$(aws ec2 describe-images --image-ids $IMAGE_ID --query "Images[*].BlockDeviceMappings[*].Ebs.SnapshotId" --output text)
74+
75+
echo "Deregistering image $IMAGE_ID"
76+
aws ec2 deregister-image --image-id $IMAGE_ID
77+
78+
for SNAPSHOT in $SNAPSHOTS; do
79+
echo "Deleting snapshot $SNAPSHOT"
80+
aws ec2 delete-snapshot --snapshot-id $SNAPSHOT
81+
done
82+
done
83+
84+
- name: Cleanup resources on build cancellation
85+
if: ${{ cancelled() }}
86+
run: |
87+
aws ec2 describe-instances --filters "Name=tag:packerExecutionId,Values=u18-${GITHUB_RUN_ID}" --query "Reservations[].Instances[].InstanceId" --output text | xargs -I {} aws ec2 terminate-instances --instance-ids {}

.github/workflows/ami-release.yml

+9-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ jobs:
2525
- name: Build AMI
2626
run: |
2727
GIT_SHA=${{github.sha}}
28-
packer build -var "git-head-version=${GIT_SHA}" -var "packer-execution-id=${GITHUB_RUN_ID}" -var-file="development-arm.vars.pkr.hcl" -var-file="common.vars.pkr.hcl" amazon-arm64.pkr.hcl
28+
packer build -var "git-head-version=${GIT_SHA}" -var "packer-execution-id=${GITHUB_RUN_ID}" -var-file="development-arm.vars.pkr.hcl" -var-file="common.vars.pkr.hcl" -var "ansible_arguments=" amazon-arm64.pkr.hcl
2929
3030
- name: Grab release version
3131
id: process_release_version
@@ -47,6 +47,10 @@ jobs:
4747
-e "internal_artifacts_bucket=${{ secrets.ARTIFACTS_BUCKET }}" \
4848
manifest-playbook.yml
4949
50+
- name: Upload pg binaries to s3 staging
51+
run: |
52+
aws s3 cp /tmp/pg_binaries.tar.gz s3://${{ secrets.ARTIFACTS_BUCKET }}/upgrades/postgres/supabase-postgres-${{ steps.process_release_version.outputs.version }}/20.04.tar.gz
53+
5054
- name: configure aws credentials - prod
5155
uses: aws-actions/configure-aws-credentials@v1
5256
with:
@@ -61,6 +65,10 @@ jobs:
6165
-e "internal_artifacts_bucket=${{ secrets.PROD_ARTIFACTS_BUCKET }}" \
6266
manifest-playbook.yml
6367
68+
- name: Upload pg binaries to s3 prod
69+
run: |
70+
aws s3 cp /tmp/pg_binaries.tar.gz s3://${{ secrets.PROD_ARTIFACTS_BUCKET }}/upgrades/postgres/supabase-postgres-${{ steps.process_release_version.outputs.version }}/20.04.tar.gz
71+
6472
- name: Create release
6573
uses: softprops/action-gh-release@v1
6674
with:

amazon-arm64.pkr.hcl

+9-2
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ variable "ami_regions" {
2020

2121
variable "ansible_arguments" {
2222
type = string
23-
default = "--skip-tags,install-postgrest,--skip-tags,install-pgbouncer,--skip-tags,install-supabase-internal,ebssurrogate_mode='true'"
23+
default = "--skip-tags install-postgrest,install-pgbouncer,install-supabase-internal"
2424
}
2525

2626
variable "aws_access_key" {
@@ -239,8 +239,9 @@ build {
239239
"DOCKER_IMAGE=${var.docker_image}",
240240
"DOCKER_IMAGE_TAG=${var.docker_image_tag}"
241241
]
242+
use_env_var_file = true
242243
script = "ebssurrogate/scripts/surrogate-bootstrap.sh"
243-
execute_command = "sudo -S sh -c '{{ .Vars }} {{ .Path }}'"
244+
execute_command = "sudo -S sh -c '. {{.EnvVarFile}} && {{.Path}}'"
244245
start_retry_timeout = "5m"
245246
skip_clean = true
246247
}
@@ -250,4 +251,10 @@ build {
250251
destination = "/tmp/ansible.log"
251252
direction = "download"
252253
}
254+
255+
provisioner "file" {
256+
source = "/tmp/pg_binaries.tar.gz"
257+
destination = "/tmp/pg_binaries.tar.gz"
258+
direction = "download"
259+
}
253260
}

ansible/playbook.yml

+9
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,8 @@
154154

155155
- name: Run migrations
156156
import_tasks: tasks/setup-migrations.yml
157+
tags:
158+
- migrations
157159

158160
- name: Stop Postgres Database without Systemd
159161
become: yes
@@ -164,3 +166,10 @@
164166

165167
- name: Run unit tests
166168
import_tasks: tasks/test-image.yml
169+
tags:
170+
- unit-tests
171+
172+
- name: Collect Postgres binaries
173+
import_tasks: tasks/internal/collect-pg-binaries.yml
174+
tags:
175+
- collect-binaries

ansible/tasks/finalize-ami.yml

+19
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,31 @@
2727
port: http
2828
tags:
2929
- install-supabase-internal
30+
when: ansible_distribution_version != "18.04"
3031

3132
- name: UFW - Allow connections to https (443)
3233
ufw:
3334
rule: allow
3435
port: https
3536
tags:
3637
- install-supabase-internal
38+
when: ansible_distribution_version != "18.04"
39+
40+
- name: UFW - Allow connections to http (80) - Ubuntu 18.04
41+
ufw:
42+
rule: allow
43+
port: "80"
44+
tags:
45+
- install-supabase-internal
46+
when: ansible_distribution_version == "18.04"
47+
48+
- name: UFW - Allow connections to https (443) - Ubuntu 18.04
49+
ufw:
50+
rule: allow
51+
port: "443"
52+
tags:
53+
- install-supabase-internal
54+
when: ansible_distribution_version == "18.04"
3755

3856
- name: UFW - Deny all other incoming traffic by default
3957
ufw:
@@ -65,6 +83,7 @@
6583
sed -i -e 's;daily;*:0/10;' /etc/systemd/system/logrotate.timer
6684
systemctl reenable logrotate.timer
6785
become: yes
86+
when: ansible_distribution_version != "18.04"
6887

6988
- name: import pgsodium_getkey script
7089
template:
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
- name: Collect Postgres binaries - create collection directory
2+
file:
3+
path: /tmp/pg_binaries/{{ postgresql_major }}/
4+
state: directory
5+
6+
- name: Collect Postgres binaries - collect binaries and libraries
7+
copy:
8+
remote_src: yes
9+
src: /usr/lib/postgresql/{{ item }}/
10+
dest: /tmp/pg_binaries/{{ postgresql_major }}/{{ item }}/
11+
with_items:
12+
- bin
13+
- lib
14+
15+
- name: Collect Postgres binaries - collect shared files
16+
copy:
17+
remote_src: yes
18+
src: /var/lib/postgresql/
19+
dest: /tmp/pg_binaries/{{ postgresql_major }}/share/
20+
21+
- name: Collect Postgres binaries - create tarfile
22+
archive:
23+
path: /tmp/pg_binaries/
24+
dest: /tmp/pg_binaries.tar.gz
25+
remove: yes
26+
27+
- name: Fetch tarfile to local
28+
fetch:
29+
src: /tmp/pg_binaries.tar.gz
30+
dest: /tmp/
31+
flat: true

ansible/tasks/internal/supautils.yml

+10
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,16 @@
66
- clang-11
77
update_cache: yes
88
cache_valid_time: 3600
9+
when: ansible_distribution_version != "18.04"
10+
11+
- name: supautils - download & install dependencies - Ubuntu 18.04
12+
apt:
13+
pkg:
14+
- build-essential
15+
- clang-12
16+
update_cache: yes
17+
cache_valid_time: 3600
18+
when: ansible_distribution_version != "18.04"
919

1020
- name: supautils - download latest release
1121
get_url:

ansible/tasks/postgres-extensions/01-postgis.yml

+4-2
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,8 @@
4949
become: yes
5050

5151
- name: postgis - build SFCGAL
52-
make:
52+
community.general.make:
53+
target: all
5354
chdir: /tmp/SFCGAL-v{{ sfcgal_release }}
5455
jobs: "{{ parallel_jobs | default(omit) }}"
5556
become: yes
@@ -78,7 +79,8 @@
7879
become: yes
7980

8081
- name: postgis - build
81-
make:
82+
community.general.make:
83+
target: all
8284
chdir: /tmp/postgis-{{ postgis_release }}
8385
jobs: "{{ parallel_jobs | default(omit) }}"
8486
become: yes

ansible/tasks/postgres-extensions/02-pgrouting.yml

+2-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@
3434
become: yes
3535

3636
- name: pgRouting - build
37-
make:
37+
community.general.make:
38+
target: all
3839
chdir: /tmp/pgrouting-{{ pgrouting_release }}/build
3940
jobs: "{{ parallel_jobs | default(omit) }}"
4041
become: yes

ansible/tasks/postgres-extensions/18-pgsodium.yml

-1
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@
5353
- name: pgsodium - build
5454
make:
5555
chdir: /tmp/pgsodium-{{ pgsodium_release }}
56-
jobs: "{{ parallel_jobs | default(omit) }}"
5756
become: yes
5857

5958
- name: pgsodium - install

ansible/tasks/postgres-extensions/24-pgroonga.yml

+4-2
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@
3333
become: yes
3434

3535
- name: groonga - build
36-
make:
36+
community.general.make:
37+
target: all
3738
chdir: /tmp/groonga-{{ groonga_release }}
3839
jobs: "{{ parallel_jobs | default(omit) }}"
3940
become: yes
@@ -59,7 +60,8 @@
5960
become: yes
6061

6162
- name: pgroonga - build
62-
make:
63+
community.general.make:
64+
target: all
6365
chdir: /tmp/pgroonga-{{ pgroonga_release }}
6466
jobs: "{{ parallel_jobs | default(omit) }}"
6567
become: yes

ansible/tasks/postgres-extensions/28-pgvector.yml

+8
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,14 @@
55
dest: /tmp/pgvector
66
version: 'v{{ pgvector_release }}'
77
become: yes
8+
9+
- name: pgvector - ubuntu 18.04 compat
10+
lineinfile:
11+
path: /tmp/pgvector/Makefile
12+
regexp: "march=native$"
13+
line: "OPTFLAGS = "
14+
firstmatch: true
15+
when: ansible_distribution_version == "18.04"
816

917
- name: pgvector - build
1018
make:

ansible/tasks/setup-extensions.yml

+4
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@
3939

4040
- name: Install pljava
4141
import_tasks: tasks/postgres-extensions/12-pljava.yml
42+
tags:
43+
- legacy-incompatible
4244

4345
- name: Install pg_plan_filter
4446
import_tasks: tasks/postgres-extensions/14-pg_plan_filter.yml
@@ -57,6 +59,8 @@
5759

5860
- name: Install pg_graphql
5961
import_tasks: tasks/postgres-extensions/19-pg_graphql.yml
62+
tags:
63+
- legacy-incompatible
6064

6165
- name: Install pg_stat_monitor
6266
import_tasks: tasks/postgres-extensions/20-pg_stat_monitor.yml

ansible/tasks/setup-nginx.yml

+2-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,8 @@
3737
become: yes
3838

3939
- name: nginx - build
40-
make:
40+
community.general.make:
41+
target: build
4142
chdir: /tmp/nginx-{{ nginx_release }}
4243
jobs: "{{ parallel_jobs | default(omit) }}"
4344
become: yes

0 commit comments

Comments
 (0)