Skip to content

⚙️ Configuration

🌎 Environment Variables

.env.example:

## --- Environment variable --- ##
ENV=LOCAL
DEBUG=false
# TZ=UTC
# PYTHONDONTWRITEBYTECODE=1


## --- DB configs --- ##
FOT_DB_HOST=localhost # For local docker-compose: db
FOT_DB_PORT=5432
FOT_DB_USERNAME=fot_admin
FOT_DB_PASSWORD="FOT_DB_PASSWORD123" # !!! CHANGE THIS TO RANDOM PASSWORD !!! # pragma: allowlist secret
FOT_DB_DATABASE=fot_db
# FOT_DB_DSN_URL="postgresql+psycopg://fot_admin:FOT_DB_PASSWORD123@localhost:5432/fot_db" # !!! CHANGE THIS TO REAL DSN URL !!! # pragma: allowlist secret

# FOT_DB_READ_HOST=localhost
# FOT_DB_READ_PORT=5432
# FOT_DB_READ_USERNAME=fot_admin
# FOT_DB_READ_PASSWORD="FOT_DB_PASSWORD123" # !!! CHANGE THIS TO RANDOM PASSWORD !!! # pragma: allowlist secret
# FOT_DB_READ_DATABASE=fot_db
# FOT_DB_READ_DSN_URL="postgresql+psycopg://fot_admin:FOT_DB_PASSWORD123@localhost:5432/fot_db" # !!! CHANGE THIS TO REAL DSN URL !!! # pragma: allowlist secret


## -- API configs -- ##
FOT_API_PORT=8000
# FOT_API_CONFIGS_DIR="/etc/rest-fastapi-orm-template"
# FOT_API_LOGS_DIR="/var/log/rest-fastapi-orm-template"
# FOT_API_DATA_DIR="/var/lib/rest-fastapi-orm-template"
# FOT_API_TMP_DIR="/tmp/rest-fastapi-orm-template"
# FOT_API_VERSION="1"
# FOT_API_PREFIX="/api/v{api_version}"
# FOT_API_DOCS_ENABLED=true
# FOT_API_DOCS_OPENAPI_URL="{api_prefix}/openapi.json"
# FOT_API_DOCS_DOCS_URL="{api_prefix}/docs"
# FOT_API_DOCS_REDOC_URL="{api_prefix}/redoc"



## -- Extra -- ##
# FOT_DB_ECHO_SQL=false
# FOT_DB_ECHO_POOL=false

🐳 Docker compose override

You can copy the following compose.override.yml files to your project root directory (which is compose.yml located) and you can modify it fit your environment. It will override, update or extend the default compose.yml file.

services:
  db:
    # volumes:
    #   - "./volumes/configs/postgresql/docker-entrypoint-initdb.d:/docker-entrypoint-initdb.d:ro"
    #   - "./volumes/storage/postgresql/logs:/var/log/postgresql"
    # deploy:
    #   resources:
    #     limits:
    #       cpus: "1.0"
    #       memory: 1G
    ports:
      - "${FOT_DB_PORT:-5432}:${FOT_DB_PORT:-5432}"
    # healthcheck:
    #   test: ["CMD-SHELL", "pg_isready -U ${FOT_DB_USERNAME:-fot_admin} -d ${FOT_DB_DATABASE:-fot_db}"]
    #   start_period: 15s
    #   start_interval: 1s
    #   interval: 1m
    #   timeout: 5s
    #   retries: 3

  # db-gui:
  #   image: dpage/pgadmin4:latest
  #   depends_on:
  #     db:
  #       condition: service_healthy
  #   restart: unless-stopped
  #   environment:
  #     PGADMIN_DEFAULT_EMAIL: ${FOT_DB_GUI_EMAIL:-fot_admin@example.com}
  #     PGADMIN_DEFAULT_PASSWORD: "${FOT_DB_GUI_PASSWORD:-FOT_DB_GUI_PASSWORD123}"
  #   volumes:
  #     - "/etc/localtime:/etc/localtime:ro"
  #     - "db-gui-data:/var/lib/pgadmin"
  #   deploy:
  #     resources:
  #       limits:
  #         cpus: "0.5"
  #         memory: 512M
  #   ports:
  #     - "${PGADMIN_PORT:-8080}:80"

  api:
    image: bybatkhuu/rest-fastapi-orm-template:latest
    # depends_on:
    #   db:
    #     condition: service_healthy
    environment:
      FOT_DB_HOST: db
    volumes:
      - "./scripts/docker/docker-entrypoint.sh:/usr/local/bin/docker-entrypoint.sh"
      - "./src:/app/rest-fastapi-orm-template"
      - "./volumes/.vscode-server:/home/fot-user/.vscode-server"
    # deploy:
    #   replicas: 3
    #   resources:
    #     limits:
    #       cpus: "0.5"
    #       memory: 512M
    # ports: !override
    #   - "8000-8002:${FOT_API_PORT:-8000}"
    # command: ["/bin/bash"]
    # command: ["-b", "uvicorn api.main:app --host=0.0.0.0 --port=${FOT_API_PORT:-8000} --no-access-log --no-server-header --proxy-headers --forwarded-allow-ips='*' --reload"]
    # healthcheck:
    #   test: ["CMD-SHELL", "curl -f http://localhost:${FOT_API_PORT:-8000}/api/v${FOT_API_VERSION:-1}/ping"]
    #   start_period: 30s
    #   start_interval: 1s
    #   interval: 5m
    #   timeout: 5s
    #   retries: 3


# volumes:
#   db-gui-data:
# services:
#   db:
#     volumes:
#       - "./volumes/configs/postgresql/docker-entrypoint-initdb.d:/docker-entrypoint-initdb.d:ro"
#       - "./volumes/storage/postgresql/logs:/var/log/postgresql"
#     deploy:
#       resources:
#         limits:
#           cpus: "1.0"
#           memory: 1G
#     ports:
#       - "${FOT_DB_PORT:-5432}:${FOT_DB_PORT:-5432}"
#     healthcheck:
#       test: ["CMD-SHELL", "pg_isready -U ${FOT_DB_USERNAME:-fot_admin} -d ${FOT_DB_DATABASE:-fot_db}"]
#       start_period: 15s
#       start_interval: 1s
#       interval: 1m
#       timeout: 5s
#       retries: 3

#   db-gui:
#     image: dpage/pgadmin4:latest
#     depends_on:
#       db:
#         condition: service_healthy
#     restart: unless-stopped
#     environment:
#       PGADMIN_DEFAULT_EMAIL: ${FOT_DB_GUI_EMAIL:-fot_admin@example.com}
#       PGADMIN_DEFAULT_PASSWORD: "${FOT_DB_GUI_PASSWORD:-FOT_DB_GUI_PASSWORD123}"
#     volumes:
#       - "/etc/localtime:/etc/localtime:ro"
#       - "db-gui-data:/var/lib/pgadmin"
#     deploy:
#       resources:
#         limits:
#           cpus: "0.5"
#           memory: 512M
#     ports:
#       - "${PGADMIN_PORT:-8080}:80"

#   api:
#     volumes:
#       - "./volumes/.vscode-server:/home/fot-user/.vscode-server"
#     depends_on:
#       db:
#         condition: service_healthy
#     deploy:
#       replicas: 3
#       resources:
#         limits:
#           cpus: "0.5"
#           memory: 512M
#     ports: !override
#       - "8000-8002:${FOT_API_PORT:-8000}"
#     command: ["/bin/bash"]
#     command: ["-b", "uvicorn api.main:app --host=0.0.0.0 --port=${FOT_API_PORT:-8000} --no-access-log --no-server-header --proxy-headers --forwarded-allow-ips='*'"]
#     healthcheck:
#       test: ["CMD-SHELL", "curl -f http://localhost:${FOT_API_PORT:-8000}/api/v${FOT_API_VERSION:-1}/ping"]
#       start_period: 30s
#       start_interval: 1s
#       interval: 5m
#       timeout: 5s
#       retries: 3


# volumes:
#   db-gui-data: