139 lines
4.3 KiB
YAML
139 lines
4.3 KiB
YAML
# compose.dev.yml
|
|
# ============================================================================
|
|
# DEVELOPMENT DOCKER COMPOSE CONFIGURATION
|
|
# ============================================================================
|
|
# This file defines the local development environment using Docker/Podman.
|
|
#
|
|
# Services:
|
|
# - app: Node.js application (API + Frontend)
|
|
# - postgres: PostgreSQL 15 with PostGIS extension
|
|
# - redis: Redis for caching and job queues
|
|
#
|
|
# Usage:
|
|
# Start all services: podman-compose -f compose.dev.yml up -d
|
|
# Stop all services: podman-compose -f compose.dev.yml down
|
|
# View logs: podman-compose -f compose.dev.yml logs -f
|
|
# Reset everything: podman-compose -f compose.dev.yml down -v
|
|
#
|
|
# VS Code Dev Containers:
|
|
# This file is referenced by .devcontainer/devcontainer.json for seamless
|
|
# VS Code integration. Open the project in VS Code and use "Reopen in Container".
|
|
# ============================================================================
|
|
|
|
version: '3.8'
|
|
|
|
services:
|
|
# ===================
|
|
# Application Service
|
|
# ===================
|
|
app:
|
|
container_name: flyer-crawler-dev
|
|
build:
|
|
context: .
|
|
dockerfile: Dockerfile.dev
|
|
volumes:
|
|
# Mount the current directory to /app in the container
|
|
- .:/app
|
|
# Create a volume for node_modules to avoid conflicts with Windows host
|
|
# and improve performance.
|
|
- node_modules_data:/app/node_modules
|
|
ports:
|
|
- '3000:3000' # Frontend (Vite default)
|
|
- '3001:3001' # Backend API
|
|
environment:
|
|
# Core settings
|
|
- NODE_ENV=development
|
|
# Database - use service name for Docker networking
|
|
- DB_HOST=postgres
|
|
- DB_PORT=5432
|
|
- DB_USER=postgres
|
|
- DB_PASSWORD=postgres
|
|
- DB_NAME=flyer_crawler_dev
|
|
# Redis - use service name for Docker networking
|
|
- REDIS_URL=redis://redis:6379
|
|
- REDIS_HOST=redis
|
|
- REDIS_PORT=6379
|
|
# Frontend URL for CORS
|
|
- FRONTEND_URL=http://localhost:3000
|
|
# Default JWT secret for development (override in production!)
|
|
- JWT_SECRET=dev-jwt-secret-change-in-production
|
|
# Worker settings
|
|
- WORKER_LOCK_DURATION=120000
|
|
depends_on:
|
|
postgres:
|
|
condition: service_healthy
|
|
redis:
|
|
condition: service_healthy
|
|
# Keep container running so VS Code can attach
|
|
command: tail -f /dev/null
|
|
# Healthcheck for the app (once it's running)
|
|
healthcheck:
|
|
test: ['CMD', 'curl', '-f', 'http://localhost:3001/api/health', '||', 'exit', '0']
|
|
interval: 30s
|
|
timeout: 10s
|
|
retries: 3
|
|
start_period: 60s
|
|
|
|
# ===================
|
|
# PostgreSQL Database
|
|
# ===================
|
|
postgres:
|
|
image: docker.io/library/postgis/postgis:15-3.4
|
|
container_name: flyer-crawler-postgres
|
|
ports:
|
|
- '5432:5432'
|
|
environment:
|
|
POSTGRES_USER: postgres
|
|
POSTGRES_PASSWORD: postgres
|
|
POSTGRES_DB: flyer_crawler_dev
|
|
# Optimize for development
|
|
POSTGRES_INITDB_ARGS: '--encoding=UTF8 --locale=C'
|
|
volumes:
|
|
- postgres_data:/var/lib/postgresql/data
|
|
# Mount SQL files for manual initialization if needed
|
|
- ./sql:/docker-entrypoint-initdb.d/sql:ro
|
|
# Healthcheck ensures postgres is ready before app starts
|
|
healthcheck:
|
|
test: ['CMD-SHELL', 'pg_isready -U postgres -d flyer_crawler_dev']
|
|
interval: 5s
|
|
timeout: 5s
|
|
retries: 10
|
|
start_period: 10s
|
|
|
|
# ===================
|
|
# Redis Cache/Queue
|
|
# ===================
|
|
redis:
|
|
image: docker.io/library/redis:alpine
|
|
container_name: flyer-crawler-redis
|
|
ports:
|
|
- '6379:6379'
|
|
volumes:
|
|
- redis_data:/data
|
|
# Healthcheck ensures redis is ready before app starts
|
|
healthcheck:
|
|
test: ['CMD', 'redis-cli', 'ping']
|
|
interval: 5s
|
|
timeout: 5s
|
|
retries: 10
|
|
start_period: 5s
|
|
# Enable persistence for development data
|
|
command: redis-server --appendonly yes
|
|
|
|
# ===================
|
|
# Named Volumes
|
|
# ===================
|
|
volumes:
|
|
postgres_data:
|
|
name: flyer-crawler-postgres-data
|
|
redis_data:
|
|
name: flyer-crawler-redis-data
|
|
node_modules_data:
|
|
name: flyer-crawler-node-modules
|
|
|
|
# ===================
|
|
# Network Configuration
|
|
# ===================
|
|
# All services are on the default bridge network.
|
|
# Use service names (postgres, redis) as hostnames.
|