-
-
Save siers/5441b9c3140c91d653d5283c662d79f9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
### BEGIN INIT INFO | |
# Provides: dockercompose | |
# Required-Start: $docker | |
# Required-Stop: $docker | |
# Default-Start: 2 3 4 5 | |
# Default-Stop: 0 1 6 | |
# Short-Description: Docker Services | |
### END INIT INFO | |
set -eu | |
export WEB_PORT="8080" # for docker compose in case of multiple roots | |
PROJECT_NAME='project' | |
MAIN_YAML='/project/root/docker-compose.yml' | |
OVERRIDE_YAML='/project/root/docker-compose.server.yml' | |
OPTS=(-p "$PROJECT_NAME" -f "$MAIN_YAML") | |
UPOPTS=(-d --build) | |
if [ -e "$OVERRIDE_YAML" ]; then | |
OPTS=("${OPTS[@]}" -f "$OVERRIDE_YAML") | |
fi | |
. /lib/lsb/init-functions | |
case "$1" in | |
restart) | |
docker-compose "${OPTS[@]}" stop | |
restart=1 | |
;& | |
stop) | |
log_daemon_msg "Stopping Docker Compose" "dockercompose" || true | |
docker-compose "${OPTS[@]}" stop | |
[ -n "${restart:-}" ] || exit 0 | |
;& | |
reload) | |
;& | |
start) | |
log_daemon_msg "Starting Docker Compose" "dockercompose" || true | |
docker-compose "${OPTS[@]}" up "${UPOPTS[@]}" | |
;; | |
*) | |
log_action_msg "Usage: /etc/init.d/dockercompose {start|stop|restart|reload}" || true | |
exit 1 | |
;; | |
esac | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment