# INOWYA Location History Analyzer - Docker Compose (Redone Version) # Self-contained deployment for GPS/location data analysis # Supports: Google Takeout, GPX, KML, etc. | Offline-capable | Multi-arch (M1 Mac/x86/ARM) # Usage: docker compose up -d | Access: http://localhost:3000 (UI), :8000/docs (API) services: # 1. Database: PostgreSQL + PostGIS for spatial queries (raw_points, stops, trips) postgres: image: postgis/postgis:15-3.4-alpine platform: linux/arm64 container_name: inowya_postgres restart: unless-stopped environment: POSTGRES_DB: ${POSTGRES_DB:-inowya} POSTGRES_USER: ${POSTGRES_USER:-inowya} POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-inowya123} volumes: - postgres_data:/var/lib/postgresql/data - ./database:/docker-entrypoint-initdb.d:ro # Auto-run schema.sql on init ports: - '5432:5432' # Optional: Expose for external tools like pgAdmin healthcheck: test: ['CMD-SHELL', 'pg_isready -U ${POSTGRES_USER:-inowya} -d ${POSTGRES_DB:-inowya}'] interval: 10s timeout: 5s retries: 5 start_period: 30s command: postgres -c shared_preload_libraries=postgis-3 -c postgis.gdal_enabled_drivers=GTiff,WebP # 2. Cache/Session Store: Redis for heat tiles, WebSocket sessions, Celery broker redis: image: redis:7-alpine container_name: inowya_redis restart: unless-stopped command: redis-server --appendonly yes --requirepass ${REDIS_PASSWORD:-inowya_redis} volumes: - redis_data:/data ports: - '6379:6379' # Optional: Expose for monitoring healthcheck: test: ['CMD', 'redis-cli', '-a', '${REDIS_PASSWORD:-inowya_redis}', 'ping'] interval: 10s timeout: 5s retries: 5 # 3. Map Tiles: Self-hosted OpenMapTiles server (vector tiles, offline with MBTiles) tileserver: build: context: ./tileserver dockerfile: Dockerfile container_name: inowya_tileserver restart: unless-stopped user: "501:501" command: /bin/sh -c "/usr/src/app/docker-entrypoint.sh" ports: - '8080:80' volumes: - ./maptiles:/data # Mount downloaded MBTiles (e.g., planet.mbtiles ~5GB regional) environment: - MBTILES=/data/openmaptiles.mbtiles # Customize for your tiles - PORT=80 healthcheck: test: ['CMD', 'curl', '-f', 'http://localhost:80/health'] interval: 30s timeout: 10s retries: 3 start_period: 60s # Tileserver takes longer to init # 4. Backend API: FastAPI (REST + WebSocket, OpenAPI docs) backend: build: context: ./backend dockerfile: Dockerfile args: - PYTHON_VERSION=3.11 container_name: inowya_backend restart: unless-stopped depends_on: postgres: condition: service_healthy redis: condition: service_healthy environment: - DATABASE_URL=postgresql://${POSTGRES_USER:-inowya}:${POSTGRES_PASSWORD:-inowya123}@postgres:5432/${POSTGRES_DB:-inowya} - REDIS_URL=redis://:${REDIS_PASSWORD:-inowya_redis}@redis:6379/0 - CELERY_BROKER_URL=redis://:${REDIS_PASSWORD:-inowya_redis}@redis:6379/0 - SECRET_KEY=${SECRET_KEY:-your-super-secret-key-change-this} - TZ=${TZ:-America/Los_Angeles} - NOMINATIM_OFFLINE=${NOMINATIM_OFFLINE:-true} volumes: - ./uploads:/app/uploads # For file uploads - ./backend:/app ports: - '8000:8000' healthcheck: test: ['CMD', 'curl', '-f', 'http://localhost:8000/health'] interval: 30s timeout: 10s retries: 3 start_period: 60s user: "1000:1000" # Non-root user (match your host UID for volumes) # 6. Frontend: React PWA (MapLibre, offline-capable) frontend: build: context: ./frontend dockerfile: Dockerfile args: - NODE_VERSION=18 container_name: inowya_frontend restart: unless-stopped depends_on: backend: condition: service_healthy tileserver: condition: service_healthy environment: - REACT_APP_API_URL=${REACT_APP_API_URL:-http://localhost:8000} - REACT_APP_TILE_URL=${REACT_APP_TILE_URL:-http://localhost:8080} - REACT_APP_WS_URL=ws://localhost:8000/ws - I18N_LANG=${I18N_LANG:-en} volumes: - ./frontend:/app - /app/node_modules # Exclude host node_modules for clean build ports: - '3000:3000' # Dev server (hot reload) # For production (static serve via Nginx): # ports: # - '80:80' # command: npm run build && nginx -g 'daemon off;' healthcheck: test: ['CMD', 'curl', '-f', 'http://localhost:3000'] interval: 30s timeout: 10s retries: 3 start_period: 60s # Build time user: "1000:1000" # Non-root # Optional: Reverse Proxy for HTTPS/LAN (Traefik) # traefik: # image: traefik:v2.10 # command: # - "--api.insecure=true" # - "--providers.docker=true" # - "--entrypoints.web.address=:80" # ports: # - "80:80" # - "8081:8080" # Dashboard # volumes: # - /var/run/docker.sock:/var/run/docker.sock volumes: postgres_data: driver: local redis_data: driver: local networks: default: driver: bridge name: inowya_network # Deployment Notes: # - Min Specs: 4-core CPU, 8GB RAM, 20GB disk # - First Run: docker compose build (downloads ~1.5GB) # - Offline Maps: Download MBTiles to ./maptiles/ (e.g., from openmaptiles.org) # - Security: Change passwords in .env; enable RLS in schema.sql # - Scaling: Add more workers via docker compose scale worker=3 # - Backup: docker compose exec postgres pg_dumpall -U inowya > backup.sql # - Cleanup: docker compose down -v && docker system prune