-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdocker_build_and_start.sh
More file actions
executable file
·40 lines (33 loc) · 1.27 KB
/
docker_build_and_start.sh
File metadata and controls
executable file
·40 lines (33 loc) · 1.27 KB
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
#!/bin/sh
#
# This script builds C3 artifacts, and then creates and starts new Docker C3 image.
#
# Abort on first error
set -e
# Stop all currently running containers with c3-next image
docker ps -a | grep ifunsoftware/c3-next:snapshot | awk '{ print $1 }' | xargs docker rm -f
# Build app binaries and new docker image
mvn clean install
# Prepare a new Docker image
docker build -t ifunsoftware/c3-next:snapshot c3-deploy/target/docker/
# Remove any obsolete containers
docker images | grep '^<none' | awk '{ print $3 }' | xargs docker rmi -f
get_docker_ip() {
DOCKER_PROTO=$(echo $DOCKER_HOST | cut -d ':' -f 1)
if [ "$DOCKER_PROTO" = "tcp" ] ; then
echo $(echo $DOCKER_HOST | cut -d ':' -f 2 | sed -e 's/\///g')
else
if [ "$(uname)" == "Darwin" ]; then
# Mac OS X platform
# Assuming using boot2docker
boot2docker ip 2> /dev/null
else
# Probably Linux platform
echo "127.0.0.1"
fi
fi
}
# Run Docker container with new binaries
docker run -d -p 8080:8080 -p 7375:7375 -p 8443:8443 -p 8022:22 -v /tmp/c3:/opt/c3 ifunsoftware/c3-next:snapshot \
&& echo "[Success] C3 container is started. Web CLI will be available shortly at http://$(get_docker_ip):8080/manage/" \
|| echo "[Error] Failed to start C3 container"