-
Notifications
You must be signed in to change notification settings - Fork 55
/
docker.sh
executable file
·60 lines (50 loc) · 1.67 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
#!/usr/bin/env bash
function die() { echo "ERROR: $*" 1>&2 ; exit 1; }
TMPDIR=$(mktemp -d)
REPO_PATH=$(cd $(dirname $0)/..; pwd)
if [ "x$1" = "xalias" ]; then
if [ -f ~/.bash_profile ]; then
sed -i.back '/^alias chi=/d' ~/.bash_profile
lastline=$(tail -n 1 ~/.bash_profile; echo x); lastline=${lastline%x}
if [ "${lastline: -1}" != $'\n' ]; then
echo >> ~/.bash_profile
fi
echo "alias chi=\"${REPO_PATH}/scripts/docker.sh\"" >> ~/.bash_profile
echo "execute: . ~/.bash_profile"
fi
exit 0
fi
cp ${REPO_PATH}/Dockerfile ${TMPDIR}/
cp ${REPO_PATH}/package.json ${TMPDIR}/package_chi.json
cp ${REPO_PATH}/src/documentation/package.json ${TMPDIR}/package_documentation.json
cp ${REPO_PATH}/scripts/entrypoint.sh ${TMPDIR}/
pushd "${TMPDIR}" > /dev/null
docker build -t chi:latest .
popd >/dev/null
rm -rf ${TMPDIR}
# docker system prune -f 2>&1 >/dev/null &
if [ ! -d "${REPO_PATH}/node_modules" ]
then
mkdir ${REPO_PATH}/node_modules 2>/dev/null || die "${REPO_PATH}/node_modules must exists and be a directory"
fi
if [ ! -d "${REPO_PATH}/src/documentation/node_modules" ]
then
mkdir ${REPO_PATH}/src/documentation/node_modules 2>/dev/null || die "${REPO_PATH}/src/documentation/node_modules must exists and be a directory"
fi
if [ "x$1" = "xstart" ]; then
docker run --rm -it --name chi \
--privileged \
-e GH_TOKEN=${GH_TOKEN} \
-v ${REPO_PATH}:/chi \
-p 8000:8000 \
-p 8001:8001 \
-p 3000:3000 \
chi
else
docker run --rm -ti \
--privileged \
--shm-size=2gb \
--cap-add=SYS_ADMIN \
-v ${REPO_PATH}:/chi \
chi $1
fi