-
Notifications
You must be signed in to change notification settings - Fork 1
/
develop.sh
executable file
·59 lines (46 loc) · 1.84 KB
/
develop.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#!/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:8.0
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 "=> Configure mysql to allow password login"
mysql -h"${MYSQL_IP}" -uroot -ppassword -e "ALTER USER 'root' IDENTIFIED WITH mysql_native_password BY 'password'; FLUSH PRIVILEGES;"
echo "=> Ensure database"
mysql -h"${MYSQL_IP}" -uroot -ppassword -e 'CREATE DATABASE IF NOT EXISTS releasebell'
export DEBUG="releasebell*"
echo "=> Generating session secret"
mkdir -p ./.dev
dd if=/dev/urandom bs=256 count=1 2>/dev/null | base64 > ./.dev/session.secret
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
echo "========================================================"
echo "If running the vite dev server as below in a second terminal on the side for live-reload, set VITE_DEV_PORT to the port vite runs on."
echo "VITE_API_ORIGIN=http://localhost:3000 npm run dev"
echo "========================================================"
echo "=> Start releasebell"
./index.js