mirror of
https://github.com/VinylDNS/vinyldns
synced 2025-08-22 10:10:12 +00:00
have portal wait for mysql (#527)
* have portal docker image wait for mysql before starting up
This commit is contained in:
parent
130bfa2b15
commit
1a2d12a7e9
11
build.sbt
11
build.sbt
@ -157,6 +157,16 @@ lazy val portalDockerSettings = Seq(
|
|||||||
|
|
||||||
// this is the default version, can be overridden
|
// this is the default version, can be overridden
|
||||||
bashScriptExtraDefines += s"""addJava "-Dvinyldns.base-version=${(version in ThisBuild).value}"""",
|
bashScriptExtraDefines += s"""addJava "-Dvinyldns.base-version=${(version in ThisBuild).value}"""",
|
||||||
|
|
||||||
|
// wait for mysql
|
||||||
|
bashScriptExtraDefines += "(cd /opt/docker/ && ./wait-for-dependencies.sh && cd -)",
|
||||||
|
dockerCommands ++= Seq(
|
||||||
|
Cmd("USER", "root"), // switch to root so we can install netcat
|
||||||
|
ExecCmd("RUN", "apt-get", "update"),
|
||||||
|
ExecCmd("RUN", "apt-get", "install", "-y", "netcat-openbsd"),
|
||||||
|
Cmd("USER", "daemon") // switch back to the daemon user
|
||||||
|
),
|
||||||
|
|
||||||
credentials in Docker := Seq(Credentials(Path.userHome / ".ivy2" / ".dockerCredentials"))
|
credentials in Docker := Seq(Credentials(Path.userHome / ".ivy2" / ".dockerCredentials"))
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -471,7 +481,6 @@ lazy val sonatypePublishStage = Seq[ReleaseStep](
|
|||||||
lazy val finalReleaseStage = Seq[ReleaseStep] (
|
lazy val finalReleaseStage = Seq[ReleaseStep] (
|
||||||
releaseStepCommand("project root"), // use version.sbt file from root
|
releaseStepCommand("project root"), // use version.sbt file from root
|
||||||
commitReleaseVersion,
|
commitReleaseVersion,
|
||||||
tagRelease,
|
|
||||||
setNextVersion,
|
setNextVersion,
|
||||||
commitNextVersion
|
commitNextVersion
|
||||||
)
|
)
|
||||||
|
@ -11,6 +11,7 @@ PORTAL_PORT=9001
|
|||||||
PLAY_HTTP_SECRET_KEY=change-this-for-prod
|
PLAY_HTTP_SECRET_KEY=change-this-for-prod
|
||||||
VINYLDNS_BACKEND_URL=http://vinyldns-api:9000
|
VINYLDNS_BACKEND_URL=http://vinyldns-api:9000
|
||||||
DYNAMODB_ENDPOINT=http://vinyldns-dynamodb:8000
|
DYNAMODB_ENDPOINT=http://vinyldns-dynamodb:8000
|
||||||
|
MYSQL_ENDPOINT=vinyldns-mysql:3306
|
||||||
USER_TABLE_NAME=users
|
USER_TABLE_NAME=users
|
||||||
USER_CHANGE_TABLE_NAME=userChange
|
USER_CHANGE_TABLE_NAME=userChange
|
||||||
TEST_LOGIN=true
|
TEST_LOGIN=true
|
||||||
|
@ -53,9 +53,10 @@ portal.vinyldns.backend.url = ${?VINYLDNS_BACKEND_URL}
|
|||||||
portal.test_login = true
|
portal.test_login = true
|
||||||
portal.test_login = ${?TEST_LOGIN}
|
portal.test_login = ${?TEST_LOGIN}
|
||||||
|
|
||||||
|
|
||||||
mysql {
|
mysql {
|
||||||
class-name = "vinyldns.mysql.repository.MySqlDataStoreProvider"
|
class-name = "vinyldns.mysql.repository.MySqlDataStoreProvider"
|
||||||
|
endpoint = "localhost:19002"
|
||||||
|
endpoint = ${?MYSQL_ENDPOINT}
|
||||||
|
|
||||||
settings {
|
settings {
|
||||||
# JDBC Settings, these are all values in scalikejdbc-config, not our own
|
# JDBC Settings, these are all values in scalikejdbc-config, not our own
|
||||||
@ -63,8 +64,8 @@ mysql {
|
|||||||
# assumes a docker or mysql instance running locally
|
# assumes a docker or mysql instance running locally
|
||||||
name = "vinyldns"
|
name = "vinyldns"
|
||||||
driver = "org.mariadb.jdbc.Driver"
|
driver = "org.mariadb.jdbc.Driver"
|
||||||
migration-url = "jdbc:mariadb://localhost:19002/?user=root&password=pass"
|
migration-url = "jdbc:mariadb://"${mysql.endpoint}"/?user=root&password=pass"
|
||||||
url = "jdbc:mariadb://localhost:19002/vinyldns?user=root&password=pass"
|
url = "jdbc:mariadb://"${mysql.endpoint}"/vinyldns?user=root&password=pass"
|
||||||
user = "root"
|
user = "root"
|
||||||
password = "pass"
|
password = "pass"
|
||||||
}
|
}
|
||||||
|
32
modules/portal/dist/wait-for-dependencies.sh
vendored
Executable file
32
modules/portal/dist/wait-for-dependencies.sh
vendored
Executable file
@ -0,0 +1,32 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
# allow skipping with env var
|
||||||
|
if [ "$SKIP_MYSQL_WAIT" -eq "1" ]; then
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
# the mysql address, default to a local docker setup
|
||||||
|
MYSQL_ADDRESS=${MYSQL_ADDRESS:-vinyldns-mysql}
|
||||||
|
MYSQL_PORT=${MYSQL_PORT:-3306}
|
||||||
|
echo "Waiting for MYSQL to be ready on ${MYSQL_ADDRESS}:${MYSQL_PORT}"
|
||||||
|
DATA=""
|
||||||
|
RETRY=30
|
||||||
|
while [ "$RETRY" -gt 0 ]
|
||||||
|
do
|
||||||
|
DATA=$(nc -vzw1 "$MYSQL_ADDRESS" "$MYSQL_PORT")
|
||||||
|
if [ $? -eq 0 ]
|
||||||
|
then
|
||||||
|
break
|
||||||
|
else
|
||||||
|
echo "Retrying Again" >&2
|
||||||
|
|
||||||
|
let RETRY-=1
|
||||||
|
sleep .5
|
||||||
|
|
||||||
|
if [ "$RETRY" -eq 0 ]
|
||||||
|
then
|
||||||
|
echo "Exceeded retries waiting for MYSQL to be ready on ${MYSQL_ADDRESS}:${MYSQL_PORT}, failing"
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
done
|
Loading…
x
Reference in New Issue
Block a user