Skip to content

Commit e2adbed

Browse files
authored
chore: update adminapi; persist scripts for AIO image (#676)
* chore: trigger build * chore: trigger build * fix: pgbouncer config perms * chore: fix shutdown script * chore: bump adminapi; extra configs * chore: bump adminapi; extra configs * chore: create directories before linking
1 parent 8390c6a commit e2adbed

9 files changed

+51
-11
lines changed

ansible/vars.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ postgres_exporter_release_checksum:
4141
arm64: sha256:d869c16791481dc8475487ad84ae4371a63f9b399898ca1c666eead5cccf7182
4242
amd64: sha256:ff541bd3ee19c0ae003d71424a75edfcc8695e828dd20d5b4555ce433c89d60b
4343

44-
adminapi_release: 0.44.3
44+
adminapi_release: 0.45.1
4545
adminmgr_release: 0.5.0
4646

4747
# Postgres Extensions

common.vars.pkr.hcl

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
postgres-version = "15.1.0.96"
1+
postgres-version = "15.1.0.97"

docker/all-in-one/Dockerfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ ARG pgbouncer_release=1.18.0
44
ARG postgrest_release=10.1.2
55
ARG gotrue_release=2.47.0
66
ARG kong_release=2.8.1
7-
ARG adminapi_release=0.44.3
7+
ARG adminapi_release=0.45.1
88
ARG adminmgr_release=0.5.0
99
ARG vector_release=0.22.3
1010
ARG postgres_exporter_release=0.9.0

docker/all-in-one/entrypoint.sh

+3-4
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ function enable_swap {
4747
PG_CONF=/etc/postgresql/postgresql.conf
4848
SUPERVISOR_CONF=/etc/supervisor/supervisord.conf
4949

50+
DATA_VOLUME_MOUNTPOINT=${DATA_VOLUME_MOUNTPOINT:-/data}
5051
export CONFIGURED_FLAG_PATH=${CONFIGURED_FLAG_PATH:-$DATA_VOLUME_MOUNTPOINT/machine.configured}
5152

5253
function setup_postgres {
@@ -85,6 +86,8 @@ function setup_postgres {
8586
$PG_CONF
8687

8788
if [ "${DATA_VOLUME_MOUNTPOINT}" ]; then
89+
/opt/supabase-admin-api optimize db --destination-config-file-path /etc/postgresql-custom/generated-optimizations.conf
90+
8891
# Preserve postgresql configs across restarts
8992
POSTGRESQL_CUSTOM_DIR="${DATA_VOLUME_MOUNTPOINT}/etc/postgresql-custom"
9093

@@ -117,10 +120,6 @@ function setup_postgres {
117120
chmod g+rx "/etc/wal-g"
118121
chmod g+rx "${WALG_CONF_DIR}"
119122
fi
120-
121-
# TODO: define instance size and type for running optimizations
122-
# /opt/supabase-admin-api optimize db --destination-config-file-path /etc/postgresql-custom/generated-optimizations.conf
123-
# /opt/supabase-admin-api optimize pgbouncer --destination-config-file-path /etc/pgbouncer-custom/generated-optimizations.ini
124123
}
125124

126125
function setup_credentials {

docker/all-in-one/init/configure-adminapi.sh

+13
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,19 @@ set -eou pipefail
44
ADMIN_API_CONF=/etc/adminapi/adminapi.yaml
55
touch /var/log/services/adminapi.log
66

7+
ADMINAPI_CUSTOM_DIR="${DATA_VOLUME_MOUNTPOINT}/etc/adminapi"
8+
mkdir -p "${ADMINAPI_CUSTOM_DIR}"
9+
if [ ! -f "${CONFIGURED_FLAG_PATH}" ]; then
10+
echo "Copying existing custom adminapi config from /etc/adminapi to ${ADMINAPI_CUSTOM_DIR}"
11+
cp -R "/etc/adminapi/." "${ADMINAPI_CUSTOM_DIR}/"
12+
fi
13+
14+
rm -rf "/etc/adminapi"
15+
ln -s "${ADMINAPI_CUSTOM_DIR}" "/etc/adminapi"
16+
chown -R adminapi:adminapi "/etc/adminapi"
17+
chown -R adminapi:adminapi "${ADMINAPI_CUSTOM_DIR}"
18+
chmod g+rx "${ADMINAPI_CUSTOM_DIR}"
19+
720
if [ -f "${INIT_PAYLOAD_PATH:-}" ]; then
821
echo "init adminapi payload"
922
tar -xzvf "$INIT_PAYLOAD_PATH" -C / ./etc/adminapi/adminapi.yaml

docker/all-in-one/init/configure-gotrue.sh

+13
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,19 @@ sed -i "s|gotrue_api_host|${GOTRUE_API_HOST:-0.0.0.0}|g" /etc/gotrue.env
77
sed -i "s|gotrue_site_url|$GOTRUE_SITE_URL|g" /etc/gotrue.env
88
sed -i "s|gotrue_jwt_secret|$JWT_SECRET|g" /etc/gotrue.env
99

10+
GOTRUE_CUSTOM_DIR="${DATA_VOLUME_MOUNTPOINT}/etc/gotrue"
11+
mkdir -p "${GOTRUE_CUSTOM_DIR}"
12+
if [ ! -f "${CONFIGURED_FLAG_PATH}" ]; then
13+
echo "Copying existing custom GoTrue config from /etc/gotrue to ${GOTRUE_CUSTOM_DIR}"
14+
cp -R "/etc/gotrue/." "${GOTRUE_CUSTOM_DIR}/"
15+
fi
16+
17+
rm -rf "/etc/gotrue"
18+
ln -s "${GOTRUE_CUSTOM_DIR}" "/etc/gotrue"
19+
chown -R adminapi:adminapi "/etc/gotrue"
20+
chown -R adminapi:adminapi "${GOTRUE_CUSTOM_DIR}"
21+
chmod g+rx "${GOTRUE_CUSTOM_DIR}"
22+
1023
if [ -f "${INIT_PAYLOAD_PATH:-}" ]; then
1124
echo "init gotrue payload"
1225
tar -xzvf "$INIT_PAYLOAD_PATH" -C / ./etc/gotrue.env

docker/all-in-one/init/configure-pgbouncer.sh

+3-1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ if [ -f "${INIT_PAYLOAD_PATH:-}" ]; then
1414
fi
1515

1616
if [ "${DATA_VOLUME_MOUNTPOINT}" ]; then
17+
/opt/supabase-admin-api optimize pgbouncer --destination-config-file-path /etc/pgbouncer-custom/generated-optimizations.ini
18+
1719
# Preserve pgbouncer configs across restarts
1820
PGBOUNCER_CUSTOM_DIR="${DATA_VOLUME_MOUNTPOINT}/etc/pgbouncer-custom"
1921

@@ -28,5 +30,5 @@ if [ "${DATA_VOLUME_MOUNTPOINT}" ]; then
2830
ln -s "${PGBOUNCER_CUSTOM_DIR}" "/etc/pgbouncer-custom"
2931
chown -R pgbouncer:pgbouncer "/etc/pgbouncer-custom"
3032
chown -R pgbouncer:pgbouncer "${PGBOUNCER_CUSTOM_DIR}"
31-
chmod g+rx "${PGBOUNCER_CUSTOM_DIR}"
33+
chmod -R g+rx "${PGBOUNCER_CUSTOM_DIR}"
3234
fi

docker/all-in-one/init/configure-postgrest.sh

+15-2
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,26 @@ sed -i "s|pgrst_db_extra_search_path|${PGRST_DB_SCHEMAS:-public,extensions}|g" /
1111
sed -i "s|pgrst_db_anon_role|${PGRST_DB_ANON_ROLE:-anon}|g" /etc/postgrest/base.conf
1212
sed -i "s|pgrst_jwt_secret|$JWT_SECRET|g" /etc/postgrest/base.conf
1313

14+
POSTGREST_CUSTOM_DIR="${DATA_VOLUME_MOUNTPOINT}/etc/postgrest"
15+
mkdir -p "${POSTGREST_CUSTOM_DIR}"
16+
if [ ! -f "${CONFIGURED_FLAG_PATH}" ]; then
17+
echo "Copying existing custom PostgREST config from /etc/postgrest/ to ${POSTGREST_CUSTOM_DIR}"
18+
cp -R "/etc/postgrest/." "${POSTGREST_CUSTOM_DIR}/"
19+
fi
20+
21+
rm -rf "/etc/postgrest"
22+
ln -s "${POSTGREST_CUSTOM_DIR}" "/etc/postgrest"
23+
chown -R postgrest:postgrest "/etc/postgrest"
24+
chown -R postgrest:postgrest "${POSTGREST_CUSTOM_DIR}"
25+
chmod g+rx "${POSTGREST_CUSTOM_DIR}"
26+
1427
if [ -f "${INIT_PAYLOAD_PATH:-}" ]; then
1528
echo "init postgrest payload"
1629
tar -xzvf "$INIT_PAYLOAD_PATH" -C / ./etc/postgrest/base.conf
1730
chown -R postgrest:postgrest /etc/postgrest
1831
fi
1932

2033
PGRST_CONF=/etc/postgrest/generated.conf
21-
# TODO: merge base config with optimisations
22-
# /opt/supabase-admin-api optimize postgrest --destination-config-file-path $PGRST_CONF
34+
35+
/opt/supabase-admin-api optimize postgrest --destination-config-file-path $PGRST_CONF
2336
cat /etc/postgrest/base.conf >> $PGRST_CONF

docker/all-in-one/shutdown.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ SQL
7272
run_sql -c "ALTER SYSTEM SET log_disconnections = 'on';"
7373
run_sql -c "SELECT pg_reload_conf();"
7474

75-
sleep $((MAX_IDLE_TIME_MINUTES * 60))
75+
sleep $((DEFAULT_MAX_IDLE_TIME_MINUTES * 60))
7676
while true; do
7777
if [ -f "$CONFIG_FILE_PATH" ]; then
7878
source "$CONFIG_FILE_PATH"

0 commit comments

Comments
 (0)