forked from Toxantron/scrumonline
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdocker.sh
executable file
·70 lines (68 loc) · 1.84 KB
/
docker.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
60
61
62
63
64
65
66
67
68
69
70
#!/bin/bash
command=$1
current_dir=$(pwd)
container_name=scrumonline
image=scrum-lamp
case $command in
"prepare")
echo "Preparing repository for usage with docker"
php bin/composer install
cp src/sample-config.php src/config.php
# Overwrite host
echo '$host = "localhost:8080";' >> src/config.php
;;
"start")
running=$(docker ps -a -q)
if [ -n "$running" ]; then
echo "Stopping running containers"
docker stop $running
docker rm $running
fi
echo "Starting container $container_name..."
mysql_dir=$2
if [ -n "$mysql_dir" ]; then
docker run -d --name $container_name -p 8080:80 -p 3306:3306 \
-v $current_dir:/var/www/scrumonline -v $current_dir/$mysql_dir:/var/lib/mysql \
$image
else
docker run -d --name $container_name -p 8080:80 -p 3306:3306 \
-v $current_dir:/var/www/scrumonline $image
fi
echo "...done!"
;;
"stop")
echo "Stopping container $container_name..."
docker stop $container_name
docker rm $container_name
echo "...done"
;;
"readlog")
log_name=$2
if [ -n "$log_name" ]; then
docker exec -it $container_name tail -f /var/log/apache2/$log_name.log
else
echo "No log name specified"
fi
;;
"db")
docker exec -it $container_name mysql scrum_online -u root --password=passwd
;;
"myadmin")
mycommand=$2
case $mycommand in
"stop")
docker stop myadmin
docker rm myadmin
;;
*)
docker run --name myadmin -d --link $container_name:db -p 8081:80 phpmyadmin/phpmyadmin
;;
esac
;;
"bash")
docker exec -it $container_name bash
;;
"")
echo "No command specified!"
;;
esac