Files
sibedas/README-Docker-Usage.md
2025-06-24 15:09:21 +07:00

2.8 KiB

Docker Usage Guide

Proyek ini memiliki dua konfigurasi Docker untuk keperluan yang berbeda:

📁 File Konfigurasi

1. docker-compose.yml - Production/Staging

  • Target: production (optimized build)
  • Environment: Production settings
  • Debug: Disabled
  • Asset handling: Built dan optimized
  • Use case: Deploy ke server production/staging

2. docker-compose.local.yml - Local Development

  • Target: local (development build)
  • Environment: Local development settings
  • Debug: Enabled
  • Asset handling: Vite dev server terpisah
  • Use case: Development di local machine

🚀 Cara Penggunaan

# Setup awal (otomatis)
./setup-local.sh

# Atau manual
docker-compose -f docker-compose.local.yml up -d --build

Production/Staging

# Dengan environment variables
docker-compose up -d --build

# Atau dengan custom .env
APP_ENV=production APP_DEBUG=false docker-compose up -d --build

🔧 Perbedaan Utama

Aspek Local Development Production
File docker-compose.local.yml docker-compose.yml
Target local production
Debug Enabled Disabled
Assets Vite dev server Pre-built & optimized
Permissions User mapping Standard www-data
Hot Reload Available Not needed
Node Modules Kept for dev Removed after build

📋 Command Cheat Sheet

Local Development

# Start
docker-compose -f docker-compose.local.yml up -d

# Stop
docker-compose -f docker-compose.local.yml down

# Logs
docker-compose -f docker-compose.local.yml logs -f app

# Execute commands
docker-compose -f docker-compose.local.yml exec app php artisan [command]

Production

# Start
docker-compose up -d

# Stop
docker-compose down

# Logs
docker-compose logs -f app

# Execute commands
docker-compose exec app php artisan [command]

🛠 Development Workflow

  1. Daily development: Gunakan docker-compose.local.yml
  2. Testing production build: Gunakan docker-compose.yml
  3. Deploy: Gunakan docker-compose.yml di server

FAQ

Q: Apakah perlu kedua file? A: Ya, keduanya memiliki fungsi berbeda:

  • docker-compose.local.yml untuk development
  • docker-compose.yml untuk production/staging

Q: File mana yang digunakan untuk development? A: Gunakan docker-compose.local.yml dengan menjalankan ./setup-local.sh

Q: Bagaimana cara switch antara development dan production? A: Gunakan flag -f untuk specify file yang ingin digunakan