Skip to content

Commit fcbfa6d

Browse files
committed
feat: move stage 1 to nightly build
1 parent a7327e0 commit fcbfa6d

File tree

8 files changed

+23
-36
lines changed

8 files changed

+23
-36
lines changed

.github/workflows/ami-release-nix-single.yml

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -61,14 +61,6 @@ jobs:
6161
# Ensure there's a newline at the end of the file
6262
echo "" >> common-nix.vars.pkr.hcl
6363
64-
- name: Build AMI stage 1
65-
env:
66-
POSTGRES_MAJOR_VERSION: ${{ env.POSTGRES_MAJOR_VERSION }}
67-
run: |
68-
GIT_SHA=${{ steps.get_sha.outputs.sha }}
69-
nix run github:supabase/postgres/${GIT_SHA}#packer -- init amazon-arm64-nix.pkr.hcl
70-
nix run github:supabase/postgres/${GIT_SHA}#packer -- build -var "git-head-version=${GIT_SHA}" -var "packer-execution-id=${EXECUTION_ID}" -var-file="development-arm.vars.pkr.hcl" -var-file="common-nix.vars.pkr.hcl" -var "ansible_arguments=-e postgresql_major=${POSTGRES_MAJOR_VERSION}" amazon-arm64-nix.pkr.hcl
71-
7264
- name: Build AMI stage 2
7365
env:
7466
POSTGRES_MAJOR_VERSION: ${{ env.POSTGRES_MAJOR_VERSION }}

.github/workflows/ami-release-nix.yml

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -89,15 +89,6 @@ jobs:
8989
# Ensure there's a newline at the end of the file
9090
echo "" >> common-nix.vars.pkr.hcl
9191
92-
- name: Build AMI stage 1
93-
env:
94-
POSTGRES_MAJOR_VERSION: ${{ env.POSTGRES_MAJOR_VERSION }}
95-
run: |
96-
GIT_SHA=${{github.sha}}
97-
nix run github:supabase/postgres/${GIT_SHA}#packer -- init amazon-arm64-nix.pkr.hcl
98-
# why is postgresql_major defined here instead of where the _three_ other postgresql_* variables are defined?
99-
nix run github:supabase/postgres/${GIT_SHA}#packer -- build -var "git-head-version=${GIT_SHA}" -var "packer-execution-id=${EXECUTION_ID}" -var-file="development-arm.vars.pkr.hcl" -var-file="common-nix.vars.pkr.hcl" -var "ansible_arguments=-e postgresql_major=${POSTGRES_MAJOR_VERSION}" -var "region=us-east-1" -var 'ami_regions=["us-east-1"]' amazon-arm64-nix.pkr.hcl
100-
10192
- name: Build AMI stage 2
10293
env:
10394
POSTGRES_MAJOR_VERSION: ${{ env.POSTGRES_MAJOR_VERSION }}

.github/workflows/testinfra-ami-build.yml

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -108,15 +108,6 @@ jobs:
108108
# Ensure there's a newline at the end of the file
109109
echo "" >> common-nix.vars.pkr.hcl
110110
111-
- name: Build AMI stage 1
112-
env:
113-
AWS_MAX_ATTEMPTS: 10
114-
AWS_RETRY_MODE: adaptive
115-
run: |
116-
GIT_SHA=${{github.sha}}
117-
nix run github:supabase/postgres/${GIT_SHA}#packer -- init amazon-arm64-nix.pkr.hcl
118-
nix run github:supabase/postgres/${GIT_SHA}#packer -- build -var "git-head-version=${GIT_SHA}" -var "packer-execution-id=${EXECUTION_ID}" -var-file="development-arm.vars.pkr.hcl" -var-file="common-nix.vars.pkr.hcl" -var "ansible_arguments=" -var "postgres-version=${{ steps.random.outputs.random_string }}" -var "region=ap-southeast-1" -var 'ami_regions=["ap-southeast-1"]' -var "force-deregister=true" -var "ansible_arguments=-e postgresql_major=${POSTGRES_MAJOR_VERSION}" amazon-arm64-nix.pkr.hcl
119-
120111
- name: Build AMI stage 2
121112
env:
122113
AWS_MAX_ATTEMPTS: 10

amazon-arm64-nix.pkr.hcl

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,18 @@ variable "force-deregister" {
9292
default = false
9393
}
9494

95+
variable "base-image-nightly" {
96+
type = bool
97+
default = false
98+
description = "Build as version-agnostic base image for nightly"
99+
}
100+
101+
variable "build-timestamp" {
102+
type = string
103+
default = ""
104+
description = "Timestamp for nightly builds"
105+
}
106+
95107
packer {
96108
required_plugins {
97109
amazon = {
@@ -106,7 +118,7 @@ source "amazon-ebssurrogate" "source" {
106118
profile = "${var.profile}"
107119
#access_key = "${var.aws_access_key}"
108120
#ami_name = "${var.ami_name}-arm64-${formatdate("YYYY-MM-DD-hhmm", timestamp())}"
109-
ami_name = "${var.ami_name}-${var.postgres-version}-stage-1"
121+
ami_name = var.base-image-nightly ? "${var.ami_name}-base-stage-1-nightly" : "${var.ami_name}-${var.postgres-version}-stage-1"
110122
ami_virtualization_type = "hvm"
111123
ami_architecture = "arm64"
112124
ami_regions = "${var.ami_regions}"
@@ -170,8 +182,10 @@ source "amazon-ebssurrogate" "source" {
170182
tags = {
171183
creator = "packer"
172184
appType = "postgres"
173-
postgresVersion = "${var.postgres-version}-stage1"
185+
postgresVersion = var.base-image-nightly ? "base-nightly" : "${var.postgres-version}-stage1"
174186
sourceSha = "${var.git-head-version}"
187+
buildTimestamp = var.base-image-nightly ? "${var.build-timestamp}" : ""
188+
buildType = var.base-image-nightly ? "nightly" : "release"
175189
}
176190

177191
communicator = "ssh"

ansible/playbook.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,13 +46,13 @@
4646
- install-gotrue
4747
- install-supabase-internal
4848
when: debpkg_mode or nixpkg_mode
49-
49+
5050
- name: Install PostgREST
5151
import_tasks: tasks/setup-postgrest.yml
5252
tags:
5353
- install-postgrest
5454
- install-supabase-internal
55-
when: debpkg_mode or nixpkg_mode
55+
when: debpkg_mode or stage2_nix
5656

5757
- name: Install Envoy
5858
import_tasks: tasks/setup-envoy.yml

ansible/tasks/setup-postgrest.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
- name: PostgREST - add Postgres PPA main
1212
ansible.builtin.apt_repository:
1313
filename: 'postgresql-pgdg'
14-
repo: "deb http://apt.postgresql.org/pub/repos/apt/ noble-pgdg {{ postgresql_major }}"
14+
repo: "deb http://apt.postgresql.org/pub/repos/apt/ noble-pgdg main"
1515
state: 'present'
1616

1717
- name: PostgREST - install system dependencies
@@ -36,7 +36,7 @@
3636

3737
- name: PostgREST - remove Postgres PPA
3838
ansible.builtin.apt_repository:
39-
repo: "deb http://apt.postgresql.org/pub/repos/apt/ noble-pgdg {{ postgresql_major }}"
39+
repo: "deb http://apt.postgresql.org/pub/repos/apt/ noble-pgdg main"
4040
state: 'absent'
4141

4242
- name: postgis - ensure dependencies do not get autoremoved

ebssurrogate/scripts/surrogate-bootstrap-nix.sh

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -303,11 +303,10 @@ tee /etc/ansible/ansible.cfg <<EOF
303303
callbacks_enabled = timer, profile_tasks, profile_roles
304304
EOF
305305
# Run Ansible playbook
306-
#export ANSIBLE_LOG_PATH=/tmp/ansible.log && export ANSIBLE_DEBUG=True && export ANSIBLE_REMOTE_TEMP=/mnt/tmp
306+
#export ANSIBLE_LOG_PATH=/tmp/ansible.log && export ANSIBLE_DEBUG=True && export ANSIBLE_REMOTE_TEMP=/mnt/tmp
307307
export ANSIBLE_LOG_PATH=/tmp/ansible.log && export ANSIBLE_REMOTE_TEMP=/mnt/tmp
308308
ansible-playbook -c chroot -i '/mnt,' /tmp/ansible-playbook/ansible/playbook.yml \
309309
--extra-vars '{"nixpkg_mode": true, "debpkg_mode": false, "stage2_nix": false} ' \
310-
--extra-vars "psql_version=psql_${POSTGRES_MAJOR_VERSION}" \
311310
$ARGS
312311
}
313312

stage2-nix-psql.pkr.hcl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,12 +66,12 @@ source "amazon-ebs" "ubuntu" {
6666
region = "${var.region}"
6767
source_ami_filter {
6868
filters = {
69-
name = "${var.ami_name}-${var.postgres-version}-stage-1"
69+
name = "${var.ami_name}-base-stage-1-nightly"
7070
root-device-type = "ebs"
7171
virtualization-type = "hvm"
7272
}
7373
most_recent = true
74-
owners = ["amazon", "self"]
74+
owners = ["self"]
7575
}
7676

7777
communicator = "ssh"

0 commit comments

Comments
 (0)