feat(gitea): Migrate configuration from environment variables to app.ini
Some checks failed
🚀 Build & Deploy Image / Determine Build Necessity (push) Failing after 1m12s
🚀 Build & Deploy Image / Build Runtime Base Image (push) Has been skipped
🚀 Build & Deploy Image / Build Docker Image (push) Has been skipped
🚀 Build & Deploy Image / Run Tests & Quality Checks (push) Has been skipped
🚀 Build & Deploy Image / Auto-deploy to Staging (push) Has been skipped
🚀 Build & Deploy Image / Auto-deploy to Production (push) Has been skipped
🧊 Warm Docker Build Cache / Refresh Buildx Caches (push) Has been cancelled
Security Vulnerability Scan / Check for Dependency Changes (push) Successful in 25s
System Maintenance / Run Ansible System Maintenance (push) Successful in 1m8s
📊 Monitor Workflow Performance / Monitor Workflow Performance (push) Failing after 35s
Security Vulnerability Scan / Composer Security Audit (push) Failing after 27s

- Move all Gitea configuration from docker-compose.yml environment variables to app.ini
- Enable Redis cache with proper connection string format (redis://)
- Fix Redis password to use Gitea Redis instance password (gitea_redis_password) instead of application Redis stack password
- Add database connection pool settings to prevent timeout errors
- Configure Redis for cache, session, and queue using app.ini
- Update Ansible task to use correct Redis password for Gitea Redis instance

Benefits:
- Cache now works correctly (environment variables had a bug in Gitea 1.25)
- All settings are versioned in Git
- Better maintainability and reliability
- Configuration follows Gitea documentation recommendations
This commit is contained in:
2025-11-09 16:33:35 +01:00
parent 36ef2a1e2c
commit 9289344379
3 changed files with 81 additions and 82 deletions

View File

@@ -1,12 +1,14 @@
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Gitea Configuration File - Minimal Version
;; Gitea Configuration File
;; Generated by Ansible - DO NOT EDIT MANUALLY
;;
;; IMPORTANT: This is a minimal configuration. Cache, Session, Queue, and other
;; settings are controlled via GITEA__... environment variables in docker-compose.yml
;; which override these settings on every container start.
;; All Gitea configuration is now managed via app.ini instead of
;; environment variables for better reliability and maintainability.
;;
;; Only essential values are included here to skip installation and enable basic functionality.
;; Migration from environment variables to app.ini:
;; - Cache now works correctly (environment variables had a bug in Gitea 1.25)
;; - All settings are versioned in Git
;; - Better documentation and maintainability
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
APP_NAME = Gitea: Git with a cup of tea
@@ -37,6 +39,43 @@ NAME = {{ postgres_db | default('gitea') }}
USER = {{ postgres_user | default('gitea') }}
PASSWD = {{ postgres_password | default('gitea_password') }}
SSL_MODE = disable
# Connection pool settings to prevent "Timeout before authentication" errors
# These limit the number of concurrent connections and prevent connection pool exhaustion
# - MAX_OPEN_CONNS: Maximum number of open connections to the database
# - MAX_IDLE_CONNS: More warm connections to avoid constantly creating new sessions
# - CONN_MAX_LIFETIME: 10 minutes; idle connections are not recycled too quickly
# - CONN_MAX_IDLE_TIME: Clean up connections that are idle for too long
MAX_OPEN_CONNS = 50
MAX_IDLE_CONNS = 30
CONN_MAX_LIFETIME = 600
CONN_MAX_IDLE_TIME = 300
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Cache Configuration (Redis)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
[cache]
ENABLED = true
ADAPTER = redis
# HOST must be a Redis connection string (as per Gitea documentation)
# Format: redis://:password@host:port/db?pool_size=100&idle_timeout=180s
# Using same format as queue CONN_STR for consistency
HOST = redis://:{{ redis_password }}@redis:6379/0?pool_size=100&idle_timeout=180s
# Cache configuration now works correctly in app.ini
# (Environment variables had a bug in Gitea 1.25 that connected to 127.0.0.1:6379 instead of redis:6379)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Session Configuration (Redis)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
[session]
PROVIDER = redis
PROVIDER_CONFIG = network=tcp,addr=redis:6379,password={{ redis_password }},db=0,pool_size=100,idle_timeout=180
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Queue Configuration (Redis)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
[queue]
TYPE = redis
CONN_STR = redis://:{{ redis_password }}@redis:6379/0
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Security Configuration
@@ -54,9 +93,4 @@ DISABLE_REGISTRATION = {{ disable_registration | default(true) | lower }}
;; Actions Configuration
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
[actions]
ENABLED = true
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Cache Configuration
;; NOTE: Cache configuration is controlled via GITEA__cache__ environment variables
;; in docker-compose.yml. Do NOT add [cache] section here, as it may cause conflicts.
ENABLED = true