services:
  postgres:
    image: postgres:15-alpine
    restart: always
    environment:
      POSTGRES_USER: pomo_user
      POSTGRES_PASSWORD: pomo_password
      POSTGRES_DB: pomo_db
    volumes:
      - postgres_data:/var/lib/postgresql/data
    networks:
      - pomo-network

  pomo-api:
    build: ./pomo-api
    restart: always
    environment:
      PORT: 3000
      DATABASE_URL: postgres://pomo_user:pomo_password@postgres:5432/pomo_db
      CORS_ORIGIN: "*"
      JWT_SECRET: ${JWT_SECRET:-supersecretkey}
    ports:
      - "3000:3000"
    depends_on:
      - postgres
    networks:
      - pomo-network

  pomo-bot:
    build: ./pomo-bot
    restart: always
    environment:
      TELEGRAM_BOT_TOKEN: ${TELEGRAM_BOT_TOKEN}
      API_URL: http://pomo-api:3000/api
    depends_on:
      - pomo-api
    networks:
      - pomo-network

networks:
  pomo-network:
    driver: bridge

volumes:
  postgres_data:
