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