-
Notifications
You must be signed in to change notification settings - Fork 1
feat: sync default component images from upstream Supabase #16
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
Merged
Merged
Changes from all commits
Commits
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,60 @@ | ||
| name: Sync Upstream Images | ||
|
|
||
| # Weekly job that pulls component image versions from the upstream Supabase | ||
| # compose file and opens a PR when anything changed. The existing e2e | ||
| # workflow on the PR acts as the compatibility gate for version bumps. | ||
| # | ||
| # Note: PRs created with the default GITHUB_TOKEN do not trigger other | ||
| # workflows (lint, test, e2e). Configure a SYNC_UPSTREAM_TOKEN secret with | ||
| # a PAT (repo scope) so CI runs on the sync PRs automatically. Without it | ||
| # the job falls back to GITHUB_TOKEN and CI must be triggered by closing | ||
| # and reopening the PR. | ||
|
|
||
| on: | ||
| schedule: | ||
| - cron: "0 3 * * 1" | ||
| workflow_dispatch: {} | ||
|
|
||
| permissions: | ||
| contents: write | ||
| pull-requests: write | ||
|
|
||
| jobs: | ||
| sync: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Clone the code | ||
| uses: actions/checkout@v4 | ||
|
|
||
| - name: Setup Go | ||
| uses: actions/setup-go@v5 | ||
| with: | ||
| go-version-file: go.mod | ||
|
|
||
| - name: Sync image versions from upstream | ||
| run: ./hack/sync-upstream-images.sh | ||
|
|
||
| - name: Regenerate CRD schema and run tests | ||
| run: make test | ||
|
|
||
| - name: Create pull request | ||
| uses: peter-evans/create-pull-request@v7 | ||
| with: | ||
| token: ${{ secrets.SYNC_UPSTREAM_TOKEN || secrets.GITHUB_TOKEN }} | ||
| branch: chore/sync-upstream-images | ||
| commit-message: "chore: sync component image versions from upstream Supabase" | ||
| title: "chore: sync component image versions from upstream Supabase" | ||
| body: | | ||
| Automated sync of default component image versions from the | ||
| upstream Supabase compose file: | ||
| https://github.com/supabase/supabase/blob/master/docker/docker-compose.yml | ||
|
|
||
| Updated files: | ||
| - `api/v1alpha1/wellknown_images.go` | ||
| - `api/v1alpha1/supabaseproject_types.go` | ||
| - `helm/supabase-operator/crds/` (regenerated) | ||
|
|
||
| Please review the version changes and make sure the e2e workflow | ||
| passes before merging. Major version jumps (for example Kong) | ||
| may need manual config changes in the component builders. | ||
| delete-branch: true |
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 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 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,24 @@ | ||
| package v1alpha1 | ||
|
|
||
| // Default image versions for Supabase components. | ||
| // | ||
| // This file is the single source of truth for component image defaults. | ||
| // The kubebuilder default markers in supabaseproject_types.go must carry | ||
| // the same values so that the generated CRD schema matches the webhook | ||
| // defaults. Both files are updated together by hack/sync-upstream-images.sh, | ||
| // which reads the upstream compose file: | ||
| // https://github.com/supabase/supabase/blob/master/docker/docker-compose.yml | ||
| const ( | ||
| DefaultKongImage = "kong:2.8.1" | ||
| DefaultAuthImage = "supabase/gotrue:v2.180.0" | ||
| DefaultPostgRESTImage = "postgrest/postgrest:v13.0.7" | ||
| DefaultRealtimeImage = "supabase/realtime:v2.51.11" | ||
| DefaultStorageAPIImage = "supabase/storage-api:v1.32.0" | ||
| DefaultMetaImage = "supabase/postgres-meta:v0.93.1" | ||
| DefaultStudioImage = "supabase/studio:2025.10.01-sha-8460121" | ||
| ) | ||
|
|
||
| // DefaultPostgresImage is used by the database init job only. The operator | ||
| // requires a user provided PostgreSQL, so this image is intentionally not | ||
| // synced from upstream. | ||
| const DefaultPostgresImage = "postgres:15-alpine" |
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,100 @@ | ||
| #!/bin/bash | ||
| set -euo pipefail | ||
|
|
||
| # Sync default component image versions from the upstream Supabase compose file | ||
| # https://github.com/supabase/supabase/blob/master/docker/docker-compose.yml | ||
| # | ||
| # Updates two files that must stay consistent: | ||
| # api/v1alpha1/wellknown_images.go Go constants used by the webhook | ||
| # api/v1alpha1/supabaseproject_types.go kubebuilder default markers | ||
| # Run "make manifests" afterwards to regenerate the CRD schema. | ||
| # | ||
| # Usage: ./hack/sync-upstream-images.sh [REF] | ||
| # REF defaults to master, a tag or commit of supabase/supabase also works. | ||
|
|
||
| UPSTREAM_REPO="https://raw.githubusercontent.com/supabase/supabase" | ||
| REF="${1:-master}" | ||
| COMPOSE_URL="${UPSTREAM_REPO}/${REF}/docker/docker-compose.yml" | ||
|
|
||
| CONSTANTS_FILE="api/v1alpha1/wellknown_images.go" | ||
| TYPES_FILE="api/v1alpha1/supabaseproject_types.go" | ||
|
|
||
| # Format: "compose_service constant_name struct_name" | ||
| # The db service is intentionally not listed, the operator requires a user | ||
| # provided PostgreSQL so DefaultPostgresImage is never synced from upstream. | ||
| MAPPINGS=( | ||
| "kong DefaultKongImage KongConfig" | ||
| "auth DefaultAuthImage AuthConfig" | ||
| "rest DefaultPostgRESTImage PostgRESTConfig" | ||
| "realtime DefaultRealtimeImage RealtimeConfig" | ||
| "storage DefaultStorageAPIImage StorageAPIConfig" | ||
| "meta DefaultMetaImage MetaConfig" | ||
| "studio DefaultStudioImage StudioConfig" | ||
| ) | ||
|
|
||
| compose_file="$(mktemp)" | ||
| trap 'rm -f "$compose_file"' EXIT | ||
|
|
||
| echo "Fetching ${COMPOSE_URL}..." | ||
| curl -fsSL "$COMPOSE_URL" -o "$compose_file" | ||
|
|
||
| lookup_image() { | ||
| awk -v svc="$1" ' | ||
| /^ [a-zA-Z0-9_-]+:$/ { current = substr($1, 1, length($1) - 1) } | ||
| current == svc && $1 == "image:" { print $2; exit } | ||
| ' "$compose_file" | ||
| } | ||
|
|
||
| current_constant() { | ||
| awk -v name="$1" '$1 == name { gsub(/"/, "", $3); print $3; exit }' "$CONSTANTS_FILE" | ||
| } | ||
|
|
||
| update_constant() { | ||
| local name="$1" image="$2" | ||
| sed -E -i.bak "s|(${name}[[:space:]]*=[[:space:]]*)\"[^\"]*\"|\1\"${image}\"|" "$CONSTANTS_FILE" | ||
| rm -f "${CONSTANTS_FILE}.bak" | ||
| } | ||
|
|
||
| update_marker() { | ||
| local struct="$1" image="$2" | ||
| awk -v st="$struct" -v img="$image" ' | ||
| $0 ~ "^type " st " struct" { in_struct = 1 } | ||
| in_struct && /^}/ { in_struct = 0 } | ||
| in_struct && /\+kubebuilder:default="/ && !done { | ||
| sub(/\+kubebuilder:default="[^"]*"/, "+kubebuilder:default=\"" img "\"") | ||
| done = 1 | ||
| } | ||
| { print } | ||
| ' "$TYPES_FILE" > "${TYPES_FILE}.tmp" | ||
| mv "${TYPES_FILE}.tmp" "$TYPES_FILE" | ||
| } | ||
|
|
||
| changed=0 | ||
| for entry in "${MAPPINGS[@]}"; do | ||
| read -r service constant struct <<< "$entry" | ||
|
|
||
| new_image="$(lookup_image "$service")" | ||
| if [ -z "$new_image" ]; then | ||
| echo "ERROR: service '${service}' not found in upstream compose file" >&2 | ||
| exit 1 | ||
| fi | ||
|
|
||
| old_image="$(current_constant "$constant")" | ||
| if [ "$old_image" = "$new_image" ]; then | ||
| echo " = ${service}: ${old_image} (up to date)" | ||
| continue | ||
| fi | ||
|
|
||
| echo " * ${service}: ${old_image} to ${new_image}" | ||
| update_constant "$constant" "$new_image" | ||
| update_marker "$struct" "$new_image" | ||
| changed=1 | ||
| done | ||
|
|
||
| if [ "$changed" -eq 0 ]; then | ||
| echo "All component images are up to date." | ||
| exit 0 | ||
| fi | ||
|
|
||
| gofmt -w "$CONSTANTS_FILE" "$TYPES_FILE" | ||
| echo "Done. Run 'make manifests' to regenerate the CRD schema." | ||
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 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 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 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
Oops, something went wrong.
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.
When a constant already matches the upstream compose image, this branch skips
update_marker, so a stale kubebuilder default marker/CRD can remain stale and the script will still report the service as up to date. That recreates the drift this change is meant to prevent: for resources where Kubernetes applies the CRD default before the webhook, users continue to get the marker value rather than the constant. Consider checking and updating the marker independently of whether the Go constant changed.Useful? React with 👍 / 👎.