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:
@@ -1,11 +1,15 @@
|
||||
###############################################################################
|
||||
# eCert MBIP — Docker Compose (Development — Windows 11 / Linux)
|
||||
# eCert MBIP — Docker Compose (Development — Windows 11)
|
||||
#
|
||||
# Penggunaan:
|
||||
# docker compose up -d --build
|
||||
#
|
||||
# Aplikasi: http://localhost:8003
|
||||
# DB (host): localhost:33060 (untuk TablePlus / HeidiSQL)
|
||||
# Aplikasi: http://localhost:8003
|
||||
# DB : host.docker.internal:3306 (MySQL pada Windows host)
|
||||
#
|
||||
# NOTA: Dari dalam container, MySQL pada Windows tidak boleh guna "localhost".
|
||||
# Kena guna host.docker.internal (disediakan oleh Docker Desktop).
|
||||
# Dalam .env: DB_HOST=host.docker.internal
|
||||
###############################################################################
|
||||
name: ecert
|
||||
|
||||
@@ -28,9 +32,8 @@ services:
|
||||
environment:
|
||||
APP_ENV: local
|
||||
APP_DEBUG: "true"
|
||||
depends_on:
|
||||
db:
|
||||
condition: service_healthy
|
||||
extra_hosts:
|
||||
- "host.docker.internal:host-gateway" # pastikan resolusi host pada Linux juga
|
||||
networks:
|
||||
- ecert
|
||||
|
||||
@@ -49,37 +52,6 @@ services:
|
||||
networks:
|
||||
- ecert
|
||||
|
||||
# ── MySQL 8.0 ──────────────────────────────────────────────────────────────
|
||||
db:
|
||||
image: mysql:8.0
|
||||
container_name: ecert_db
|
||||
restart: unless-stopped
|
||||
environment:
|
||||
MYSQL_DATABASE: ${DB_DATABASE:-ecert_mbip}
|
||||
MYSQL_ROOT_PASSWORD: ${DB_PASSWORD:-secret}
|
||||
MYSQL_USER: ${DB_USERNAME:-ecert}
|
||||
MYSQL_PASSWORD: ${DB_PASSWORD:-secret}
|
||||
volumes:
|
||||
- dbdata:/var/lib/mysql
|
||||
ports:
|
||||
- "33060:3306" # port host 33060 → elak konflik dengan MySQL tempatan (3306)
|
||||
healthcheck:
|
||||
test:
|
||||
- CMD
|
||||
- mysqladmin
|
||||
- ping
|
||||
- -h
|
||||
- localhost
|
||||
- -u
|
||||
- root
|
||||
- --password=${DB_PASSWORD:-secret}
|
||||
interval: 5s
|
||||
timeout: 5s
|
||||
retries: 15
|
||||
start_period: 20s
|
||||
networks:
|
||||
- ecert
|
||||
|
||||
# ── Queue Worker ───────────────────────────────────────────────────────────
|
||||
queue:
|
||||
build:
|
||||
@@ -95,7 +67,8 @@ services:
|
||||
- .env
|
||||
environment:
|
||||
APP_ENV: local
|
||||
# Override entrypoint: langkau migrate/seed (app container dah buat)
|
||||
extra_hosts:
|
||||
- "host.docker.internal:host-gateway"
|
||||
entrypoint: []
|
||||
command:
|
||||
- php
|
||||
@@ -106,10 +79,7 @@ services:
|
||||
- --max-time=3600
|
||||
- --timeout=90
|
||||
depends_on:
|
||||
db:
|
||||
condition: service_healthy
|
||||
app:
|
||||
condition: service_started
|
||||
- app
|
||||
networks:
|
||||
- ecert
|
||||
|
||||
@@ -117,7 +87,3 @@ services:
|
||||
networks:
|
||||
ecert:
|
||||
driver: bridge
|
||||
|
||||
volumes:
|
||||
dbdata:
|
||||
driver: local
|
||||
|
||||
Reference in New Issue
Block a user