-
Notifications
You must be signed in to change notification settings - Fork 22
Expand file tree
/
Copy pathonebox
More file actions
executable file
·88 lines (75 loc) · 2.3 KB
/
onebox
File metadata and controls
executable file
·88 lines (75 loc) · 2.3 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
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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
#!/bin/bash -e
export ROOT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
export PORT=50003
export COMPONENT_NAME="admiral"
export ONEBOX_NAME="admiral_onebox"
export LATEST_MICROBASE_TAG="master"
export ADMIRAL_ENV="/etc/shippable/admiral.env"
source "$ADMIRAL_ENV"
export CONFIG_DIR="/etc/shippable"
export RUNTIME_DIR="/var/lib/shippable"
export MIGRATIONS_DIR="$ROOT_DIR/migrations"
stop_component() {
local onebox_info=$(sudo docker ps -a | grep $ONEBOX_NAME | awk '{print $1}')
if [ -z "$onebox_info" ]; then
echo "No admiral containers running in onebox mode"
sudo docker rm -f "$COMPONENT_NAME" || true
else
echo "Admiral containers running in onebox mode"
sudo docker rm -f "$ONEBOX_NAME" || true
fi
}
build_image() {
echo "Building image..."
export ADMIRAL_OS="16"
if [[ $OPERATING_SYSTEM == "Ubuntu_14.04" ]]; then
export ADMIRAL_OS="14"
fi
envsubst < Dockerfile > Dockerfile.tmp
rm Dockerfile
mv Dockerfile.tmp Dockerfile
sudo docker build -t shipimg/admiral:onebox .
}
run_component() {
echo "Starting admiral..."
local envs=" -e DBNAME=$DB_NAME \
-e DBUSERNAME=$DB_USER \
-e DBPASSWORD=$DB_PASSWORD \
-e DBDIALECT=$DB_DIALECT \
-e DBHOST=$DB_IP \
-e DBPORT=$DB_PORT \
-e RUN_MODE=$RUN_MODE \
-e SSH_USER=$SSH_USER \
-e LOGIN_TOKEN=$LOGIN_TOKEN \
-e ADMIRAL_IP=$ADMIRAL_IP \
-e RELEASE=$RELEASE \
-e CONFIG_DIR=$CONFIG_DIR \
-e RUNTIME_DIR=$RUNTIME_DIR \
-e PRIVATE_IMAGE_REGISTRY=$PRIVATE_IMAGE_REGISTRY"
run_cmd="sudo docker run -d --name=$ONEBOX_NAME --privileged=true --restart=always --net=host"
run_cmd="$run_cmd $envs"
run_cmd="$run_cmd -e RUN_MODE=dev"
run_cmd="$run_cmd -p $PORT:$PORT "
run_cmd="$run_cmd -v /var/run/docker.sock:/var/run/docker.sock:rw"
run_cmd="$run_cmd -v $CONFIG_DIR:$CONFIG_DIR:rw "
run_cmd="$run_cmd -v $RUNTIME_DIR:$RUNTIME_DIR:rw "
run_cmd="$run_cmd -v $(pwd):/home/shippable/admiral:rw "
run_cmd="$run_cmd -t shipimg/admiral:onebox"
echo $run_cmd
run_cmd_exc=$($run_cmd)
echo "$run_cmd_exc"
}
checkout_dockerfile() {
git checkout -- Dockerfile
}
run_npm_install() {
docker exec $ONEBOX_NAME bash -c "cd /home/shippable/admiral && npm install --unsafe-perm"
}
main() {
stop_component
build_image
run_component
checkout_dockerfile
run_npm_install
}
main