Skip to content

Commit

Permalink
fix: gotrue config persistence for AIO (#961)
Browse files Browse the repository at this point in the history
  • Loading branch information
pcnc committed May 14, 2024
1 parent 6f5b25f commit 77b2979
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 12 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
.DS_Store
.python-version
.mise.toml
venv/
*.swp
docker/cache/

ansible/image-manifest*.json
testinfra-aio-container-logs.log

# Byte-compiled / optimized / DLL files
__pycache__/
Expand Down
2 changes: 1 addition & 1 deletion common.vars.pkr.hcl
Original file line number Diff line number Diff line change
@@ -1 +1 @@
postgres-version = "15.1.1.49"
postgres-version = "15.1.1.50"
2 changes: 1 addition & 1 deletion docker/all-in-one/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
ARG postgres_version=15.1.1.24
ARG postgres_version=15.1.1.49

ARG pgbouncer_release=1.18.0
ARG postgrest_release=10.1.2
Expand Down
20 changes: 18 additions & 2 deletions docker/all-in-one/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,23 @@ function enable_lsn_checkpoint_push {
}

function disable_fail2ban {
sed -i "s/command=.*/command=sleep 5/" /etc/supervisor/services/fail2ban.conf
sed -i "s/autostart=.*/autostart=false/" /etc/supervisor/services/fail2ban.conf
sed -i "s/autorestart=.*/autorestart=false/" /etc/supervisor/services/fail2ban.conf
}

function disable_gotrue {
sed -i "s/command=.*/command=sleep 5/" /etc/supervisor/services/gotrue.conf
sed -i "s/autostart=.*/autostart=false/" /etc/supervisor/services/gotrue.conf
sed -i "s/autorestart=.*/autorestart=false/" /etc/supervisor/services/gotrue.conf
}

function disable_pgbouncer {
sed -i "s/command=.*/command=sleep 5/" /etc/supervisor/services/pgbouncer.conf
sed -i "s/autostart=.*/autostart=false/" /etc/supervisor/services/pgbouncer.conf
sed -i "s/autorestart=.*/autorestart=false/" /etc/supervisor/services/pgbouncer.conf
}

function setup_postgres {
tar -xzvf "$INIT_PAYLOAD_PATH" -C / ./etc/postgresql.schema.sql
mv /etc/postgresql.schema.sql /docker-entrypoint-initdb.d/migrations/99-schema.sql
Expand Down Expand Up @@ -285,8 +298,11 @@ if [ "${FAIL2BAN_DISABLED:-}" == "true" ]; then
fi

if [ "${GOTRUE_DISABLED:-}" == "true" ]; then
sed -i "s/autostart=.*/autostart=false/" /etc/supervisor/services/gotrue.conf
sed -i "s/autorestart=.*/autorestart=false/" /etc/supervisor/services/gotrue.conf
disable_gotrue
fi

if [ "${PGBOUNCER_DISABLED:-}" == "true" ]; then
disable_pgbouncer
fi

if [ "${PLATFORM_DEPLOYMENT:-}" == "true" ]; then
Expand Down
4 changes: 2 additions & 2 deletions docker/all-in-one/etc/supervisor/services/pgbouncer.conf
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
command=/usr/sbin/pgbouncer /etc/pgbouncer/pgbouncer.ini
user=pgbouncer
stopsignal=INT
autorestart=true
autostart=true
autorestart=false
autostart=false
stdout_logfile=/var/log/services/pgbouncer.log
redirect_stderr=true
stdout_logfile_maxbytes=10MB
Expand Down
3 changes: 0 additions & 3 deletions docker/all-in-one/healthcheck.sh
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,6 @@ else
kong health
fi

# pgbouncer up
printf \\0 > "/dev/tcp/localhost/$PGBOUNCER_PORT"

# fail2ban up
fail2ban-client status

Expand Down
8 changes: 5 additions & 3 deletions docker/all-in-one/init/configure-gotrue.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,11 @@ if [ "${DATA_VOLUME_MOUNTPOINT}" ]; then
fi

if [ -f "${INIT_PAYLOAD_PATH:-}" ]; then
echo "init gotrue payload"
tar -h --overwrite -xzvf "$INIT_PAYLOAD_PATH" -C / ./etc/gotrue.env
chown -R adminapi:adminapi /etc/gotrue.env
if [ ! -f "${CONFIGURED_FLAG_PATH}" ]; then
echo "init gotrue payload"
tar -h --overwrite -xzvf "$INIT_PAYLOAD_PATH" -C / ./etc/gotrue.env
chown -R adminapi:adminapi /etc/gotrue.env
fi
else
sed -i "s|api_external_url|${API_EXTERNAL_URL:-http://localhost}|g" /etc/gotrue.env
sed -i "s|gotrue_api_host|${GOTRUE_API_HOST:-0.0.0.0}|g" /etc/gotrue.env
Expand Down

0 comments on commit 77b2979

Please sign in to comment.