Build database image with bundled bootstrap dumps
This commit is contained in:
@@ -38,7 +38,7 @@ docker compose up -d
|
||||
|
||||
## Database
|
||||
|
||||
Dump diambil dari folder `spota_db` saat volume DB pertama kali dibuat.
|
||||
Dump diambil dari folder `spota_db` yang dibundel ke image database saat volume DB pertama kali dibuat.
|
||||
|
||||
Database yang di-import:
|
||||
|
||||
@@ -56,6 +56,7 @@ Folder berikut di-mount dari host supaya data upload tidak masuk image:
|
||||
|
||||
Bind mount tersebut hanya aktif untuk local development melalui `docker-compose.override.yml`.
|
||||
Di Coolify, compose utama memakai named volume agar tidak bentrok dengan host port/path handling Coolify.
|
||||
Bootstrap database tidak lagi bergantung pada bind mount folder host ke container DB; dump dan script init dibawa oleh image database.
|
||||
|
||||
Opsional, upload berkas bisa dipindah ke lokasi di luar folder project dengan environment variable:
|
||||
|
||||
@@ -79,3 +80,4 @@ Sesuaikan environment berikut di Coolify:
|
||||
|
||||
Port internal app adalah `80`. Database internal memakai service name `db` pada port `3306`.
|
||||
Jangan publish `8080:80` di compose utama untuk Coolify, karena Coolify akan mengurus routing sendiri dan bind host port bisa bentrok dengan resource lain.
|
||||
Jangan tambahkan persistent storage ke `/docker-entrypoint-initdb.d` atau `/spota_db` pada service DB.
|
||||
|
||||
@@ -25,7 +25,9 @@ services:
|
||||
condition: service_healthy
|
||||
|
||||
db:
|
||||
image: mysql:8.0
|
||||
build:
|
||||
context: .
|
||||
dockerfile: docker/mysql/Dockerfile
|
||||
restart: unless-stopped
|
||||
command: --default-authentication-plugin=mysql_native_password --character-set-server=latin1 --collation-server=latin1_swedish_ci --sql-mode=NO_ENGINE_SUBSTITUTION
|
||||
environment:
|
||||
@@ -35,8 +37,6 @@ services:
|
||||
MYSQL_DATABASE: ${DB_NAME:-spota_spotadb}
|
||||
volumes:
|
||||
- spota_db_data:/var/lib/mysql
|
||||
- ./docker/mysql-init:/docker-entrypoint-initdb.d:ro
|
||||
- ./spota_db:/spota_db:ro
|
||||
healthcheck:
|
||||
test: ["CMD-SHELL", "mysqladmin ping -h localhost -uroot -p$${MYSQL_ROOT_PASSWORD}"]
|
||||
interval: 10s
|
||||
|
||||
@@ -26,7 +26,9 @@ services:
|
||||
condition: service_healthy
|
||||
|
||||
db:
|
||||
image: mysql:8.0
|
||||
build:
|
||||
context: .
|
||||
dockerfile: docker/mysql/Dockerfile
|
||||
container_name: spota-db
|
||||
restart: unless-stopped
|
||||
command: --default-authentication-plugin=mysql_native_password --character-set-server=latin1 --collation-server=latin1_swedish_ci
|
||||
@@ -37,8 +39,6 @@ services:
|
||||
MYSQL_DATABASE: ${DB_NAME:-spota_spotadb}
|
||||
volumes:
|
||||
- spota_db_data:/var/lib/mysql
|
||||
- ./docker/mysql-init:/docker-entrypoint-initdb.d:ro
|
||||
- ./spota_db:/spota_db:ro
|
||||
healthcheck:
|
||||
test: ["CMD-SHELL", "mysqladmin ping -h localhost -uroot -p$${MYSQL_ROOT_PASSWORD}"]
|
||||
interval: 10s
|
||||
|
||||
6
docker/mysql/Dockerfile
Normal file
6
docker/mysql/Dockerfile
Normal file
@@ -0,0 +1,6 @@
|
||||
FROM mysql:8.0
|
||||
|
||||
COPY docker/mysql-init/00-import-spota-databases.sh /docker-entrypoint-initdb.d/00-import-spota-databases.sh
|
||||
COPY spota_db /spota_db
|
||||
|
||||
RUN chmod +x /docker-entrypoint-initdb.d/00-import-spota-databases.sh
|
||||
Reference in New Issue
Block a user