forked from yunionio/ocboot
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun-in-docker.sh
More file actions
executable file
·30 lines (25 loc) · 878 Bytes
/
run-in-docker.sh
File metadata and controls
executable file
·30 lines (25 loc) · 878 Bytes
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
#!/bin/bash
REGISTRY=${REGISTRY:-registry.cn-beijing.aliyuncs.com/yunionio}
VERSION=${VERSION:-v3.10.5}
OCBOOT_IMAGE="$REGISTRY/ocboot:$VERSION"
if ! docker ps > /dev/null 2>&1; then
echo "Error: Docker unavailable, Please resolve the problem and try again"
exit 3
fi
if [ $# -eq 0 ]; then
docker run --rm $OCBOOT_IMAGE -h
exit 1
fi
config_dir="$(pwd)/_config"
run_cmd="docker run --rm -t --network host -v $HOME/.ssh/id_rsa:/root/.ssh/id_rsa -v $config_dir:/opt/ocboot/_config -v $(pwd)/VERSION:/opt/ocboot/VERSION --env OCBOOT_CONFIG_DIR=/opt/ocboot/_config"
mkdir -p "$config_dir"
if [ $# -eq 1 ]; then
$run_cmd --entrypoint /opt/ocboot/run.py $OCBOOT_IMAGE $@
elif [ $# -ge 2 ]; then
for i in $@ ; do
if [ -f $i ]; then
MOUNT_CONF="-v `pwd`/$i:/opt/ocboot/$i"
fi
done
$run_cmd $MOUNT_CONF $OCBOOT_IMAGE $@
fi