Files
IoT_PreTester_Demo/V4.5/docker-compose.yml
T
2026-06-24 14:53:14 +02:00

121 lines
3.7 KiB
YAML

services:
# Django Backend Service
backend:
build:
context: .
dockerfile: Dockerfile.backend
container_name: iot-pretester-backend
restart: unless-stopped
user: "1000:1000"
ports:
- "${BACKEND_PORT:-8000}:8000"
volumes:
# Persistent data storage (bind mounts for easy access)
- backend_data:/app/data
- backend_logs:/app/logs
# Shared files volume for firmware/pcap/wireshark (named volume)
- shared_files:/app/files
- frontend_uploads:/app/files/uploads
# Optional: Mount source code for development (Commented out to fix permissions)
# - ./django_project:/app/django_project
- backend_staticfiles:/app/django_project/staticfiles
environment:
# Django settings
- DEBUG=${DEBUG:-False}
- SECRET_KEY=${SECRET_KEY}
- ALLOWED_HOSTS=${ALLOWED_HOSTS:-*}
- DJANGO_SETTINGS_MODULE=IoTPreTester.settings
# Database configuration
- DATABASE_PATH=/app/data/db.sqlite3
# CORS configuration
- CORS_ALLOWED_ORIGINS=${CORS_ALLOWED_ORIGINS:-http://localhost:3000}
# Superuser credentials
- DJANGO_SUPERUSER_USERNAME=${DJANGO_SUPERUSER_USERNAME:-admin}
- DJANGO_SUPERUSER_EMAIL=${DJANGO_SUPERUSER_EMAIL:-admin@example.com}
- DJANGO_SUPERUSER_PASSWORD=${DJANGO_SUPERUSER_PASSWORD:-admin}
# Initialization flag
- INIT_DATABASE=${INIT_DATABASE:-true}
# Gunicorn configuration
- GUNICORN_WORKERS=${GUNICORN_WORKERS:-4}
- GUNICORN_TIMEOUT=${GUNICORN_TIMEOUT:-120}
- LOG_LEVEL=${LOG_LEVEL:-info}
networks:
- iot-network
healthcheck:
test: [ "CMD", "wget", "--no-verbose", "--tries=1", "--spider", "http://localhost:8000/api/get_all_manufacturers" ]
interval: 30s
timeout: 10s
retries: 3
start_period: 40s
# Next.js Frontend Service
frontend:
build:
context: .
dockerfile: Dockerfile.frontend
args:
- NEXT_PUBLIC_API_URL=${NEXT_PUBLIC_API_URL:-http://localhost:8000/api}
container_name: iot-pretester-frontend
restart: unless-stopped
user: "1000:1000"
ports:
- "${FRONTEND_PORT:-3000}:3000"
volumes:
# Use named volumes instead of bind mounts for proper permissions
- frontend_uploads:/app/public/filesAttachment
- frontend_captures:/app/public/wireshark_capture
# Shared files volume (same as backend, mounted at /files)
- shared_files:/files
# Optional: Mount source code for development
# - ./Frontend/iot-pre-tester-frontend:/app
# - /app/node_modules
# - /app/.next
environment:
- NODE_ENV=${NODE_ENV:-production}
- NEXT_PUBLIC_API_URL=${NEXT_PUBLIC_API_URL:-http://localhost:8000/api}
# Bind Next.js to all interfaces (otherwise it binds to the container
# hostname only and the loopback healthcheck fails)
- HOSTNAME=0.0.0.0
depends_on:
backend:
condition: service_healthy
networks:
- iot-network
healthcheck:
# busybox wget resolves localhost to ::1 but Next.js only listens on
# IPv4, so the check must target 127.0.0.1 explicitly
test: [ "CMD", "wget", "--no-verbose", "--tries=1", "--spider", "http://127.0.0.1:3000/devices" ]
interval: 30s
timeout: 10s
retries: 3
start_period: 20s
networks:
iot-network:
driver: bridge
volumes:
# Named volume for shared file access between frontend and backend
shared_files:
driver: local
# Legacy volumes (keeping for backwards compatibility)
backend_data:
driver: local
files:
driver: local
logs:
driver: local
backend_logs:
driver: local
frontend_uploads:
driver: local
frontend_captures:
driver: local
backend_staticfiles:
driver: local