diff --git a/.env.example b/.env.example index 451b4f7..0a24c2b 100644 --- a/.env.example +++ b/.env.example @@ -1,3 +1,4 @@ PB_ADMIN_EMAIL=admin@example.com PB_ADMIN_PASSWORD=secret-password -PB_URL=http://pocketbase:8080 \ No newline at end of file +PB_URL=http://pocketbase:8080 +PB_DATA_DIR=/pb/pb_data \ No newline at end of file diff --git a/api/docker-entrypoint.sh b/api/docker-entrypoint.sh index d9d7f04..d12a826 100644 --- a/api/docker-entrypoint.sh +++ b/api/docker-entrypoint.sh @@ -12,8 +12,9 @@ set -e # if there are no users yet, create the superuser # we check the sqlite file for any existing record in the users table -if ! sqlite3 "/pb/pb_data/data.db" \ - "SELECT id FROM users WHERE email='${PB_ADMIN_EMAIL}' LIMIT 1;" \ +if [ ! -f "${PB_DATA_DIR}/pb_data.db" ] \ + ! sqlite3 "${PB_DATA_DIR}/data.db" \ + "SELECT id FROM _superusers WHERE email='${PB_ADMIN_EMAIL}' LIMIT 1;" \ | grep -q .; then echo ">>> Creating PocketBase superuser: ${PB_ADMIN_EMAIL}"