# Base compose file production deployment of reflex app with Caddy webserver
# providing TLS termination and reverse proxying.
#
# See `compose.prod.yaml` for more robust and performant deployment option.
#
# During build and run, set environment DOMAIN pointing
# to publicly accessible domain where app will be hosted
services:
  app:
    image: local/reflex-app
    environment:
      REFLEX_DB_URL: sqlite:///data/reflex.db
    build:
      context: .
    volumes:
      - db-data:/app/data
      - upload-data:/app/uploaded_files
    restart: always

  webserver:
    environment:
      DOMAIN: ${DOMAIN:-localhost}
    ports:
      - 443:443
      - 80:80 # For acme-challenge via HTTP.
    build:
      context: .
      dockerfile: Caddy.Dockerfile
    volumes:
      - caddy-data:/root/.caddy
    restart: always
    depends_on:
      - app

volumes:
  # SQLite data
  db-data:
  # Uploaded files
  upload-data:
  # TLS keys and certificates
  caddy-data:
