-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.sh
35 lines (28 loc) · 839 Bytes
/
build.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
#!/bin/sh
# default parameter
FORCE=false
DOCKER_NAME=php-swarm
# parsing parameter
while [ "$1" != "" ]; do
if [ $1 == "-f" ]; then
FORCE=true
fi
shift
done
# if any exist docker container then stop it
if docker ps -a | grep $DOCKER_NAME | grep Up; then
docker stop $DOCKER_NAME
fi
# if any exists docker container then remove it
if docker ps -a | grep $DOCKER_NAME; then
docker rm $DOCKER_NAME
fi
# docker image exists and force then remove existing image
if docker images | grep fudyartanto/$DOCKER_NAME && $FORCE; then
docker rmi fudyartanto/$DOCKER_NAME
fi
# not docker image exists or force then build docker
if ! docker images | grep fudyartanto/$DOCKER_NAME || $FORCE; then
docker build -t fudyartanto/$DOCKER_NAME .
fi
docker run -tid -p 8080:80 -p 3306:3306 --name $DOCKER_NAME fudyartanto/$DOCKER_NAME