Skip to content

Commit 2ae639c

Browse files
committed
Clean up build to a functional state
1 parent bcf0e0e commit 2ae639c

File tree

3 files changed

+66
-36
lines changed

3 files changed

+66
-36
lines changed

.github/workflows/qemu-image-build.yml

Lines changed: 54 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ jobs:
2121
steps:
2222
- name: Checkout Repo
2323
uses: actions/checkout@v3
24-
24+
2525
- uses: DeterminateSystems/nix-installer-action@main
2626

2727
- name: Set PostgreSQL versions - only builds pg15 atm
@@ -35,15 +35,7 @@ jobs:
3535
strategy:
3636
matrix:
3737
postgres_version: ${{ fromJson(needs.prepare.outputs.postgres_versions) }}
38-
# include:
39-
# # TODO (darora): change to use non-self-hosted runners, since they now allow nested virtualization
40-
# - runner: arm-runner
41-
# arch: arm64
42-
# ubuntu_release: focal
43-
# ubuntu_version: 20.04
44-
# mcpu: neoverse-n1
45-
runs-on:
46-
group: pg-arm-large
38+
runs-on: arm-native-runner
4739
timeout-minutes: 150
4840
permissions:
4941
contents: write
@@ -56,7 +48,6 @@ jobs:
5648

5749
- uses: DeterminateSystems/nix-installer-action@main
5850

59-
# TODO (darora): might need to temporarily disable this
6051
- name: Run checks if triggered manually
6152
if: ${{ github.event_name == 'workflow_dispatch' }}
6253
run: |
@@ -66,37 +57,55 @@ jobs:
6657
exit 1
6758
fi
6859
60+
- name: enable KVM support
61+
run: |
62+
sudo chown runner /dev/kvm
63+
sudo chmod 666 /dev/kvm
64+
65+
# - name: Install dependencies
66+
# run: |
67+
# sudo apt-get update
68+
# sudo apt-get install -y qemu-efi-aarch64 cloud-image-utils qemu-system-arm qemu-utils
69+
# cd && curl -L "https://releases.hashicorp.com/packer/1.7.8/packer_1.7.8_linux_$(dpkg --print-architecture).zip" -o packer.zip && unzip packer.zip && rm -f packer.zip && sudo mv packer /usr/local/bin/
70+
6971
- name: Set PostgreSQL version environment variable
7072
run: echo "POSTGRES_MAJOR_VERSION=${{ matrix.postgres_version }}" >> $GITHUB_ENV
7173

7274
- name: Generate common-nix.vars.pkr.hcl
7375
run: |
74-
PG_VERSION=$(sudo nix run nixpkgs#yq -- '.postgres_release["postgres'${{ matrix.postgres_version }}'"]' ansible/vars.yml)
76+
curl -L https://github.com/mikefarah/yq/releases/download/v4.45.1/yq_linux_arm64 -o yq
77+
chmod +x yq
78+
PG_VERSION=$(./yq '.postgres_release["postgres'${{ matrix.postgres_version }}'"]' ansible/vars.yml)
7579
PG_VERSION=$(echo $PG_VERSION | tr -d '"') # Remove any surrounding quotes
7680
echo 'postgres-version = "'$PG_VERSION'"' > common-nix.vars.pkr.hcl
77-
echo 'postgres_major_version = "'$POSTGRES_MAJOR_VERSION'"' >> common-nix.vars.pkr.hcl
78-
echo 'postgresql_major = "'$POSTGRES_MAJOR_VERSION'"' >> common-nix.vars.pkr.hcl
81+
echo 'postgres-major-version = "'$POSTGRES_MAJOR_VERSION'"' >> common-nix.vars.pkr.hcl
82+
# echo 'postgresql_major = "'$POSTGRES_MAJOR_VERSION'"' >> common-nix.vars.pkr.hcl
7983
# Ensure there's a newline at the end of the file
8084
echo "" >> common-nix.vars.pkr.hcl
8185
82-
- name: Get binaries
86+
87+
- name: Install dependencies
8388
run: |
84-
hash
89+
sudo apt-get update
90+
sudo apt-get remove -y qemu-efi-aarch64 cloud-image-utils qemu-system-arm qemu-utils
91+
sudo apt-get install -y qemu-efi-aarch64 cloud-image-utils qemu-system-arm qemu-utils
8592
8693
- name: Build QEMU artifact
8794
run: |
8895
make init
8996
GIT_SHA=${{github.sha}}
90-
# TODO (darora): possibly need to install qemu deps here
97+
export PACKER_LOG=1
9198
packer build -var "git_sha=$(UPSTREAM_NIX_GIT_SHA)" -var-file="common-nix.vars.pkr.hcl" qemu-arm64-nix.pkr.hcl
92-
# 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-nix.vars.pkr.hcl" -var "ansible_arguments=-e postgresql_major=${POSTGRES_MAJOR_VERSION}" amazon-arm64-nix.pkr.hcl
9399
94-
# TODO (darora): publishing things is temporarily disabled
95-
# - name: Grab release version
96-
# id: process_release_version
97-
# run: |
98-
# VERSION=$(cat common-nix.vars.pkr.hcl | sed -e 's/postgres-version = "\(.*\)"/\1/g')
99-
# echo "version=$VERSION" >> $GITHUB_OUTPUT
100+
- name: Install dependencies
101+
run: |
102+
ls -lh output-cloudimg/
103+
104+
- name: Grab release version
105+
id: process_release_version
106+
run: |
107+
VERSION=$(cat common-nix.vars.pkr.hcl | sed -e 's/postgres-version = "\(.*\)"/\1/g')
108+
echo "version=$VERSION" >> $GITHUB_OUTPUT
100109
101110
# - name: Create nix flake revision tarball
102111
# run: |
@@ -107,11 +116,27 @@ jobs:
107116
# echo "$GIT_SHA" >> "/tmp/pg_upgrade_bin/${MAJOR_VERSION}/nix_flake_version"
108117
# tar -czf "/tmp/pg_binaries.tar.gz" -C "/tmp/pg_upgrade_bin" .
109118

110-
# - name: configure aws credentials - staging
111-
# uses: aws-actions/configure-aws-credentials@v4
112-
# with:
113-
# role-to-assume: ${{ secrets.DEV_AWS_ROLE }}
114-
# aws-region: "us-east-1"
119+
- name: configure aws credentials - staging
120+
uses: aws-actions/configure-aws-credentials@v4
121+
with:
122+
role-to-assume: ${{ secrets.DEV_AWS_ROLE }}
123+
aws-region: "us-east-1"
124+
125+
- uses: docker/setup-buildx-action@v3
126+
127+
- name: Login to ECR
128+
uses: docker/login-action@v2
129+
with:
130+
registry: public.ecr.aws
131+
132+
- id: build
133+
uses: docker/build-push-action@v5
134+
with:
135+
file: Dockerfile-kubernetes
136+
push: true
137+
tags: public.ecr.aws/w9p6e7k7/supabase/postgres-v3:${{ steps.process_release_version.outputs.version }}
138+
platforms: linux/arm64
139+
context: .
115140

116141
# - name: Upload software manifest to s3 staging
117142
# run: |

Dockerfile-kubernetes

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
FROM alpine:3.21
22

3-
ADD output-cloudimg/packer-cloudimg /disk/focal.qcow2
3+
ADD ./output-cloudimg/packer-cloudimg /disk/focal.qcow2
44

5-
RUN apk add --no-cache qemu-system-aarch64 qemu-img openssh nftables cloud-utils-localds aavmf
5+
RUN apk add --no-cache qemu-system-aarch64 qemu-img openssh-client nftables cloud-utils-localds aavmf
66
# dev stuff
77
# RUN apk add --no-cache iproute2
88

qemu-arm64-nix.pkr.hcl

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,11 @@ variable "postgres-version" {
2121
default = ""
2222
}
2323

24+
variable "postgres-major-version" {
25+
type = string
26+
default = ""
27+
}
28+
2429
variable "git-head-version" {
2530
type = string
2631
default = "unknown"
@@ -63,18 +68,18 @@ build {
6368

6469
source "qemu" "cloudimg" {
6570
boot_wait = "2s"
66-
cpus = 12
71+
cpus = 8
6772
disk_image = true
6873
disk_size = "15G"
6974
format = "qcow2"
7075
headless = true
7176
http_directory = "http"
7277
iso_checksum = "file:https://cloud-images.ubuntu.com/focal/current/SHA256SUMS"
7378
iso_url = "https://cloud-images.ubuntu.com/focal/current/focal-server-cloudimg-arm64.img"
74-
memory = 20000
79+
memory = 40000
7580
qemu_binary = "qemu-system-aarch64"
7681
qemuargs = [
77-
["-machine", "virt"],
82+
["-machine", "virt,gic-version=3"],
7883
["-cpu", "host"],
7984
["-device", "virtio-gpu-pci"],
8085
["-drive", "if=pflash,format=raw,id=ovmf_code,readonly=on,file=/usr/share/AAVMF/AAVMF_CODE.fd"],
@@ -124,9 +129,9 @@ build {
124129

125130
provisioner "shell" {
126131
environment_vars = [
127-
"POSTGRES_MAJOR_VERSION=${var.postgres_major_version}"
132+
"POSTGRES_MAJOR_VERSION=${var.postgres-major-version}",
128133
"POSTGRES_SUPABASE_VERSION=${var.postgres-version}",
129-
"GIT_SHA=${var.git_sha}",
134+
"GIT_SHA=${var.git_sha}"
130135
]
131136
use_env_var_file = true
132137
script = "ebssurrogate/scripts/qemu-bootstrap-nix.sh"

0 commit comments

Comments
 (0)