services:
  db:
    image: postgres:17-alpine
    container_name: aurora_db
    environment:
      - POSTGRES_USER=${DB_USER}
      - POSTGRES_PASSWORD=${DB_PASSWORD}
      - POSTGRES_DB=${DB_NAME}
    ports:
      - "127.0.0.1:${DB_PORT}:5432"
    volumes:
      - ./src/db/data:/var/lib/postgresql/data
      - ./src/db/log:/var/log/postgresql
  app:
    container_name: aurora_app
    restart: unless-stopped
    image: aurora-app
    build:
      context: .
      dockerfile: Dockerfile
    working_dir: /app
    ports:
      - "3000:3000"
    volumes:
      - .:/app
      - /app/node_modules
    environment:
      - DB_USER=${DB_USER}
      - DB_PASSWORD=${DB_PASSWORD}
      - DB_NAME=${DB_NAME}
      - DB_PORT=${DB_PORT}
      - DB_HOST=db
      - DISCORD_BOT_TOKEN=${DISCORD_BOT_TOKEN}
      - DISCORD_GUILD_ID=${DISCORD_GUILD_ID}
      - DISCORD_CLIENT_ID=${DISCORD_CLIENT_ID}
      - DATABASE_URL=postgresql://${DB_USER}:${DB_PASSWORD}@db:5432/${DB_NAME}
    depends_on:
      - db
    command: bun run dev

  studio:
    container_name: aurora_studio
    image: aurora-app
    build:
      context: .
      dockerfile: Dockerfile
    working_dir: /app
    ports:
      - "127.0.0.1:4983:4983"
    volumes:
      - .:/app
      - /app/node_modules
    environment:
      - DB_USER=${DB_USER}
      - DB_PASSWORD=${DB_PASSWORD}
      - DB_NAME=${DB_NAME}
      - DB_PORT=${DB_PORT}
      - DB_HOST=db
      - DATABASE_URL=postgresql://${DB_USER}:${DB_PASSWORD}@db:5432/${DB_NAME}
    depends_on:
      - db
    command: bun run db:studio
