🧩 Quick Start — Docker Compose¶
This variant runs backend-antiginx as a container service connected to PostgreSQL and RabbitMQ.
✅ Requirements¶
- Docker + Docker Compose (v2)
- Running PostgreSQL and RabbitMQ instances
- Existing Docker network
antiginx(defined asexternal)
Create the network (one-time setup) if you don't have it:
1️⃣ Prepare .env File¶
Create a .env file in the project root directory:
DATABASE_URL=postgres://user:pass@dbhost:5432/antiginx
RABBITMQ_URL=amqp://user:pass@mqhost:5672/
JWT_SECRET=super-secret-key
BACKEND_PORT=4000
📋 About Environment Variables:
DATABASE_URLconnects backend to PostgreSQL.RABBITMQ_URLconnects backend to RabbitMQ and publishes tasks toscan_queue.JWT_SECRETis required for JWT token signing (/api/auth/login,/api/auth/me).BACKEND_PORTis used for Compose mapping (${BACKEND_PORT}:4000).
2️⃣ Create docker-compose.yml¶
Create or update the docker-compose.yml file in your project root:
services:
backend-antiginx:
image: ghcr.io/prawo-i-piesc/backend-antiginx:latest
container_name: backend
restart: unless-stopped
ports:
- "${BACKEND_PORT}:4000"
environment:
- DATABASE_URL=${DATABASE_URL}
- RABBITMQ_URL=${RABBITMQ_URL}
- JWT_SECRET=${JWT_SECRET}
mem_limit: 2048m
networks:
- antiginx
networks:
antiginx:
external: true
💡 Customization:
- Change
ghcr.io/prawo-i-piesc/backend-antiginx:latestto your own image/tag if needed. - Adjust
mem_limitbased on available server resources. - If you do not use an external network, replace
external: truewith an internal network setup.
3️⃣ Start Services¶
Start the container in detached mode:
✅ Quick Validation¶
Check status:
Verify health endpoint:
View logs:
4️⃣ Stop Services¶
Stop and remove containers:
🔄 How It Works¶
- Backend starts on port
4000inside the container. - On
POST /api/scans, a scan record is created in PostgreSQL withPENDINGstatus. - Backend publishes a task message to RabbitMQ queue
scan_queue. - Workers send results to
POST /api/results; backend stores them and updates scan status (RUNNING/COMPLETED).
🔧 Troubleshooting¶
- Error:
network antiginx declared as external, but could not be found→ Create the network:docker network create antiginx. - Auth endpoints return 500/401 → Verify
JWT_SECRETis set and non-empty in.env. - No DB/RabbitMQ connection → Check
DATABASE_URLandRABBITMQ_URL, then restart withdocker compose up -d. localhostin DB/MQ URLs does not work → If services run in other containers/hosts, use reachable hostnames (e.g., service name, container DNS, or external host IP).- Container keeps restarting → Check logs with
docker compose logs -f backend-antiginxand validate external service reachability.