-
Notifications
You must be signed in to change notification settings - Fork 37
/
up
63 lines (54 loc) · 1.49 KB
/
up
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
60
61
62
63
#!/bin/bash
mongo_version="5.0.26"
mysql_version="5.6"
app_dir="/app"
home_dir="/home/app"
cd "$(dirname "$0")/.." # move to the parent dir
dirpath="$( pwd -P )" # study the dir path
project=${dirpath##*/} # set the name of dir
#
# Starting up...
#
docker network create $project > /dev/null
docker run \
--name $project-mongod \
--detach --rm \
--network $project \
--publish 27017:27017 \
mongo:$mongo_version --replSet "rs0" > /dev/null
docker run \
--name $project-mysqld \
--detach --rm \
--network $project \
--publish 3306:3306 \
--env MYSQL_ALLOW_EMPTY_PASSWORD=yes \
mysql:$mysql_version > /dev/null
# Build dev image
if [ -z "$(docker image ls -q $project-app)" ]; then
bash dev/build
fi
# Initialize databases
echo -n "Waiting mysql."
while ! docker exec $project-mysqld mysqladmin ping --silent > /dev/null; do
echo -n .
sleep 1
done
echo " OK."
docker exec $project-mongod mongo --eval 'rs.initiate()' > /dev/null
docker exec $project-mysqld mysql -e "CREATE DATABASE momy;" > /dev/null
# Run dev container
docker run \
--name $project-app \
--interactive --tty --rm \
--network $project \
--publish 9229:9229 \
--mount type=bind,source=$dirpath,target=$app_dir \
--mount type=bind,source="$HOME/.ssh",target="$home_dir/.ssh" \
--mount type=bind,source="$HOME/.gitconfig",target="$home_dir/.gitconfig" \
$project-app $@
#
# Shutting down...
#
docker stop $project-mysqld > /dev/null
docker stop $project-mongod > /dev/null
docker network rm $project > /dev/null