Automate Gitea init, NocoDB auto sign-in, and fix prod compose
- Add scripts/gitea-init.sh: runs migrations + creates admin user on first boot, replacing the manual installation wizard - Set GITEA__security__INSTALL_LOCK=true in both compose files - Add NocoDB auth bridge (nginx) + /api/services/nocodb-auth proxy endpoint so the admin iframe auto-authenticates - Update NocoDBPage.tsx to fetch token and use auth bridge flow - Fix docker-compose.prod.yml missing Gitea env vars for API container (GITEA_URL, GITEA_API_TOKEN, GITEA_ADMIN_PASSWORD, etc.) - Pass NC_ADMIN_EMAIL/PASSWORD to API for NocoDB auth proxy - Increase Gitea auto-setup retries from 3 to 6 with admin auth check - Update config.sh non-interactive mode to set GITEA_ADMIN_USER - Include gitea-init.sh in release tarball (build-release.sh) Bunker Admin
This commit is contained in:
@@ -103,7 +103,7 @@ cp "$PROJECT_DIR/api/prisma/init-nocodb-db.sh" "$STAGE_DIR/scripts/"
|
||||
cp "$PROJECT_DIR/api/prisma/init-gancio-db.sh" "$STAGE_DIR/scripts/"
|
||||
|
||||
# Runtime scripts
|
||||
for script in nocodb-init.sh mkdocs-entrypoint.sh backup.sh \
|
||||
for script in nocodb-init.sh gitea-init.sh mkdocs-entrypoint.sh backup.sh \
|
||||
upgrade.sh upgrade-check.sh upgrade-watcher.sh \
|
||||
uninstall.sh test-deployment.sh; do
|
||||
if [[ -f "$PROJECT_DIR/scripts/$script" ]]; then
|
||||
|
||||
54
scripts/gitea-init.sh
Executable file
54
scripts/gitea-init.sh
Executable file
@@ -0,0 +1,54 @@
|
||||
#!/bin/sh
|
||||
# =============================================================================
|
||||
# Gitea Initialization Script
|
||||
# =============================================================================
|
||||
# Replaces the default CMD in the Gitea Docker container.
|
||||
# Runs database migrations, creates the admin user (if credentials are provided
|
||||
# and the user doesn't already exist), then starts the Gitea web server.
|
||||
#
|
||||
# This script is exec'd by /usr/bin/entrypoint, which has already:
|
||||
# - Set up UID/GID
|
||||
# - Created directories with correct permissions
|
||||
# - Converted GITEA__* env vars into /data/gitea/conf/app.ini
|
||||
# =============================================================================
|
||||
set -e
|
||||
|
||||
PREFIX="[gitea-init]"
|
||||
log() { echo "$PREFIX $1"; }
|
||||
|
||||
# --- Step 1: Run database migrations ---
|
||||
log "Running database migrations..."
|
||||
MIGRATE_OK=false
|
||||
for i in $(seq 1 10); do
|
||||
if gitea migrate 2>&1; then
|
||||
MIGRATE_OK=true
|
||||
log "Migrations complete"
|
||||
break
|
||||
fi
|
||||
log "Waiting for database... (attempt $i/10)"
|
||||
sleep 3
|
||||
done
|
||||
|
||||
if [ "$MIGRATE_OK" = false ]; then
|
||||
log "WARNING: Migrations may not have completed — starting anyway"
|
||||
fi
|
||||
|
||||
# --- Step 2: Create admin user if credentials provided ---
|
||||
if [ -n "$GITEA_ADMIN_USER" ] && [ -n "$GITEA_ADMIN_PASSWORD" ] && [ -n "$GITEA_ADMIN_EMAIL" ]; then
|
||||
log "Creating admin user '${GITEA_ADMIN_USER}'..."
|
||||
if gitea admin user create --admin \
|
||||
--username "$GITEA_ADMIN_USER" \
|
||||
--password "$GITEA_ADMIN_PASSWORD" \
|
||||
--email "$GITEA_ADMIN_EMAIL" \
|
||||
--must-change-password false 2>&1; then
|
||||
log "Admin user created successfully"
|
||||
else
|
||||
log "Admin user already exists (or creation skipped)"
|
||||
fi
|
||||
else
|
||||
log "No GITEA_ADMIN_USER/PASSWORD/EMAIL set — skipping admin creation"
|
||||
fi
|
||||
|
||||
# --- Step 3: Start Gitea web server ---
|
||||
log "Starting Gitea web server..."
|
||||
exec gitea web
|
||||
Reference in New Issue
Block a user