version: '3.8'

services:
  postgres:
    image: postgres:15-alpine
    environment:
      POSTGRES_DB: geeklife
      POSTGRES_USER: postgres
      POSTGRES_PASSWORD: geeklife_password
    volumes:
      - postgres_data:/var/lib/postgresql/data
    ports:
      - "5432:5432"
    healthcheck:
      test: ["CMD-SHELL", "pg_isready -U postgres"]
      interval: 30s
      timeout: 10s
      retries: 3

  geek-life:
    build: .
    depends_on:
      postgres:
        condition: service_healthy
    environment:
      DB_HOST: postgres
      DB_PORT: 5432
      DB_USER: postgres
      DB_PASSWORD: geeklife_password
      DB_NAME: geeklife
      DB_SSLMODE: disable
      JWT_SECRET: your-super-secret-jwt-key-change-in-production
      SESSION_DURATION: 24
      ENVIRONMENT: production
      LOG_LEVEL: info
    volumes:
      - ./migrations:/app/migrations
    command: sh -c "./geek-life --migrate && ./geek-life"
    restart: unless-stopped

volumes:
  postgres_data: