Commit 6e7d1fdb authored by zkuang's avatar zkuang

fix data migration error

parent 71082c9b
......@@ -2,7 +2,7 @@ version: "3.7"
services:
carbinet_migrate:
build: .
image: carbinet:latest
image: gzego/carbinet:latest
container_name: carbinet_migrate
links:
- mysql:mysql
......@@ -26,7 +26,7 @@ services:
carbinet_upgrade:
build: .
image: carbinet:latest
image: gzego/carbinet:latest
container_name: carbinet_upgrade
links:
- mysql:mysql
......@@ -34,7 +34,6 @@ services:
depends_on:
- "mysql"
- "redis"
- "carbinet_migrate"
environment:
- ALI_IOT_ACCESS_KEY_ID=LTAI4FsNmRpoK4wEmBP5xL2J
- ALI_IOT_ACCESS_KEY_SECRET=Mb9n4bTp3u6aLYThBoDy9S26cX4npD
......@@ -47,11 +46,11 @@ services:
- ALI_IOT_AMQP_CLIENT_ID=carbinet
networks:
- ego
command: ["./wait-for-it.sh", "mysql:3306", "--", "flask", "db", "upgrade"]
command: ["./wait-for-it.sh", "mysql:3306", "--", "sh", "-c", "flask db migrate && flask db upgrade"]
carbinet_seed:
build: .
image: carbinet:latest
image: gzego/carbinet:latest
container_name: carbinet_seed
links:
- mysql:mysql
......@@ -92,9 +91,31 @@ services:
networks:
- ego
command: ["./wait-for-it.sh", "mysql:3306", "--", "python", "./manage.py", "migrate"]
sso_seed:
build: ./sso
container_name: sso_seed
image: gzego/sso:latest
tty: true
stdin_open: true
links:
- mysql:mysql
depends_on:
- "mysql"
environment:
- SECRET_KEY=1gboig1%1%ljuz_h0&8m%s84ybxz42z3w0pu50qi%mobo%poae
- ALLOWED_HOSTS=["sso.gzego.com"]
- DB_NAME=sso
- DB_USERNAME=sso
- DB_PASSWORD=123456
- DB_HOST=mysql
- DB_PORT=3306
- CAS_SERVICES=["http://carbinet.gzego.com:8080/api/cas", "http://carbinet.gzego.com:8080/api/cas/logout"]
networks:
- ego
command: ["./wait-for-it.sh", "mysql:3306", "--", "python", "./manage.py", "createsuperuser"]
carbinet_bash:
build: .
image: carbinet:latest
image: gzego/carbinet:latest
container_name: carbinet_migrate
links:
- mysql:mysql
......
build() {
echo "building..."
if [[ "$(docker images -q ego/carbinet:base 2> /dev/null)" == "" ]]; then
docker build -t ego/carbinet:base -f ./Dockerfile.base .
fi
if [ -d "./sso/.git" ]; then
pushd ./sso
git pull origin master
popd
else
git clone -b master --single-branch --depth=1 http://git.gz-ego.com/zkuang/sso.git
fi
if [ -d "./ziti/.git" ]; then
pushd ./ziti
git pull origin cas
popd
else
git clone -b cas --single-branch --depth=1 http://git.gz-ego.com/iot/ziti.git
fi
rm -rf ziti/carbinet_service/migrations/versions/*
pushd ./ziti/carbinet-admin-web/
yarn && VUE_APP_BASE_API=/api yarn build:prod
cp -fr ./dist/* ../../www/carbinet/
popd
docker-compose build carbinet_production
docker-compose build sso_production
docker-compose build mysql
docker-compose build nginx
docker-compose build redis
}
migrate() {
echo "migrating..."
docker-compose -f ./docker-compose.yml -f ./docker-compose.seeding.yml up carbinet_upgrade
docker-compose -f ./docker-compose.yml -f ./docker-compose.seeding.yml up sso_migrate
}
seed() {
echo "seeding..."
docker-compose -f ./docker-compose.yml -f ./docker-compose.seeding.yml up carbinet_seed
docker-compose -f ./docker-compose.yml -f ./docker-compose.seeding.yml run sso_seed
}
if [ "$1" == "build" ]; then
build
elif [ "$1" == "migrate" ]; then
migrate
elif [ "$1" == "seed" ]; then
seed
elif [ "$1" == "deploy" ]; then
docker-compose up -d
elif [ "$1" == "all" ]; then
build
migrate
seed
docker-compose up -d
fi
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment