Skip to content

Commit

Permalink
devops: Disable unused supabase services
Browse files Browse the repository at this point in the history
  • Loading branch information
jhf committed Dec 9, 2024
1 parent cfa0b38 commit 1686bca
Show file tree
Hide file tree
Showing 7 changed files with 99 additions and 34 deletions.
23 changes: 17 additions & 6 deletions devops/manage-statbus.sh
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,11 @@ case "$action" in
./devops/dotenv --file .env set VERSION=$VERSION
set_profile_arg "$@"

# Conditionally add the --build argument if the profile is 'all'
# Conditionally add the --build argument if the profile is 'all' or 'required'
# since docker compose does not use the --profile to determine
# if a build is required.
build_arg=""
if [ "$profile" = "all" ]; then
if [ "$profile" = "all" ] || [ "$profile" = "required" ]; then
build_arg="--build"
fi

Expand Down Expand Up @@ -393,7 +393,7 @@ EOF
echo " brew install mike-engel/jwt-cli/jwt-cli"
exit 1
fi

export ANON_KEY=$(jwt encode --secret "$JWT_SECRET" "$jwt_anon_payload")
ANON_KEY=$(./devops/dotenv --file $CREDENTIALS_FILE generate ANON_KEY echo $ANON_KEY)

Expand Down Expand Up @@ -725,6 +725,17 @@ EOS
setpath($i | path; $i) # and put in each node, using its original path
) ' supabase_docker/docker-compose.yml | tr -d "'" > docker-compose.supabase_docker.erase-ports.yml

echo Generating docker-compose.supabase_docker.erase-depends_on.yml
yq '(
.. | # recurse through all the nodes
select(has("depends_on")) | # match parents that have volume
(.depends_on) | # select those children
select(.) # filter out nulls
| . |= "!reset []"
) as $i ireduce({}; # using that set of nodes, create a new result map
setpath($i | path; $i) # and put in each node, using its original path
) ' supabase_docker/docker-compose.yml | tr -d "'" > docker-compose.supabase_docker.erase-depends_on.yml

echo Generating docker-compose.supabase_docker.customize-container_name.yml
yq '(
.. | # recurse through all the nodes
Expand All @@ -735,14 +746,14 @@ EOS
setpath($i | path; $i) # and put in each node, using its original path
) ' supabase_docker/docker-compose.yml > docker-compose.supabase_docker.customize-container_name.yml

echo Generating docker-compose.supabase_docker.add-profile.yml
echo Generating docker-compose.supabase_docker.add-all-profile.yml
yq '(
.services[] | # recurse through all service definitions
.profiles = ["all", "not_app"] | # set profiles
.profiles = ["all", "all_not_app"] | # set profiles
(.profiles) # Only retain profiles
) as $i ireduce({}; # using that set of nodes, create a new result map
setpath($i | path; $i) # and put in each node, using its original path
) ' supabase_docker/docker-compose.yml > docker-compose.supabase_docker.add-profile.yml
) ' supabase_docker/docker-compose.yml > docker-compose.supabase_docker.add-all-profile.yml
;;
* )
echo "Unknown action '$action', select one of"
Expand Down
5 changes: 3 additions & 2 deletions docker-compose.app.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,9 @@ services:
ports:
- "${APP_BIND_ADDRESS:-127.0.0.1:3010}:3000"
profiles:
- all
- app
- "all"
- "required"
- "app"
environment:
NEXT_PUBLIC_SUPABASE_ANON_KEY: ${NEXT_PUBLIC_SUPABASE_ANON_KEY}
NEXT_PUBLIC_BROWSER_SUPABASE_URL: ${NEXT_PUBLIC_BROWSER_SUPABASE_URL}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,52 +2,52 @@ services:
studio:
profiles:
- all
- not_app
- all_not_app
kong:
profiles:
- all
- not_app
- all_not_app
auth:
profiles:
- all
- not_app
- all_not_app
rest:
profiles:
- all
- not_app
- all_not_app
realtime:
profiles:
- all
- not_app
- all_not_app
storage:
profiles:
- all
- not_app
- all_not_app
imgproxy:
profiles:
- all
- not_app
- all_not_app
meta:
profiles:
- all
- not_app
- all_not_app
functions:
profiles:
- all
- not_app
- all_not_app
analytics:
profiles:
- all
- not_app
- all_not_app
db:
profiles:
- all
- not_app
- all_not_app
vector:
profiles:
- all
- not_app
- all_not_app
supavisor:
profiles:
- all
- not_app
- all_not_app
21 changes: 21 additions & 0 deletions docker-compose.supabase_docker.add-required-profile.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
services:
studio:
profiles:
- required
- required_not_app
kong:
profiles:
- required
- required_not_app
auth:
profiles:
- required
- required_not_app
rest:
profiles:
- required
- required_not_app
db:
profiles:
- required
- required_not_app
11 changes: 9 additions & 2 deletions docker-compose.supabase_docker.customise.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Adapt Supabase.
services:
auth:
depends_on:
db:
condition: service_healthy
kong:
# Expose API endpoint
ports:
Expand All @@ -12,6 +16,9 @@ services:
# and `select=count(),physical_region_id`
# and uses indices for this.
PGRST_DB_AGGREGATES_ENABLED: true
depends_on:
db:
condition: service_healthy
db:
# Use a custom build with sql_saga extension for temporal tables.
image: ghcr.io/veridit/supabase_postgres:c035263a
Expand Down Expand Up @@ -62,7 +69,7 @@ services:
"--no-verbose",
"--tries=1",
"--spider",
"http://127.0.0.1:5000/status"
"http://127.0.0.1:5000/status",
]
studio:
# Override the address of the healthcheck from localhost that resolves to 127.0.0.1 (IPv4) that studio
Expand All @@ -74,5 +81,5 @@ services:
"CMD",
"node",
"-e",
"require('http').get('http://studio:3000/api/profile', (r) => {if (r.statusCode !== 200) throw new Error(r.statusCode)})"
"require('http').get('http://studio:3000/api/profile', (r) => {if (r.statusCode !== 200) throw new Error(r.statusCode)})",
]
23 changes: 23 additions & 0 deletions docker-compose.supabase_docker.erase-depends_on.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
services:
studio:
depends_on: !reset []
kong:
depends_on: !reset []
auth:
depends_on: !reset []
rest:
depends_on: !reset []
realtime:
depends_on: !reset []
storage:
depends_on: !reset []
meta:
depends_on: !reset []
functions:
depends_on: !reset []
analytics:
depends_on: !reset []
db:
depends_on: !reset []
supavisor:
depends_on: !reset []
24 changes: 13 additions & 11 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,17 @@ include:
# else the mounts of the second path includes are relative
# to the first file loaded.
- path:
# Setup STATBUS Next.js app (frontend + backend)
- "docker-compose.app.yml"
# Setup STATBUS Next.js app (frontend + backend)
- "docker-compose.app.yml"
- path:
# Mirrored from https://github.com/supabase/supabase/tree/master/docker
- "supabase_docker/docker-compose.yml"
# Generated by ./devops/manage-supabase.sh generate-docker-compose-adjustments
- "docker-compose.supabase_docker.erase-ports.yml"
- "docker-compose.supabase_docker.customize-container_name.yml"
- "docker-compose.supabase_docker.add-profile.yml"
# Maintained by STATBUS team.
# Adjust Supabase settings for our docker setup
- "docker-compose.supabase_docker.customise.yml"
# Mirrored from https://github.com/supabase/supabase/tree/master/docker
- "supabase_docker/docker-compose.yml"
# Generated by ./devops/manage-supabase.sh generate-docker-compose-adjustments
- "docker-compose.supabase_docker.erase-ports.yml"
- "docker-compose.supabase_docker.erase-depends_on.yml"
- "docker-compose.supabase_docker.customize-container_name.yml"
- "docker-compose.supabase_docker.add-all-profile.yml"
- "docker-compose.supabase_docker.add-required-profile.yml"
# Maintained by STATBUS team.
# Adjust Supabase settings for our docker setup
- "docker-compose.supabase_docker.customise.yml"

0 comments on commit 1686bca

Please sign in to comment.