services:
  postgres:
    image: postgres:alpine
    environment:
      POSTGRES_DB: httpsms
      POSTGRES_PASSWORD: dbpassword
      POSTGRES_USER: dbusername
    volumes:
      - postgres:/var/lib/postgresql/data
    ports:
      - "5435:5432"
    restart: on-failure
    healthcheck:
      test: ["CMD-SHELL", "pg_isready -U $${POSTGRES_USER} -d $${POSTGRES_DB}"]
      interval: 30s
      timeout: 60s
      retries: 5
      start_period: 5s

  redis:
    image: redis:latest
    command: redis-server
    volumes:
      - redis:/var/lib/redis
    ports:
      - "6379:6379"
    restart: on-failure

  api:
    build:
      context: ./api
    ports:
      - "8000:8000"
    depends_on:
      postgres:
        condition: service_healthy
      redis:
        condition: service_started
    env_file:
      - ./api/.env

  web:
    build:
      context: ./web
    ports:
      - "3000:3000"
    depends_on:
      api:
        condition: service_started

volumes:
  redis:
  postgres:
