⚙️ Configuration
🌎 Environment Variables
## --- Environment variable --- ##
ENV=LOCAL
DEBUG=false
# TZ=UTC
# PYTHONDONTWRITEBYTECODE=1
## -- API configs -- ##
FT_API_PORT=8000
# FT_API_CONFIGS_DIR="/etc/rest-fastapi-template"
# FT_API_LOGS_DIR="/var/log/rest-fastapi-template"
# FT_API_DATA_DIR="/var/lib/rest-fastapi-template"
# FT_API_TMP_DIR="/tmp/rest-fastapi-template"
# FT_API_VERSION="1"
# FT_API_PREFIX="/api/v{api_version}"
# FT_API_DOCS_ENABLED=true
# FT_API_DOCS_OPENAPI_URL="{api_prefix}/openapi.json"
# FT_API_DOCS_DOCS_URL="{api_prefix}/docs"
# FT_API_DOCS_REDOC_URL="{api_prefix}/redoc"
🐳 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.
- For DEVELOPMENT:
compose.override.dev.yml
services:
api:
image: bybatkhuu/rest-fastapi-template:latest
volumes:
- "./scripts/docker/docker-entrypoint.sh:/usr/local/bin/docker-entrypoint.sh"
- "./src:/app/rest-fastapi-template"
- "./volumes/.vscode-server:/home/ft-user/.vscode-server"
# deploy:
# replicas: 3
# resources:
# limits:
# cpus: "0.5"
# memory: 512M
# ports: !override
# - "8000-8002:${FT_API_PORT:-8000}"
# command: ["/bin/bash"]
# command: ["-b", "uvicorn api.main:app --host=0.0.0.0 --port=${FT_API_PORT:-8000} --no-access-log --no-server-header --proxy-headers --forwarded-allow-ips='*' --reload"]
# healthcheck:
# test: ["CMD-SHELL", "curl -f http://localhost:${FT_API_PORT:-8000}/api/v${FT_API_VERSION:-1}/ping"]
# start_period: 30s
# start_interval: 1s
# interval: 5m
# timeout: 5s
# retries: 3
- For DEVELOPMENT with GPU:
compose.override.dev.gpu.yml
services:
api:
image: bybatkhuu/rest-fastapi-template:latest-gpu
runtime: nvidia
build:
args:
BASE_IMAGE: nvidia/cuda:12.6.3-cudnn-runtime-ubuntu24.04
environment:
NVIDIA_VISIBLE_DEVICES: ${NVIDIA_VISIBLE_DEVICES:-all}
CUDA_VISIBLE_DEVICES: ${CUDA_VISIBLE_DEVICES:-all}
volumes:
- "./scripts/docker/docker-entrypoint.sh:/usr/local/bin/docker-entrypoint.sh"
- "./src:/app/rest-fastapi-template"
- "./volumes/.vscode-server:/home/ft-user/.vscode-server"
# deploy:
# replicas: 3
# resources:
# limits:
# cpus: "0.5"
# memory: 512M
# ports: !override
# - "8000-8002:${FT_API_PORT:-8000}"
# command: ["/bin/bash"]
# command: ["-b", "uvicorn api.main:app --host=0.0.0.0 --port=${FT_API_PORT:-8000} --no-access-log --no-server-header --proxy-headers --forwarded-allow-ips='*' --reload"]
# healthcheck:
# test: ["CMD-SHELL", "curl -f http://localhost:${FT_API_PORT:-8000}/api/v${FT_API_VERSION:-1}/ping"]
# start_period: 30s
# start_interval: 1s
# interval: 5m
# timeout: 5s
# retries: 3
- For PRODUCTION:
compose.override.prod.yml
# services:
# api:
# volumes:
# - "./volumes/.vscode-server:/home/ft-user/.vscode-server"
# deploy:
# replicas: 3
# resources:
# limits:
# cpus: "0.5"
# memory: 512M
# ports: !override
# - "8000-8002:${FT_API_PORT:-8000}"
# command: ["/bin/bash"]
# command: ["-b", "uvicorn api.main:app --host=0.0.0.0 --port=${FT_API_PORT:-8000} --no-access-log --no-server-header --proxy-headers --forwarded-allow-ips='*'"]
# healthcheck:
# test: ["CMD-SHELL", "curl -f http://localhost:${FT_API_PORT:-8000}/api/v${FT_API_VERSION:-1}/ping"]
# start_period: 30s
# start_interval: 1s
# interval: 5m
# timeout: 5s
# retries: 3
- For PRODUCTION with GPU:
compose.override.prod.gpu.yml
services:
api:
image: bybatkhuu/rest-fastapi-template:8.0.7-260313-gpu
runtime: nvidia
build:
args:
BASE_IMAGE: nvidia/cuda:12.6.3-cudnn-runtime-ubuntu24.04
environment:
NVIDIA_VISIBLE_DEVICES: ${NVIDIA_VISIBLE_DEVICES:-all}
CUDA_VISIBLE_DEVICES: ${CUDA_VISIBLE_DEVICES:-all}
# volumes:
# - "./volumes/.vscode-server:/home/ft-user/.vscode-server"
# deploy:
# replicas: 3
# resources:
# limits:
# cpus: "0.5"
# memory: 512M
# ports: !override
# - "8000-8002:${FT_API_PORT:-8000}"
# command: ["/bin/bash"]
# command: ["-b", "uvicorn api.main:app --host=0.0.0.0 --port=${FT_API_PORT:-8000} --no-access-log --no-server-header --proxy-headers --forwarded-allow-ips='*'"]
# healthcheck:
# test: ["CMD-SHELL", "curl -f http://localhost:${FT_API_PORT:-8000}/api/v${FT_API_VERSION:-1}/ping"]
# start_period: 30s
# start_interval: 1s
# interval: 5m
# timeout: 5s
# retries: 3