forked from jarnovanleeuwen/laravel-dock
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdock
executable file
·87 lines (65 loc) · 2.21 KB
/
dock
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
#!/usr/bin/env bash
set -e
source .env
APP_USER="webdev"
BUILD_DIR="build/"
DOCKERFILE="${BUILD_DIR}/Dockerfile"
COMPOSE_BASE="${BUILD_DIR}docker-compose.yml"
COMPOSE_LOCAL="${BUILD_DIR}docker-compose.local.yml"
COMPOSE_PROD="${BUILD_DIR}docker-compose.prod.yml"
COMPOSE="docker-compose -f ${COMPOSE_BASE} -f ${COMPOSE_LOCAL}"
if [ $# -gt 0 ]; then
if [ "$1" == "up" ]; then
${COMPOSE} up --build --detach app
elif [ "$1" == "scheduler" ]; then
${COMPOSE} up --build scheduler
elif [ "$1" == "queue" ]; then
${COMPOSE} up --build queue
elif [ "$1" == "down" ]; then
${COMPOSE} down
elif [ "$1" == "tail" ]; then
${COMPOSE} logs --follow
elif [ "$1" == "restart" ]; then
./$0 down
./$0 up
elif [ "$1" == "push" ]; then
docker push ${DOCKER_REPOSITORY}
elif [ "$1" == "login" ]; then
docker login -u ${REGISTRY_USER} -p ${REGISTRY_PASSWORD} ${REGISTRY}
elif [ "$1" == "build" ]; then
docker build --file ${DOCKERFILE} --target production --tag ${DOCKER_REPOSITORY} .
elif [ "$1" == "deploy" ]; then
read -p "Are you sure you want to deploy [${DOCKER_REPOSITORY}] to [${DEPLOY_SERVER}]? (y/N) " -r
echo
if [[ $REPLY =~ ^[Yy]$ ]]; then
echo -n "Uploading deployment configuration..."
ssh ${DEPLOY_SERVER} "mkdir -p ${APP_ID}"
scp -r dock dock-swarm ${BUILD_DIR} ${DEPLOY_SERVER}:~/${APP_ID} > /dev/null && echo "OK"
ssh ${DEPLOY_SERVER} "cd ${APP_ID} && ./dock-swarm deploy"
fi
elif [ "$1" == "deploy-migrations" ]; then
read -p "Are you sure you want to run database migrations on [${DEPLOY_SERVER}]? (y/N) " -r
echo
if [[ $REPLY =~ ^[Yy]$ ]]; then
ssh ${DEPLOY_SERVER} "cd ${APP_ID} && ./dock-swarm deploy-migrations"
fi
elif [ "$1" == "clean" ]; then
docker system prune
elif [ "$1" == "exec" ]; then
shift 1
ARGS="$@"
${COMPOSE} exec --user ${APP_USER} app bash -c "$ARGS"
elif [ "$1" == "test" ]; then
shift 1
ARGS="$@"
${COMPOSE} exec --user ${APP_USER} app bash -c "vendor/bin/phpunit $ARGS"
elif [ "$1" == "artisan" ]; then
shift 1
ARGS="$@"
${COMPOSE} exec --user ${APP_USER} app bash -c "php artisan $ARGS"
else
${COMPOSE} "$@"
fi
else
${COMPOSE} ps
fi