feat: guna MySQL external — host.docker.internal (dev) & 172.17.200.16 (prod)
- Buang service db dan volume dbdata dari compose files - dev: extra_hosts host.docker.internal:host-gateway → capai MySQL Windows host - prod: IP terus 172.17.200.16, tiada extra_hosts diperlukan - .env.docker: DB_HOST=host.docker.internal dengan nota untuk production - entrypoint.sh: default DB_HOST → host.docker.internal Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -4,12 +4,14 @@
|
||||
# Penggunaan:
|
||||
# docker compose -f docker-compose.yml -f docker-compose.prod.yml up -d --build
|
||||
#
|
||||
# DB external: 172.17.200.16:3306
|
||||
# Dalam .env (production): DB_HOST=172.17.200.16
|
||||
#
|
||||
# Perbezaan dari dev:
|
||||
# • APP_ENV=production, APP_DEBUG=false
|
||||
# • DB port TIDAK didedahkan ke host
|
||||
# • Storage sijil/template disimpan dalam named volume (kekal semasa deploy)
|
||||
# • Opcache validate_timestamps=0 (prestasi)
|
||||
# • Storage sijil/template dalam named volume (kekal semasa redeploy)
|
||||
# • php-dev.ini tidak dimuat
|
||||
# • extra_hosts dibuang (IP terus boleh dicapai dari container)
|
||||
###############################################################################
|
||||
name: ecert
|
||||
|
||||
@@ -20,15 +22,13 @@ services:
|
||||
container_name: ecert_app
|
||||
restart: always
|
||||
volumes:
|
||||
# Kod dari server (git pull)
|
||||
- .:/var/www
|
||||
# php.ini sahaja (tanpa php-dev.ini)
|
||||
- ./docker/php/php.ini:/usr/local/etc/php/conf.d/99-ecert.ini:ro
|
||||
# Storage kekal semasa redeploy
|
||||
- storage_data:/var/www/storage
|
||||
environment:
|
||||
APP_ENV: production
|
||||
APP_DEBUG: "false"
|
||||
extra_hosts: [] # buang host.docker.internal, guna IP terus
|
||||
|
||||
# ── Nginx (production) ─────────────────────────────────────────────────────
|
||||
nginx:
|
||||
@@ -37,17 +37,8 @@ services:
|
||||
volumes:
|
||||
- .:/var/www:ro
|
||||
- ./docker/nginx/default.conf:/etc/nginx/conf.d/default.conf:ro
|
||||
# Mount storage supaya nginx boleh serve fail statik jika perlu
|
||||
- storage_data:/var/www/storage:ro
|
||||
|
||||
# ── MySQL (production) ─────────────────────────────────────────────────────
|
||||
db:
|
||||
container_name: ecert_db
|
||||
restart: always
|
||||
ports: [] # Jangan dedahkan DB port ke luar dalam production
|
||||
volumes:
|
||||
- dbdata:/var/lib/mysql
|
||||
|
||||
# ── Queue Worker (production) ──────────────────────────────────────────────
|
||||
queue:
|
||||
container_name: ecert_queue
|
||||
@@ -58,6 +49,7 @@ services:
|
||||
- storage_data:/var/www/storage
|
||||
environment:
|
||||
APP_ENV: production
|
||||
extra_hosts: []
|
||||
|
||||
###############################################################################
|
||||
volumes:
|
||||
|
||||
Reference in New Issue
Block a user