Commit f71a47bf authored by Johannes Zellner's avatar Johannes Zellner

Add develop script to run against a docker mysql instance

parent 70ddc8ff
node_modules/
users.json
database.json
{
"defaultEnv": "local",
"local": {
"host": "localhost",
"user": "root",
"password": "",
"database": "releasebell",
"driver": "mysql",
"multipleStatements": true
}
}
#!/bin/bash
set -eu
# create the same mysql server version to test with
CONTAINER_NAME="mysql-server-releasebell"
OUT=`docker inspect ${CONTAINER_NAME}` || true
if [[ "${OUT}" = "[]" ]]; then
echo "=> Starting ${CONTAINER_NAME}..."
docker run --name ${CONTAINER_NAME} -e MYSQL_ROOT_PASSWORD=password -d mysql:5.6.34
else
echo "=> ${CONTAINER_NAME} already running. If you want to start fresh, run 'docker rm --force ${CONTAINER_NAME}'"
fi
export MYSQL_IP=`docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' ${CONTAINER_NAME}`
echo "=> Waiting for mysql server to be ready..."
while ! mysqladmin ping -h"${MYSQL_IP}" --silent; do
sleep 1
done
echo "=> Ensure database"
mysql -h"${MYSQL_IP}" -uroot -ppassword -e 'CREATE DATABASE IF NOT EXISTS releasebell'
export DEBUG="releasebell*"
echo "=> Create database.json"
cat <<EOF > ./database.json
{
"defaultEnv": "local",
"local": {
"host": "${MYSQL_IP}",
"user": "root",
"password": "password",
"database": "releasebell",
"driver": "mysql",
"multipleStatements": true
}
}
EOF
echo "=> Run database migrations"
./node_modules/.bin/db-migrate up
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