Use this when you want to deploy the entire stack on a single server using Docker Compose.
By default, this stack starts the main production services:
- PostgreSQL
- Redis
- FastAPI API
- Caddy reverse proxy
Migrations, background workers, scheduler and Flower are available through Docker Compose profiles and do not start automatically.
| Service | Description | Starts by default |
|---|---|---|
postgres |
pgvector/pgvector PostgreSQL service | Yes |
redis |
Redis Alpine service | Yes |
api |
FastAPI via Uvicorn, behind Caddy | Yes |
caddy |
Reverse proxy with automatic HTTPS support | Yes |
migrate |
Runs alembic upgrade head |
No — profile migrate |
celery_worker |
Celery Worker | No — profile worker |
celery_beat |
Celery Beat scheduler | No — profile scheduler |
celery_flower |
Flower monitoring UI | No — profile observability |
- Docker and Docker Compose installed on the server.
- A
.envfile configured inbackend/.env. Seebackend/.env.example. - Your server IP mapped to your domain through a DNS
Arecord. - Ports
80and443open on the server firewall.
This setup uses the existing backend/.env file. You do not need to create an extra .env file for this Compose stack.
Make sure the required variables are configured, especially:
POSTGRES_USERPOSTGRES_PASSWORDPOSTGRES_DBREDIS_CACHE_PASSWORD
If you want to run Flower, also configure:
FLOWER_BASIC_AUTH=user:password
REDIS_CACHE_PASSWORD is used as the main Redis password for the Redis container and is also reused by the application for the internal Redis connections configured in this Compose file.
Caddy is used as the reverse proxy for the API.
To enable automatic HTTPS, edit:
deploy/compose/full-stack/Caddyfile
and configure your real domain, for example:
api.example.com
Your domain must point to the server IP, and ports 80 and 443 must be reachable from the internet.
Run all commands from the repository root.
Starts PostgreSQL, Redis, API and Caddy:
docker compose --env-file backend/.env \
-f deploy/compose/full-stack/docker-compose.yml \
--project-name fastapi-async-sqlmodel-boilerplate-prod \
up -dUsually required before using the API with a fresh database or after deploying code with new Alembic revisions:
docker compose --env-file backend/.env \
-f deploy/compose/full-stack/docker-compose.yml \
--project-name fastapi-async-sqlmodel-boilerplate-prod \
--profile migrate \
run --rm migrateUse this when you need to process background jobs:
docker compose --env-file backend/.env \
-f deploy/compose/full-stack/docker-compose.yml \
--project-name fastapi-async-sqlmodel-boilerplate-prod \
--profile worker \
up -d celery_workerdocker compose --env-file backend/.env \
-f deploy/compose/full-stack/docker-compose.yml \
--project-name fastapi-async-sqlmodel-boilerplate-prod \
stop celery_workerUse this when you need scheduled tasks:
docker compose --env-file backend/.env \
-f deploy/compose/full-stack/docker-compose.yml \
--project-name fastapi-async-sqlmodel-boilerplate-prod \
--profile scheduler \
up -d celery_beatUse this when you want to inspect Celery workers and tasks through the Flower UI:
docker compose --env-file backend/.env \
-f deploy/compose/full-stack/docker-compose.yml \
--project-name fastapi-async-sqlmodel-boilerplate-prod \
--profile observability \
up -d celery_flowerStarts Celery Worker, Celery Beat and Flower:
docker compose --env-file backend/.env \
-f deploy/compose/full-stack/docker-compose.yml \
--project-name fastapi-async-sqlmodel-boilerplate-prod \
--profile worker \
--profile scheduler \
--profile observability \
up -d- Standalone mode: this Compose file is intended for a single-server deployment where PostgreSQL, Redis, API and reverse proxy run on the same host.
- Caddy proxy: Caddy acts as the public entrypoint and can provision Let's Encrypt certificates automatically when configured with a real domain.
- Internal services: PostgreSQL, Redis, API and Flower use
expose, not publicports, so they are only reachable inside the Docker network. Caddy is the only public HTTP/HTTPS entrypoint. - Security: PostgreSQL and Redis are not exposed directly to the host network.
- Resilience: the
apicontainer starts only afterpostgresandredispass their healthchecks. - Migrations: migrations do not run automatically. Run the
migrateprofile explicitly when needed. - Profiles: background tasks, scheduler, Flower and migrations do not start by default. Use
--profileflags to start them. - Resources: the Celery Worker is configured with conservative concurrency to be friendly to small VPS environments.