Skip to content

Commit

Permalink
Added ~/.warden/.env with variables to allow overriding aspects of gl…
Browse files Browse the repository at this point in the history
…obal services

issue #13
  • Loading branch information
davidalger committed Jan 29, 2020
1 parent 5ffdf28 commit 5073c5b
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 13 deletions.
3 changes: 2 additions & 1 deletion commands/down.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@
[[ ! ${WARDEN_COMMAND} ]] && >&2 echo -e "\033[31mThis script is not intended to be run directly!" && exit 1

pushd "${WARDEN_DIR}" >/dev/null
docker-compose -p warden -f docker/docker-compose.yml down "${WARDEN_PARAMS[@]}" "$@"
docker-compose -p warden --env-file "${WARDEN_HOME_DIR}/.env" \
-f docker/docker-compose.yml down "${WARDEN_PARAMS[@]}" "$@"
3 changes: 2 additions & 1 deletion commands/restart.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ source "${WARDEN_DIR}/utils/install.sh"
assertWardenInstall

pushd "${WARDEN_DIR}" >/dev/null
docker-compose -p warden -f docker/docker-compose.yml restart "${WARDEN_PARAMS[@]}" "$@"
docker-compose -p warden --env-file "${WARDEN_HOME_DIR}/.env" \
-f docker/docker-compose.yml restart "${WARDEN_PARAMS[@]}" "$@"
4 changes: 3 additions & 1 deletion commands/sign-certificate.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,9 @@ openssl x509 -req -days 365 -sha256 -extensions v3_req \
-in "${WARDEN_SSL_DIR}/certs/${CERTIFICATE_NAME}.csr.pem" \
-out "${WARDEN_SSL_DIR}/certs/${CERTIFICATE_NAME}.crt.pem"

if [[ "$(cd "${WARDEN_DIR}" && docker-compose -p warden -f docker/docker-compose.yml ps -q traefik)" ]]; then
if [[ "$(cd "${WARDEN_DIR}" && docker-compose -p warden --env-file "${WARDEN_HOME_DIR}/.env" \
-f docker/docker-compose.yml ps -q traefik)" ]]
then
echo "==> Updating traefik"
"${WARDEN_DIR}/bin/warden" up traefik
"${WARDEN_DIR}/bin/warden" restart traefik
Expand Down
3 changes: 2 additions & 1 deletion commands/start.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ source "${WARDEN_DIR}/utils/install.sh"
assertWardenInstall

pushd "${WARDEN_DIR}" >/dev/null
docker-compose -p warden -f docker/docker-compose.yml start "${WARDEN_PARAMS[@]}" "$@"
docker-compose -p warden --env-file "${WARDEN_HOME_DIR}/.env" \
-f docker/docker-compose.yml start "${WARDEN_PARAMS[@]}" "$@"
3 changes: 2 additions & 1 deletion commands/stop.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@
[[ ! ${WARDEN_COMMAND} ]] && >&2 echo -e "\033[31mThis script is not intended to be run directly!" && exit 1

pushd "${WARDEN_DIR}" >/dev/null
docker-compose -p warden -f docker/docker-compose.yml stop "${WARDEN_PARAMS[@]}" "$@"
docker-compose -p warden --env-file "${WARDEN_HOME_DIR}/.env" \
-f docker/docker-compose.yml stop "${WARDEN_PARAMS[@]}" "$@"
3 changes: 2 additions & 1 deletion commands/up.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,5 @@ for cert in $(find "${WARDEN_SSL_DIR}/certs" -type f -name "*.crt.pem" | sed -E
done

pushd "${WARDEN_DIR}" >/dev/null
docker-compose -p warden -f docker/docker-compose.yml up -d "${WARDEN_PARAMS[@]}" "$@"
docker-compose -p warden --env-file "${WARDEN_HOME_DIR}/.env" \
-f docker/docker-compose.yml up -d "${WARDEN_PARAMS[@]}" "$@"
14 changes: 7 additions & 7 deletions docker/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ version: "3.5"
services:
traefik:
container_name: traefik
image: traefik:2.1
image: traefik:${TRAEFIK_VERSION:-2.1}
ports:
- "127.0.0.1:80:80" # The HTTP port
- "127.0.0.1:443:443" # The HTTPS port
- "${TRAEFIK_LISTEN:-127.0.0.1}:80:80" # The HTTP port
- "${TRAEFIK_LISTEN:-127.0.0.1}:443:443" # The HTTPS port
volumes:
- ~/.warden/etc/traefik/traefik.yml:/etc/traefik/traefik.yml
- ~/.warden/etc/traefik/dynamic.yml:/etc/traefik/dynamic.yml
Expand All @@ -20,7 +20,7 @@ services:
- traefik.http.routers.traefik.tls=true
- traefik.http.routers.traefik.rule=Host(`traefik.warden.test`)
- traefik.http.routers.traefik.service=api@internal
restart: always
restart: ${WARDEN_RESTART_POLICY:-always}

portainer:
container_name: portainer
Expand All @@ -33,7 +33,7 @@ services:
- traefik.http.routers.portainer.tls=true
- traefik.http.routers.portainer.rule=Host(`portainer.warden.test`)
- traefik.http.services.portainer.loadbalancer.server.port=9000
restart: always
restart: ${WARDEN_RESTART_POLICY:-always}

dnsmasq:
container_name: dnsmasq
Expand All @@ -47,7 +47,7 @@ services:
- traefik.http.routers.dnsmasq.tls=true
- traefik.http.routers.dnsmasq.rule=Host(`dnsmasq.warden.test`)
- traefik.http.services.dnsmasq.loadbalancer.server.port=8080
restart: always
restart: ${WARDEN_RESTART_POLICY:-always}

tunnel:
container_name: tunnel
Expand All @@ -67,7 +67,7 @@ services:
- SSH_USERS=user:2000:2000
- TCP_FORWARDING=true
restart: always
restart: ${WARDEN_RESTART_POLICY:-always}

volumes:
portainer:
Expand Down

0 comments on commit 5073c5b

Please sign in to comment.