Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
116 commits
Select commit Hold shift + click to select a range
236fe71
feat: WIP multi-stage ami build
samrose Apr 19, 2024
08b6fb2
feat: WIP switch off 2nd phase items
samrose Apr 20, 2024
25e46d6
feat: migrating and adjusting build steps to work with sourcing files
samrose Apr 22, 2024
258136b
feat: use jinja2 files in 2nd stage
samrose Apr 22, 2024
0acebe0
feat: postgis built in our bundle again and matching version we need …
samrose Apr 23, 2024
36a5c3e
feat: cleanup on postgis extension
samrose Apr 23, 2024
fe2c90c
feat: make pg_prove an nix installable package in our set
samrose Apr 23, 2024
195c170
Merge branch 'develop' into sam/2-stage-ami-nix
samrose Apr 23, 2024
39f232b
feat: integration of nix with packer/ansible stage2 steps
samrose Apr 25, 2024
e83886d
WIP: this build is working up to running unit tests on image
samrose Apr 27, 2024
b8f2b22
feat: ansible run unit and migration tests passing!
samrose Apr 29, 2024
5fb6ead
feat: create a nix package for sfcgal
samrose Apr 30, 2024
9f63f35
chore: correct license
samrose May 1, 2024
3e9e76c
feat: tmp sourcing from the right flake url for successful build of s…
samrose May 1, 2024
e82dd6d
feat: retain old and new ansible/packer files until change is complete
samrose May 1, 2024
971fb6f
chore: remove very old file no longer in use
samrose May 1, 2024
5c46f97
chore: remove deprecated workflow
samrose May 1, 2024
c15b960
feat: clean up and attach stages in packer
samrose May 2, 2024
feadaad
chore: deactivate on PR for these while I refactor them, trigger manu…
samrose May 3, 2024
76f6606
feat: tying up loose ends on the creation and deployment to staging
samrose May 3, 2024
92d96f0
update the version
samrose May 3, 2024
6ce6452
fix: rename workflow
samrose May 3, 2024
ebb97e0
fix: try to get see the workflow appear as an option
samrose May 3, 2024
51f05a3
fix: narrow down the vars needed
samrose May 3, 2024
db21821
fix: use perms in gh runner for ami publishing prior to establishing
samrose May 6, 2024
faf337a
docs: add some notes about the workflow ordering
samrose May 6, 2024
553faca
fix: avoid passing around owner id as this is supported in the
samrose May 6, 2024
778ecf6
chore: attempt to trigger ami build
samrose May 6, 2024
0fbfb0c
fix: don't pass in ami owner on packer build
samrose May 6, 2024
b29029e
fix: creator tags for packer
samrose May 6, 2024
2db86f7
chore: bump version to trigger build
samrose May 6, 2024
d6eaed0
chore: bump to trigger
samrose May 6, 2024
1f5c12e
fix: fix ssh timeout on ami build
samrose May 6, 2024
f409b02
fix: ssh interface setting
samrose May 6, 2024
2a9474b
fix: try increased timeout
samrose May 6, 2024
376f37d
fix: revert timeout
samrose May 6, 2024
4747932
fix: try associate_public_ip_address = true
samrose May 6, 2024
8706eb0
chore: bump version to re-run build
samrose May 7, 2024
81cd221
chore: advance version to trigger image build
samrose May 7, 2024
7193125
chore: bump version for rebuild attempt
samrose May 7, 2024
0ccedc2
chore: bump version to try to run build in ci
samrose May 7, 2024
046474f
fix: stage 1 needs a distinct tag
samrose May 7, 2024
fbe0983
chore: bump version to trigger re-build
samrose May 7, 2024
a528f70
fix: dealing with locales in stages
samrose May 13, 2024
5cabc64
chore: bump version to trigger the build
samrose May 13, 2024
5cf08dd
fix: rm server.key settings
samrose May 13, 2024
47f2703
fix: correct perms on the parnet directory for this key file
samrose May 13, 2024
251ec25
fix: also need perms on the parent dir for the key file
samrose May 13, 2024
6aebe6d
fix: sorting out the linux groups that the postgres user belongs to
samrose May 14, 2024
2fb3426
chore: bump version for build
samrose May 14, 2024
caf2f14
fix: jsut append: no to constrain groups
samrose May 14, 2024
741fde9
get the group creation into the right place
samrose May 14, 2024
7dedb19
fix: some programs are looking for items in /usr/bin
samrose May 14, 2024
8d21818
fix: just link psql
samrose May 14, 2024
b6c40f4
feat: make sure postgres user not part of "users" group
samrose May 15, 2024
6996c54
fix: trying in second stage
samrose May 15, 2024
fe206a3
fix: move command to the right stage
samrose May 15, 2024
4678636
fix: try to remove group at the end of build
samrose May 15, 2024
d6338b9
chore: check if postgres user member of "users" group
samrose May 15, 2024
ec27e73
chore: bump version
samrose May 15, 2024
73fa7f5
fix: do not try to remove yet, just check if postgres user is in user…
samrose May 15, 2024
a22335b
chore: try to see what group the user is part of at end of build
samrose May 15, 2024
2cfe394
chore: run user check on both stages
samrose May 15, 2024
ed0464f
feat: attempt to use command directly to create user and group
samrose May 15, 2024
7744315
fix: user add command route
samrose May 15, 2024
ff83fba
chore: bump version
samrose May 15, 2024
26758c1
fix: use correct flag on group add
samrose May 15, 2024
5df9ec8
chore: command formatting
samrose May 15, 2024
80af04e
fix: explicit group add for each group after user created
samrose May 15, 2024
4067a82
chore: trigger build
samrose May 15, 2024
8ec33d5
chore: trigger build
samrose May 15, 2024
d1cd802
fix: use this approach to prevent failure
samrose May 15, 2024
4ff8846
fix: correct flag
samrose May 15, 2024
77bb52c
chore: trigger build
samrose May 16, 2024
76a6a01
fix: update vars to keep in sunc with dev branch
samrose May 17, 2024
f2c5adb
chore: tmp install osquery
samrose May 21, 2024
6075aca
chore: bump to trigger build
samrose May 21, 2024
53953ce
chore: bump to trigger build
samrose May 21, 2024
9bd0f53
feat: tmp install osquery, check all permissions, remove script and o…
samrose May 21, 2024
e7d6b35
chore: move commands to the proper stage
samrose May 21, 2024
7d4dc0b
fix: source file from upload
samrose May 21, 2024
4b17691
fix: try to run from /tmp dir
samrose May 21, 2024
2fa9435
fix: bring dep into path
samrose May 21, 2024
b3cd55a
fix: typo
samrose May 21, 2024
b535cf3
feat: also check nixbld user groups
samrose May 21, 2024
0923ece
fix: merge conflict resolve
samrose May 22, 2024
c4ba080
chore: bump auth version to fix merge conflict
samrose Jun 3, 2024
09e31e4
chore: bump auth version
samrose Jun 3, 2024
70a3f8e
chore: cleaning up and triggering build
samrose Jun 6, 2024
ed9225d
chore: sync up go true versions
samrose Jun 11, 2024
5af81eb
chore: rm TODO comments on done items
samrose Jun 11, 2024
72ccd63
chore: trigger ami build with gotrue changes
samrose Jun 11, 2024
3c8f683
fix: syncing source of kong with develop branch
samrose Jun 11, 2024
a2f566a
Sam/pljava nix (#976)
samrose May 21, 2024
49cc9fe
Bump supautils version (#989)
olirice Jun 4, 2024
e09976e
chore: bump version
samrose Jun 11, 2024
26f193a
chore: bump version
samrose Jun 11, 2024
f519287
fix: resolve deps and congif for pljava
samrose Jun 12, 2024
fe4ec8d
fix: cleanup
samrose Jun 12, 2024
fd609d6
chore: ensure target dir exists
samrose Jun 12, 2024
ab55895
fix: It was decided to leave pljava disabled at https://github.com/su…
samrose Jun 12, 2024
91d0f67
ore: bump version
samrose Jun 12, 2024
92067bc
chore: keep package but not configure for use in AMI
samrose Jun 12, 2024
ae51796
chore: bump version
samrose Jun 12, 2024
6f43499
chore: must totally deactivate pljava package
samrose Jun 12, 2024
1ecceca
chore: fixing merge conflict
samrose Jun 12, 2024
30e29ad
chore: resolving merge conflicts
samrose Jun 12, 2024
184dd2c
chore: resolve merge conflict
samrose Jun 12, 2024
161ef63
chore: resolve merge conflict
samrose Jun 12, 2024
a301311
chore: resolve merge conflict
samrose Jun 12, 2024
319b724
chore: bump version
samrose Jun 12, 2024
f0c49ee
chore: merge conflixts
samrose Jun 12, 2024
2e5cc84
chore: bump version
samrose Jun 12, 2024
30bb692
chore: fix gh action workflow so it checks out correct commit
samrose Jun 12, 2024
8e8c8b2
Revert "Bump supautils version (#989)"
samrose Jun 24, 2024
e72391d
Revert "chore: sync up go true versions"
samrose Jun 24, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
121 changes: 121 additions & 0 deletions .github/workflows/ami-release-nix.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
name: Release AMI Nix

on:
push:
branches:
- sam/2-stage-ami-nix
paths:
- '.github/workflows/ami-release-nix.yml'
- 'common-nix.vars.pkr.hcl'
workflow_dispatch:

jobs:
build:
strategy:
matrix:
include:
- runner: arm-runner
arch: arm64
ubuntu_release: focal
ubuntu_version: 20.04
mcpu: neoverse-n1
runs-on: ${{ matrix.runner }}
timeout-minutes: 150
permissions:
contents: write
packages: write
id-token: write

steps:
- name: Checkout Repo
uses: actions/checkout@v3

- name: Run checks if triggered manually
if: ${{ github.event_name == 'workflow_dispatch' }}
# Update `ci.yaml` too if changing constraints.
run: |
SUFFIX=$(sed -E 's/postgres-version = "[0-9\.]+(.*)"/\1/g' common-nix.vars.pkr.hcl)
if [[ -z $SUFFIX ]] ; then
echo "Version must include non-numeric characters if built manually."
exit 1
fi

# extensions are build in nix prior to this step
# so we can just use the binaries from the nix store
# for postgres, extensions and wrappers

- name: Build AMI stage 1
run: |
packer init amazon-arm64-nix.pkr.hcl
GIT_SHA=${{github.sha}}
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=" amazon-arm64-nix.pkr.hcl

- name: Build AMI stage 2
run: |
packer init stage2-nix-psql.pkr.hcl
GIT_SHA=${{github.sha}}
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" stage2-nix-psql.pkr.hcl

- name: Grab release version
id: process_release_version
run: |
VERSION=$(sed -e 's/postgres-version = "\(.*\)"/\1/g' common-nix.vars.pkr.hcl)
echo "version=$VERSION" >> "$GITHUB_OUTPUT"

- name: configure aws credentials - staging
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: ${{ secrets.DEV_AWS_ROLE }}
aws-region: "us-east-1"

- name: Upload software manifest to s3 staging
run: |
cd ansible
ansible-playbook -i localhost \
-e "ami_release_version=${{ steps.process_release_version.outputs.version }}" \
-e "internal_artifacts_bucket=${{ secrets.ARTIFACTS_BUCKET }}" \
manifest-playbook.yml


#Our self hosted github runner already has permissions to publish images
#but they're limited to only that;
#so if we want s3 access we'll need to config credentials with the below steps
# (which overwrites existing perms) after the ami build

- name: configure aws credentials - prod
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: ${{ secrets.PROD_AWS_ROLE }}
aws-region: "us-east-1"

- name: Upload software manifest to s3 prod
run: |
cd ansible
ansible-playbook -i localhost \
-e "ami_release_version=${{ steps.process_release_version.outputs.version }}" \
-e "internal_artifacts_bucket=${{ secrets.PROD_ARTIFACTS_BUCKET }}" \
manifest-playbook.yml



- name: Create release
uses: softprops/action-gh-release@v1
with:
name: ${{ steps.process_release_version.outputs.version }}
tag_name: ${{ steps.process_release_version.outputs.version }}
target_commitish: ${{github.sha}}

- name: Slack Notification on Failure
if: ${{ failure() }}
uses: rtCamp/action-slack-notify@v2
env:
SLACK_WEBHOOK: ${{ secrets.SLACK_NOTIFICATIONS_WEBHOOK }}
SLACK_USERNAME: 'gha-failures-notifier'
SLACK_COLOR: 'danger'
SLACK_MESSAGE: 'Building Postgres AMI failed'
SLACK_FOOTER: ''

- name: Cleanup resources on build cancellation
if: ${{ cancelled() }}
run: |
aws ec2 describe-instances --filters "Name=tag:packerExecutionId,Values=${GITHUB_RUN_ID}" --query "Reservations[].Instances[].InstanceId" --output text | xargs -n 1 -I {} aws ec2 terminate-instances --instance-ids {}
6 changes: 5 additions & 1 deletion .github/workflows/nix-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,11 @@ jobs:
steps:

- name: Check out code
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.ref || github.ref }}
fetch-depth: 0
fetch-tags: true
- name: aws-creds
uses: aws-actions/configure-aws-credentials@v4
with:
Expand Down
52 changes: 0 additions & 52 deletions .github/workflows/nix-cache-upload.yml

This file was deleted.

2 changes: 1 addition & 1 deletion .github/workflows/testinfra.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: Testinfra Integration Tests

on:
pull_request:
#pull_request:
workflow_dispatch:

jobs:
Expand Down
117 changes: 117 additions & 0 deletions .github/workflows/text-nix.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
name: Test Database

on:
# push:
# branches:
# - develop
# pull_request:
workflow_dispatch:

jobs:
build:
strategy:
matrix:
include:
- runner: [self-hosted, X64]
arch: amd64
- runner: arm-runner
arch: arm64
runs-on: ${{ matrix.runner }}
timeout-minutes: 180
env:
POSTGRES_PORT: 5478
POSTGRES_PASSWORD: password
steps:
- uses: actions/checkout@v3
- id: args
uses: mikefarah/yq@master
with:
cmd: yq 'to_entries | map(select(.value|type == "!!str")) | map(.key + "=" + .value) | join("\n")' 'ansible/vars.yml'

- run: docker context create builders
- uses: docker/setup-buildx-action@v3
with:
endpoint: builders
- uses: docker/build-push-action@v5
with:
load: true
context: .
target: production
build-args: |
${{ steps.args.outputs.result }}
tags: samrose/nix-experimental-postgresql-15-aarch64-linux:latest
cache-from: |
type=gha,scope=${{ github.ref_name }}-latest-${{ matrix.arch }}
type=gha,scope=${{ github.base_ref }}-latest-${{ matrix.arch }}
cache-to: type=gha,mode=max,scope=${{ github.ref_name }}-latest-${{ matrix.arch }}

- name: Start Postgres
run: |
docker run --rm --pull=never \
-e POSTGRES_PASSWORD=${{ env.POSTGRES_PASSWORD }} \
-p ${{ env.POSTGRES_PORT }}:5432 \
--name supabase_postgres \
-d supabase/postgres:latest
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't this testing an upstream build, rather than the one build locally?

Would prefer to also use an exact version string rather than latest, just in case it starts falling back to a public image somehow

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This (and all docker/docker-aio work) is going to be moved to PR that will follow #1012


- name: Install psql
run: |
sudo apt update
sudo apt install -y --no-install-recommends postgresql-client

- name: Install pg_prove
run: sudo cpan -T TAP::Parser::SourceHandler::pgTAP
env:
SHELL: /bin/bash

- name: Wait for healthy database
run: |
count=0
until [ "$(docker inspect -f '{{.State.Health.Status}}' "$container")" == "healthy" ]; do
exit=$?
count=$((count + 1))
if [ $count -ge "$retries" ]; then
echo "Retry $count/$retries exited $exit, no more retries left."
docker stop -t 2 "$container"
return $exit
fi
sleep 1;
done;
echo "$container container is healthy"
env:
retries: 20
container: supabase_postgres

- name: Run tests
run: pg_prove migrations/tests/test.sql
env:
PGHOST: localhost
PGPORT: ${{ env.POSTGRES_PORT }}
PGDATABASE: postgres
PGUSER: supabase_admin
PGPASSWORD: ${{ env.POSTGRES_PASSWORD }}

- name: Check migrations are idempotent
run: |
for sql in ./migrations/db/migrations/*.sql; do
echo "$0: running $sql"
psql -v ON_ERROR_STOP=1 --no-password --no-psqlrc -f "$sql"
done
env:
PGHOST: localhost
PGPORT: ${{ env.POSTGRES_PORT }}
PGDATABASE: postgres
PGUSER: supabase_admin
PGPASSWORD: ${{ env.POSTGRES_PASSWORD }}

schema:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: verify schema.sql is committed
run: |
docker compose -f migrations/docker-compose.yaml up db dbmate --abort-on-container-exit
if ! git diff --ignore-space-at-eol --exit-code --quiet migrations/schema.sql; then
echo "Detected uncommitted changes after build. See status below:"
git diff
exit 1
fi
Loading