Docker Deployment
Quark Commerce ships with two Dockerfiles and two compose files for different deployment scenarios.
Dockerfiles
| File | Base Image | Purpose |
|---|---|---|
Dockerfile | .NET SDK → Runtime | Full build including compose dependencies |
Dockerfile.api | .NET SDK → Runtime | API-only multi-stage build (recommended) |
Building the API Image
docker build -f Dockerfile.api -t quark-api:latest .
The Dockerfile.api performs a multi-stage build:
- Build stage — restores packages and compiles the solution
- Publish stage — creates a trimmed production release
- Runtime stage — copies the published output into
mcr.microsoft.com/dotnet/aspnet
The runtime image:
- Creates
wwwroot/mediadirectory for media storage - Sets
ASPNETCORE_ENVIRONMENT=Production - Listens on port 8080
- Includes a health check at
/health
Docker Compose (Production)
The docker-compose.yml is designed for production use (e.g., via Coolify):
services:
rabbitmq:
image: rabbitmq:3-management
ports:
- "5672:5672"
- "15672:15672"
volumes:
- rabbitmq_data:/var/lib/rabbitmq
api:
build:
context: .
dockerfile: Dockerfile
ports:
- "9080:80"
environment:
- ASPNETCORE_ENVIRONMENT=Production
- ConnectionStrings__DefaultConnection=Host=...;Port=5432;...
- RabbitMQ__Host=rabbitmq
depends_on:
- rabbitmq
volumes:
- api_media:/app/wwwroot/media
volumes:
rabbitmq_data:
api_media:
Key Volumes
| Volume | Container Path | Purpose |
|---|---|---|
api_media | /app/wwwroot/media | Persistent media file storage |
rabbitmq_data | /var/lib/rabbitmq | RabbitMQ state persistence |
warning
The api_media volume is critical. Without it, uploaded media files will be lost on container restart.
Environment Variables
Pass configuration via environment variables using the double-underscore convention:
# Database
ConnectionStrings__DefaultConnection="Host=db;Port=5432;Database=HeadlessEcommerce;Username=postgres;Password=..."
# RabbitMQ
RabbitMQ__Host=rabbitmq
RabbitMQ__Port=5672
RabbitMQ__Username=guest
RabbitMQ__Password=guest
# JWT
Jwt__SecretKey="your-production-secret-key-min-32-chars"
# Licensing
Licensing__PublicKeyBase64="base64-encoded-rsa-public-key"
Licensing__LicenseFileBase64="base64-encoded-license-file"
# Storage
Storage__BaseUrl="https://your-domain.com/media"
# Stripe (optional)
Stripe__SecretKey="sk_live_..."
See Configuration Reference for the full list.
Running Standalone
If you prefer to manage services separately:
# Run just the API
docker run -d \
--name quark-api \
-p 8080:8080 \
-v quark_media:/app/wwwroot/media \
-e ConnectionStrings__DefaultConnection="Host=host.docker.internal;Port=5432;..." \
-e RabbitMQ__Host=host.docker.internal \
-e Licensing__PublicKeyBase64="..." \
-e Licensing__LicenseFileBase64="..." \
quark-api:latest
Health Check
The API exposes a health endpoint:
GET /health
The Docker health check pings this endpoint every 30 seconds. The container will be marked unhealthy after 3 consecutive failures.