services:
  app:
    # Mengambil image dari Registry Gitea Anda
    image: git.exavolt.web.id/fikri/portfolio-app:latest
    container_name: fikri-portfolio-app
    restart: always
    ports:
      - "4000:4000"
    
    # Mengambil variabel dari file .env di folder yang sama
    env_file:
      - .env
    
    environment:
      DATABASE_URL: ${DATABASE_URL}
      JWT_SECRET: ${JWT_SECRET}
      R2_TOKEN: ${R2_TOKEN}
      R2_ACCESS_KEY: ${R2_ACCESS_KEY}
      R2_SECRET_KEY: ${R2_SECRET_KEY}
      R2_ENDPOINT: ${R2_ENDPOINT}
      R2_BUCKET_NAME: ${R2_BUCKET_NAME}
      IMAGE_URL: ${IMAGE_URL}
      # Tambahkan port agar internal container sesuai
      PORT: 4000 
      
    extra_hosts:
      - "host.docker.internal:host-gateway"
    
    # Tetap jalankan migrasi database sebelum start
    command: >
      sh -c "npx prisma migrate deploy && node server.js"