Skip to content

Commit

Permalink
Make global portainer service optional
Browse files Browse the repository at this point in the history
  • Loading branch information
bap14 authored and navarr committed Jan 17, 2023
1 parent 5a24ca7 commit 03783b6
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 17 deletions.
10 changes: 10 additions & 0 deletions commands/install.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -85,3 +85,13 @@ fi

## append settings for tunnel.warden.test in /etc/ssh/ssh_config
installSshConfig

## Add optional Warden configuration file
if [[ ! -f "${WARDEN_HOME_DIR}/.env" ]]; then
cat >> "${WARDEN_HOME_DIR}/.env" <<-EOT
# Set to "1" to enable global Portainer service
WARDEN_PORTAINER_ENABLE=0
# SEt to "0" to disable DNSMasq
WARDEN_DNSMASQ_ENABLE=1
EOT
fi
13 changes: 9 additions & 4 deletions commands/svc.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,11 @@ DOCKER_COMPOSE_ARGS=()
DOCKER_COMPOSE_ARGS+=("-f")
DOCKER_COMPOSE_ARGS+=("${WARDEN_DIR}/docker/docker-compose.yml")


## check if dnsmasq is enabled
if [[ -f "${WARDEN_HOME_DIR}/.env" ]]; then
# Check DNSMasq
eval "$(grep "^WARDEN_DNSMASQ_ENABLE" "${WARDEN_HOME_DIR}/.env")"
# Check Portainer
eval "$(grep "^WARDEN_PORTAINER_ENABLE" "${WARDEN_HOME_DIR}/.env")"
fi

## add dnsmasq docker-compose
Expand All @@ -31,14 +32,18 @@ if [[ "$WARDEN_DNSMASQ_ENABLE" == "1" ]]; then
DOCKER_COMPOSE_ARGS+=("${WARDEN_DIR}/docker/docker-compose.dnsmasq.yml")
fi

WARDEN_PORTAINER_ENABLE="${WARDEN_PORTAINER_ENABLE:-0}"
if [[ "${WARDEN_PORTAINER_ENABLE}" == 1 ]]; then
DOCKER_COMPOSE_ARGS+=("-f")
DOCKER_COMPOSE_ARGS+=("${WARDEN_DIR}/docker/docker-compose.portainer.yml")
fi

## allow an additional docker-compose file to be loaded for global services
if [[ -f "${WARDEN_HOME_DIR}/docker-compose.yml" ]]; then
DOCKER_COMPOSE_ARGS+=("-f")
DOCKER_COMPOSE_ARGS+=("${WARDEN_HOME_DIR}/docker-compose.yml")
fi


## special handling when 'svc up' is run
if [[ "${WARDEN_PARAMS[0]}" == "up" ]]; then

Expand Down Expand Up @@ -82,7 +87,7 @@ if [[ "${WARDEN_PARAMS[0]}" == "up" ]]; then
fi

## pass ochestration through to docker-compose
docker-compose \
WARDEN_SERVICE_DIR=${WARDEN_DIR} docker-compose \
--project-directory "${WARDEN_HOME_DIR}" -p warden \
"${DOCKER_COMPOSE_ARGS[@]}" "${WARDEN_PARAMS[@]}" "$@"

Expand Down
14 changes: 14 additions & 0 deletions docker/docker-compose.portainer.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
version: "3.5"
services:
portainer:
container_name: portainer
image: portainer/portainer-ce
volumes:
- /var/run/docker.sock:/var/run/docker.sock
- portainer:/data
labels:
- traefik.enable=true
- traefik.http.routers.portainer.tls=true
- traefik.http.routers.portainer.rule=Host(`portainer.${WARDEN_SERVICE_DOMAIN:-den.test}`)||Host(`portainer.warden.test`)
- traefik.http.services.portainer.loadbalancer.server.port=9000
restart: ${WARDEN_RESTART_POLICY:-always}
13 changes: 0 additions & 13 deletions docker/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,6 @@ services:
- traefik.http.routers.traefik.service=api@internal
restart: ${WARDEN_RESTART_POLICY:-always}

portainer:
container_name: portainer
image: portainer/portainer-ce
volumes:
- /var/run/docker.sock:/var/run/docker.sock
- portainer:/data
labels:
- traefik.enable=true
- traefik.http.routers.portainer.tls=true
- traefik.http.routers.portainer.rule=Host(`portainer.${WARDEN_SERVICE_DOMAIN:-warden.test}`)
- traefik.http.services.portainer.loadbalancer.server.port=9000
restart: ${WARDEN_RESTART_POLICY:-always}

mailhog:
container_name: mailhog
image: wardenenv/mailhog:1.0
Expand Down

0 comments on commit 03783b6

Please sign in to comment.