This repository was archived by the owner on Jul 16, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathactivate
More file actions
107 lines (86 loc) · 3.33 KB
/
activate
File metadata and controls
107 lines (86 loc) · 3.33 KB
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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
#!/usr/bin/env bash
# To use this file, run `source activate` and `helpme` to view usage.
function helpme {
cat <<HELP_USAGE
Production:
dc [options] => docker-compose [options]
dcup => Starts a Docker container in detached mode
dcdown => Destroys the started Docker container
dcrestart => Destroys and creates a new Docker container
dcx <subsystem> [command] => docker-compose exec <subsystem> [command]
setversion <version number> => Sets the VERSION_TAG environment variable
setlatest => Sets the VERSION_TAG environment variable to the latest version available on GitHub
The setlatest command requires curl and python to be installed.
Development:
devmode => Sets the COMPOSE_PROJECT_NAME environment variable.
dcd [options] => docker-compose -f docker-compose.dev.yml [options]
dcdup => Builds the development Docker container using the docker-compose.dev.yml file
dcddown => Destroys the development Docker container
dcdrestart => Destroys and builds a new development Docker container
dcdx <subsystem> [command] => docker-compose -f docker-compose.dev.yml exec <subsystem> [command]
dcdsetup => Runs the setup commands within the development Docker container
dcdbuild => Rebuilds the development Docker container without using the cache
dcdresetall => Deletes all Docker volumes of the development environment
setdevref <ref> => Sets the developer target reference. Can be a branch, tag, or specific commit hash.
HELP_USAGE
}
##############
# Production #
##############
function is_shipper_version_tag_set {
if [ -z "$VERSION_TAG" ]; then
echo "Error: the version tag is not set. Stopping..."
return 1
fi
return 0
}
function dc {
if is_shipper_version_tag_set; then
docker-compose "$@"
fi
}
function dcup {
if is_shipper_version_tag_set; then
docker-compose up -d "$@"
fi
}
function dcdown {
if is_shipper_version_tag_set; then
docker-compose down "$@"
fi
}
alias dcrestart='dcdown && dcup'
function dcx {
if is_shipper_version_tag_set; then
docker-compose exec "$@"
fi
}
function setversion {
export VERSION_TAG=$1
}
function setlatest {
export VERSION_TAG=$(curl -s https://api.github.com/repos/shipperstack/shipper/releases/latest | python -c "import sys, json; print json.load(sys.stdin)['name']")
echo "The latest release on GitHub is $VERSION_TAG."
}
###############
# Development #
###############
alias devmode='export COMPOSE_PROJECT_NAME="shipper_dev" && echo "Developer mode is now active!"'
alias dcd='docker-compose -f docker-compose.dev.yml'
alias dcdup='docker-compose -f docker-compose.dev.yml up -d --build'
alias dcddown='docker-compose -f docker-compose.dev.yml down'
alias dcdrestart='dcddown && dcdup'
alias dcdx='docker-compose -f docker-compose.dev.yml exec'
alias dcdsetup='./django-update.sh developer'
alias dcdbuild='docker-compose -f docker-compose.dev.yml build --no-cache'
function dcdresetall {
echo "Deleting all development Docker volumes..."
docker volume rm ${COMPOSE_PROJECT_NAME}_media_volume
docker volume rm ${COMPOSE_PROJECT_NAME}_static_volume
docker volume rm ${COMPOSE_PROJECT_NAME}_postgres_data
echo "Finished deleting all development Docker volumes!"
}
function setdevref {
export SHIPPER_DEV_TARGET_REF=$1
}
echo "Finished loading commands for shipper-docker. Run helpme for usage."