-
-
Notifications
You must be signed in to change notification settings - Fork 200
Sam/2 stage ami nix #953
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Sam/2 stage ami nix #953
Changes from 114 commits
Commits
Show all changes
116 commits
Select commit
Hold shift + click to select a range
236fe71
feat: WIP multi-stage ami build
samrose 08b6fb2
feat: WIP switch off 2nd phase items
samrose 25e46d6
feat: migrating and adjusting build steps to work with sourcing files
samrose 258136b
feat: use jinja2 files in 2nd stage
samrose 0acebe0
feat: postgis built in our bundle again and matching version we need …
samrose 36a5c3e
feat: cleanup on postgis extension
samrose fe2c90c
feat: make pg_prove an nix installable package in our set
samrose 195c170
Merge branch 'develop' into sam/2-stage-ami-nix
samrose 39f232b
feat: integration of nix with packer/ansible stage2 steps
samrose e83886d
WIP: this build is working up to running unit tests on image
samrose b8f2b22
feat: ansible run unit and migration tests passing!
samrose 5fb6ead
feat: create a nix package for sfcgal
samrose 9f63f35
chore: correct license
samrose 3e9e76c
feat: tmp sourcing from the right flake url for successful build of s…
samrose e82dd6d
feat: retain old and new ansible/packer files until change is complete
samrose 971fb6f
chore: remove very old file no longer in use
samrose 5c46f97
chore: remove deprecated workflow
samrose c15b960
feat: clean up and attach stages in packer
samrose feadaad
chore: deactivate on PR for these while I refactor them, trigger manu…
samrose 76f6606
feat: tying up loose ends on the creation and deployment to staging
samrose 92d96f0
update the version
samrose 6ce6452
fix: rename workflow
samrose ebb97e0
fix: try to get see the workflow appear as an option
samrose 51f05a3
fix: narrow down the vars needed
samrose db21821
fix: use perms in gh runner for ami publishing prior to establishing
samrose faf337a
docs: add some notes about the workflow ordering
samrose 553faca
fix: avoid passing around owner id as this is supported in the
samrose 778ecf6
chore: attempt to trigger ami build
samrose 0fbfb0c
fix: don't pass in ami owner on packer build
samrose b29029e
fix: creator tags for packer
samrose 2db86f7
chore: bump version to trigger build
samrose d6eaed0
chore: bump to trigger
samrose 1f5c12e
fix: fix ssh timeout on ami build
samrose f409b02
fix: ssh interface setting
samrose 2a9474b
fix: try increased timeout
samrose 376f37d
fix: revert timeout
samrose 4747932
fix: try associate_public_ip_address = true
samrose 8706eb0
chore: bump version to re-run build
samrose 81cd221
chore: advance version to trigger image build
samrose 7193125
chore: bump version for rebuild attempt
samrose 0ccedc2
chore: bump version to try to run build in ci
samrose 046474f
fix: stage 1 needs a distinct tag
samrose fbe0983
chore: bump version to trigger re-build
samrose a528f70
fix: dealing with locales in stages
samrose 5cabc64
chore: bump version to trigger the build
samrose 5cf08dd
fix: rm server.key settings
samrose 47f2703
fix: correct perms on the parnet directory for this key file
samrose 251ec25
fix: also need perms on the parent dir for the key file
samrose 6aebe6d
fix: sorting out the linux groups that the postgres user belongs to
samrose 2fb3426
chore: bump version for build
samrose caf2f14
fix: jsut append: no to constrain groups
samrose 741fde9
get the group creation into the right place
samrose 7dedb19
fix: some programs are looking for items in /usr/bin
samrose 8d21818
fix: just link psql
samrose b6c40f4
feat: make sure postgres user not part of "users" group
samrose 6996c54
fix: trying in second stage
samrose fe206a3
fix: move command to the right stage
samrose 4678636
fix: try to remove group at the end of build
samrose d6338b9
chore: check if postgres user member of "users" group
samrose ec27e73
chore: bump version
samrose 73fa7f5
fix: do not try to remove yet, just check if postgres user is in user…
samrose a22335b
chore: try to see what group the user is part of at end of build
samrose 2cfe394
chore: run user check on both stages
samrose ed0464f
feat: attempt to use command directly to create user and group
samrose 7744315
fix: user add command route
samrose ff83fba
chore: bump version
samrose 26758c1
fix: use correct flag on group add
samrose 5df9ec8
chore: command formatting
samrose 80af04e
fix: explicit group add for each group after user created
samrose 4067a82
chore: trigger build
samrose 8ec33d5
chore: trigger build
samrose d1cd802
fix: use this approach to prevent failure
samrose 4ff8846
fix: correct flag
samrose 77bb52c
chore: trigger build
samrose 76a6a01
fix: update vars to keep in sunc with dev branch
samrose f2c5adb
chore: tmp install osquery
samrose 6075aca
chore: bump to trigger build
samrose 53953ce
chore: bump to trigger build
samrose 9bd0f53
feat: tmp install osquery, check all permissions, remove script and o…
samrose e7d6b35
chore: move commands to the proper stage
samrose 7d4dc0b
fix: source file from upload
samrose 4b17691
fix: try to run from /tmp dir
samrose 2fa9435
fix: bring dep into path
samrose b3cd55a
fix: typo
samrose b535cf3
feat: also check nixbld user groups
samrose 0923ece
fix: merge conflict resolve
samrose c4ba080
chore: bump auth version to fix merge conflict
samrose 09e31e4
chore: bump auth version
samrose 70a3f8e
chore: cleaning up and triggering build
samrose ed9225d
chore: sync up go true versions
samrose 5af81eb
chore: rm TODO comments on done items
samrose 72ccd63
chore: trigger ami build with gotrue changes
samrose 3c8f683
fix: syncing source of kong with develop branch
samrose a2f566a
Sam/pljava nix (#976)
samrose 49cc9fe
Bump supautils version (#989)
olirice e09976e
chore: bump version
samrose 26f193a
chore: bump version
samrose f519287
fix: resolve deps and congif for pljava
samrose fe4ec8d
fix: cleanup
samrose fd609d6
chore: ensure target dir exists
samrose ab55895
fix: It was decided to leave pljava disabled at https://github.com/su…
samrose 91d0f67
ore: bump version
samrose 92067bc
chore: keep package but not configure for use in AMI
samrose ae51796
chore: bump version
samrose 6f43499
chore: must totally deactivate pljava package
samrose 1ecceca
chore: fixing merge conflict
samrose 30e29ad
chore: resolving merge conflicts
samrose 184dd2c
chore: resolve merge conflict
samrose 161ef63
chore: resolve merge conflict
samrose a301311
chore: resolve merge conflict
samrose 319b724
chore: bump version
samrose f0c49ee
chore: merge conflixts
samrose 2e5cc84
chore: bump version
samrose 30bb692
chore: fix gh action workflow so it checks out correct commit
samrose 8e8c8b2
Revert "Bump supautils version (#989)"
samrose e72391d
Revert "chore: sync up go true versions"
samrose File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 {} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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: | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
|
||
- 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 |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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 somehowThere was a problem hiding this comment.
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