forked from SamSpiri/infra-workspace
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstart.sh
executable file
·47 lines (40 loc) · 1.34 KB
/
start.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
#!/bin/bash
export MY_PATH="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
export MY_HOMEPATH="$( cd >/dev/null 2>&1 && pwd )"
export MY_PARENT=$(dirname "${MY_PATH}")
export CONTAINER_NAME="${MY_PARENT}"
export xUID=$(id -u)
export xGID=$(id -g)
export xGID_DOCKER=$(stat -c '%g' /var/run/docker.sock)
[[ -z "$USERNAME" ]] && export USERNAME="$USER"
export BUILDKIT_PROGRESS=plain
unameOut="$(uname -s)"
case "${unameOut}" in
Linux*) machine=Linux;;
Darwin*) machine=Mac;;
CYGWIN*) machine=Windows;;
MINGW*) machine=Windows;;
*) machine="UNKNOWN:${unameOut}"
esac
if [ "$machine" == "Windows" ] ; then
WINPTY="winpty"
else
if [ $(id -u) -eq "0" ]; then
echo "Doesn't work when launched as root."
exit 1
fi
SUDO="sudo -EHu app"
if ! type docker-compose >/dev/null 2>&1; then
sudo curl -L "https://github.com/docker/compose/releases/latest/download/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose
fi
fi
pushd "$MY_PATH"
if [ "$1" == "build" ]; then
docker pull opuscapita/toolbox:latest && \
docker-compose --ansi=never build && \
exec $WINPTY docker-compose --ansi=never run --rm -e TERM -e COLORTERM main
else
exec $WINPTY docker-compose --ansi=never run --rm -e TERM -e COLORTERM main
fi
popd