CadArena can run as a single container because the frontend is served directly by the FastAPI backend.
Dockerfile- Multi-stage build for optimized application imagedocker-compose.yml- Docker Compose configuration for running the app with persistent volumes
-
Install Docker and Docker Compose:
- Docker Desktop (includes Docker Compose)
- Or install Docker Engine and Docker Compose separately
-
Create the backend environment file:
cp backend/.env.example backend/.envFrom the project root directory:
docker compose -f docker/docker-compose.yml up --buildThen open your browser and navigate to:
http://localhost:8000
docker compose -f docker/docker-compose.yml updocker compose -f docker/docker-compose.yml up -ddocker compose -f docker/docker-compose.yml up --builddocker compose -f docker/docker-compose.yml logs -fdocker compose -f docker/docker-compose.yml downdocker compose -f docker/docker-compose.yml down -vThe Docker Compose setup maintains runtime files on the host machine:
backend/data/- Local databases and data filesbackend/output/- Generated DXF files and exported assets
These directories are mounted as volumes, so data persists even after stopping the container.
The application uses environment variables from backend/.env. Key variables:
# Database
DATABASE_URL=sqlite:///./data/cadarena.db
# API Settings
API_HOST=0.0.0.0
API_PORT=8000
# Environment
CADARENA_ENV=devIf port 8000 is already in use, modify the port mapping in docker-compose.yml:
ports:
- "8001:8000" # Maps host port 8001 to container port 8000If you encounter permission errors with volumes, ensure the backend/data and backend/output directories exist:
mkdir -p backend/data backend/outputCheck the logs for errors:
docker compose -f docker/docker-compose.yml logsRemove all containers and images, then rebuild:
docker compose -f docker/docker-compose.yml down -v
docker system prune -a
docker compose -f docker/docker-compose.yml up --build- Use BuildKit - Faster builds with better caching:
DOCKER_BUILDKIT=1 docker compose -f docker/docker-compose.yml up --build- Limit resources - Add resource limits in
docker-compose.yml:
services:
cadarena-app:
deploy:
resources:
limits:
cpus: '2'
memory: 2G- Use .dockerignore - Reduces build context size
The Docker setup includes several security best practices:
- Non-root user - Application runs as unprivileged user
- Minimal base image - Uses
python:3.12-slimfor smaller attack surface - Health checks - Monitors container health
- Network isolation - Uses custom bridge network
- Capability dropping - Removes unnecessary Linux capabilities
docker compose -f docker/docker-compose.yml upFor production deployments:
- Use environment-specific
.envfiles - Set
CADARENA_ENV=production - Configure proper logging
- Use a reverse proxy (nginx, Traefik)
- Enable HTTPS/TLS
- Use managed databases instead of SQLite
- Configure proper backup strategies