-
Notifications
You must be signed in to change notification settings - Fork 3
/
start.sh
59 lines (52 loc) · 1.75 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
48
49
50
51
52
53
54
55
56
57
58
59
#!/bin/bash
# The current Version of this file can be found HERE:
# https://github.com/pluswerk/php-dev/blob/main/start.sh
[ -f .env ] && . .env
CONTEXT=${CONTEXT:-Development}
USER=${APPLICATION_UID:-1000}:${APPLICATION_GID:-1000}
if [ -z "$SSH_AUTH_SOCK" ]
then
SSH_AGENT_PART=
else
SSH_AGENT_PART="-v $(dirname $SSH_AUTH_SOCK):$(dirname $SSH_AUTH_SOCK) -e SSH_AUTH_SOCK=$SSH_AUTH_SOCK"
fi
function startFunction {
key="$1"
case ${key} in
start)
startFunction pull && \
startFunction build && \
startFunction up && \
startFunction login
return
;;
up)
docker-compose --project-directory . -f compose/${CONTEXT}/docker-compose.yml up -d --remove-orphans
return
;;
down)
docker-compose --project-directory . -f compose/${CONTEXT}/docker-compose.yml down --remove-orphans
return
;;
login)
docker-compose --project-directory . -f compose/${CONTEXT}/docker-compose.yml exec -u $USER web bash
return
;;
login:node)
docker-compose --project-directory . -f compose/${CONTEXT}/docker-compose.yml exec -u $USER node bash
return
;;
# this is useful if you need to have your ssh-agent available for executing a command e.g composer install
# example usage: bash start.sh run-with-agent -T web composer install --no-dev --ansi --verbose
run-with-agent)
docker-compose --project-directory . -f compose/${CONTEXT}/docker-compose.yml run --rm -u $USER --rm --entrypoint= $SSH_AGENT_PART ${@:2}
return
;;
*)
docker-compose --project-directory . -f compose/${CONTEXT}/docker-compose.yml "${@:1}"
return
;;
esac
}
startFunction "${@:1}"
exit $?