services:
  web:
    build:
      context: .
    container_name: psalmbordonline-web
    ports:
      # Host:Container
      - "${WEB_PORT:-5000}:5000"
    environment:
      # Flask
      - FLASK_ENV=${FLASK_ENV:-production}
      # The app reads these from env (with sensible defaults in app.py)
      - SECRET_KEY=${SECRET_KEY:-change-me}
      # Use an absolute path inside the container. Note the 4 slashes for sqlite.
      - SQLALCHEMY_DATABASE_URI=${SQLALCHEMY_DATABASE_URI:-sqlite:////instance/liturgie.db}
      # Default admin bootstrap (only created if not existing)
      - ADMIN_USERNAME=${ADMIN_USERNAME:-admin}
      - ADMIN_PASSWORD=${ADMIN_PASSWORD:-admin}
    command:
      # Ensure the SQLite DB + tables exist when running under gunicorn (the __main__
      # block in app.py does not run under gunicorn).
      - sh
      - -c
      - "python init_db.py && gunicorn wsgi:app -b 0.0.0.0:5000"
    volumes:
      # Persist SQLite DB (stored under Flask's instance folder)
      - ./instance:/instance
      # Persist uploaded images/backgrounds
      - ./static/uploads:/static/uploads
    restart: unless-stopped





