perbaikan migrasi database pada docker compose
This commit is contained in:
@@ -0,0 +1,2 @@
|
||||
FROM mysql:8.4
|
||||
COPY ./migrations /docker-entrypoint-initdb.d/
|
||||
+6
-7
@@ -17,7 +17,10 @@ services:
|
||||
restart: unless-stopped
|
||||
|
||||
db:
|
||||
image: mysql:8.4
|
||||
build:
|
||||
context: .
|
||||
dockerfile: Dockerfile.db
|
||||
image: webgis-db
|
||||
environment:
|
||||
MYSQL_DATABASE: webgis_spbu
|
||||
MYSQL_USER: webgis_user
|
||||
@@ -27,15 +30,12 @@ services:
|
||||
- "3306"
|
||||
volumes:
|
||||
- webgis_db_data:/var/lib/mysql
|
||||
- ./migrations:/docker-entrypoint-initdb.d:ro
|
||||
restart: unless-stopped
|
||||
|
||||
migrate:
|
||||
image: mysql:8.4
|
||||
image: webgis-db
|
||||
environment:
|
||||
MYSQL_PWD: root_password
|
||||
volumes:
|
||||
- ./migrations:/migrations:ro
|
||||
depends_on:
|
||||
- db
|
||||
command: >
|
||||
@@ -46,8 +46,7 @@ services:
|
||||
done;
|
||||
sleep 3;
|
||||
echo 'mysqld is alive';
|
||||
for file in /migrations/*.sql; do
|
||||
[ -e \"$$file\" ] || { echo 'No SQL files found'; exit 0; };
|
||||
for file in /docker-entrypoint-initdb.d/*.sql; do
|
||||
echo \"Running $$file\";
|
||||
mysql -h db -uroot --password=$$MYSQL_PWD < $$file || exit 1;
|
||||
done;
|
||||
|
||||
Reference in New Issue
Block a user