lots of final minor improvements to setup.

Signed-off-by: David Lawrence <david.lawrence@docker.com> (github: endophage)
This commit is contained in:
David Lawrence 2016-02-08 14:18:07 -08:00
parent 3cf000a852
commit 7a751e5f78
6 changed files with 46 additions and 19 deletions

View File

@ -1,31 +1,34 @@
notaryserver: server:
build: . build: .
dockerfile: server.Dockerfile dockerfile: server.Dockerfile
links: links:
- notarymysql - mysql
- notarysigner - signer
- signer:notarysigner
environment: environment:
- SERVICE_NAME=notaryserver - SERVICE_NAME=notary_server
ports: ports:
- "8080" - "8080"
- "4443:4443" - "4443:4443"
entrypoint: /bin/bash entrypoint: /bin/bash
command: -c "./migrations/migrate.sh && notary-server -config=fixtures/server-config.json" command: -c "./migrations/migrate.sh && notary-server -config=fixtures/server-config.json"
notarysigner: signer:
build: . build: .
dockerfile: signer.Dockerfile dockerfile: signer.Dockerfile
links: links:
- notarymysql - mysql
environment: environment:
- SERVICE_NAME=notarysigner - SERVICE_NAME=notary_signer
entrypoint: /bin/bash entrypoint: /bin/bash
command: -c "./migrations/migrate.sh && notary-signer -config=fixtures/signer-config.json" command: -c "./migrations/migrate.sh && notary-signer -config=fixtures/signer-config.json"
notarymysql: mysql:
volumes: volumes:
- ./notarymysql/docker-entrypoint-initdb.d:/docker-entrypoint-initdb.d - ./notarymysql/docker-entrypoint-initdb.d:/docker-entrypoint-initdb.d
- notarydata:/var/lib/mysql - notary_data:/var/lib/mysql
image: mariadb:10.1.10 image: mariadb:10.1.10
ports: ports:
- "3306:3306" - "3306:3306"
environment: environment:
- TERM=dumb
- MYSQL_ALLOW_EMPTY_PASSWORD="true" - MYSQL_ALLOW_EMPTY_PASSWORD="true"
command: mysqld --innodb_file_per_table

View File

@ -18,6 +18,6 @@
}, },
"storage": { "storage": {
"backend": "mysql", "backend": "mysql",
"db_url": "server@tcp(notarymysql:3306)/notaryserver?parseTime=True" "db_url": "server@tcp(mysql:3306)/notaryserver?parseTime=True"
} }
} }

View File

@ -11,6 +11,6 @@
}, },
"storage": { "storage": {
"backend": "mysql", "backend": "mysql",
"db_url": "signer@tcp(notarymysql:3306)/notarysigner?parseTime=True" "db_url": "signer@tcp(mysql:3306)/notarysigner?parseTime=True"
} }
} }

View File

@ -6,30 +6,54 @@
iter=0 iter=0
case $SERVICE_NAME in case $SERVICE_NAME in
notaryserver) notary_server)
# have to poll for DB to come up # have to poll for DB to come up
until migrate -path=migrations/server/mysql -url="mysql://server@tcp(notarymysql:3306)/notaryserver" up until migrate -path=migrations/server/mysql -url="mysql://server@tcp(mysql:3306)/notaryserver" version > /dev/null
do do
((iter++)) ((iter++))
if (( iter > 30 )); then if (( iter > 30 )); then
echo "notaryserver database failed to come up within 30 seconds"
exit 1; exit 1;
fi fi
echo "waiting for notarymysql to come up." echo "waiting for notarymysql to come up."
sleep 1 sleep 1
done done
echo "notaryserver database migrated to latest version" pre=$(migrate -path=migrations/server/mysql -url="mysql://server@tcp(mysql:3306)/notaryserver" version)
if migrate -path=migrations/server/mysql -url="mysql://server@tcp(mysql:3306)/notaryserver" up ; then
post=$(migrate -path=migrations/server/mysql -url="mysql://server@tcp(mysql:3306)/notaryserver" version)
if [ "$pre" != "$post" ]; then
echo "notaryserver database migrated to latest version"
else
echo "notaryserver database already at latest version"
fi
else
echo "notaryserver database migration failed"
exit 1
fi
;; ;;
notarysigner) notary_signer)
# have to poll for DB to come up # have to poll for DB to come up
until migrate -path=migrations/signer/mysql -url="mysql://signer@tcp(notarymysql:3306)/notarysigner" up until migrate -path=migrations/signer/mysql -url="mysql://signer@tcp(mysql:3306)/notarysigner" version > /dev/null
do do
((iter++)) ((iter++))
if (( iter > 30 )); then if (( iter > 30 )); then
echo "notarysigner database failed to come up within 30 seconds"
exit 1; exit 1;
fi fi
echo "waiting for notarymysql to come up." echo "waiting for notarymysql to come up."
sleep 1 sleep 1
done done
echo "notarysigner database migrated to latest version" pre=$(migrate -path=migrations/signer/mysql -url="mysql://signer@tcp(mysql:3306)/notarysigner" version)
if migrate -path=migrations/signer/mysql -url="mysql://signer@tcp(mysql:3306)/notarysigner" up ; then
post=$(migrate -path=migrations/signer/mysql -url="mysql://signer@tcp(mysql:3306)/notarysigner" version)
if [ "$pre" != "$post" ]; then
echo "notarysigner database migrated to latest version"
else
echo "notarysigner database already at latest version"
fi
else
echo "notarysigner database migration failed"
exit 1
fi
;; ;;
esac esac

View File

@ -2,6 +2,6 @@ CREATE DATABASE IF NOT EXISTS `notaryserver`;
CREATE USER "server"@"%" IDENTIFIED BY ""; CREATE USER "server"@"%" IDENTIFIED BY "";
GRANT GRANT
ALL PRIVILEGES ON `notaryserver`.* ALL PRIVILEGES ON `notaryserver`.*
TO "server"@"%"; TO "server"@"%";

View File

@ -2,6 +2,6 @@ CREATE DATABASE IF NOT EXISTS `notarysigner`;
CREATE USER "signer"@"%" IDENTIFIED BY ""; CREATE USER "signer"@"%" IDENTIFIED BY "";
GRANT GRANT
ALL PRIVILEGES ON `notarysigner`.* ALL PRIVILEGES ON `notarysigner`.*
TO "signer"@"%"; TO "signer"@"%";