Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow dnsmasq service to be disabled #462

Merged
merged 4 commits into from
Jan 17, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions commands/svc.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,28 @@ 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
eval "$(grep "^WARDEN_DNSMASQ_ENABLE" "${WARDEN_HOME_DIR}/.env")"
fi
navarr marked this conversation as resolved.
Show resolved Hide resolved

## add dnsmasq docker-compose
WARDEN_DNSMASQ_ENABLE="${WARDEN_DNSMASQ_ENABLE:-1}"
if [[ "$WARDEN_DNSMASQ_ENABLE" == "1" ]]; then
echo "adding docker-compose.dnsmasq.yml"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is useless message

Suggested change
echo "adding docker-compose.dnsmasq.yml"

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Echo statement removed. Sorry for taking so long, this somehow slipped my mind.

DOCKER_COMPOSE_ARGS+=("-f")
DOCKER_COMPOSE_ARGS+=("${WARDEN_DIR}/docker/docker-compose.dnsmasq.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
38 changes: 38 additions & 0 deletions docker/docker-compose.dnsmasq.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
version: "3.5"
services:

dnsmasq:
container_name: dnsmasq
image: jpillora/dnsmasq
ports:
- "127.0.0.1:53:53/udp"
environment:
WARDEN_DNSMASQ_CONF: |-
#dnsmasq config, for a complete example, see:
# http://oss.segetech.com/intra/srv/dnsmasq.conf

#log all dns queries (enable as-needed for debugging purposes)
# log-queries

#dont use hosts nameservers
no-resolv

#use cloudflare as default nameservers, prefer 1^4
server=${WARDEN_DNSMASQ_NS1:-1.0.0.1}
server=${WARDEN_DNSMASQ_NS2:-1.1.1.1}
strict-order

#explicitly define host-ip mappings
address=/.test/127.0.0.1
${WARDEN_DNSMASQ_CONF_ADDITIONAL:-}

entrypoint: ["/bin/sh", "-c", "
echo \"$$WARDEN_DNSMASQ_CONF\" > /etc/dnsmasq.conf;
webproc --config /etc/dnsmasq.conf -- dnsmasq --no-daemon;
"]
labels:
- traefik.enable=true
- traefik.http.routers.dnsmasq.tls=true
- traefik.http.routers.dnsmasq.rule=Host(`dnsmasq.${WARDEN_SERVICE_DOMAIN:-warden.test}`)
- traefik.http.services.dnsmasq.loadbalancer.server.port=8080
restart: ${WARDEN_RESTART_POLICY:-always}
36 changes: 0 additions & 36 deletions docker/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,42 +31,6 @@ services:
- traefik.http.services.portainer.loadbalancer.server.port=9000
restart: ${WARDEN_RESTART_POLICY:-always}

dnsmasq:
container_name: dnsmasq
image: jpillora/dnsmasq
ports:
- "127.0.0.1:53:53/udp"
environment:
WARDEN_DNSMASQ_CONF: |-
#dnsmasq config, for a complete example, see:
# http://oss.segetech.com/intra/srv/dnsmasq.conf

#log all dns queries (enable as-needed for debugging purposes)
# log-queries

#dont use hosts nameservers
no-resolv

#use cloudflare as default nameservers, prefer 1^4
server=${WARDEN_DNSMASQ_NS1:-1.0.0.1}
server=${WARDEN_DNSMASQ_NS2:-1.1.1.1}
strict-order

#explicitly define host-ip mappings
address=/.test/127.0.0.1
${WARDEN_DNSMASQ_CONF_ADDITIONAL:-}

entrypoint: ["/bin/sh", "-c", "
echo \"$$WARDEN_DNSMASQ_CONF\" > /etc/dnsmasq.conf;
webproc --config /etc/dnsmasq.conf -- dnsmasq --no-daemon;
"]
labels:
- traefik.enable=true
- traefik.http.routers.dnsmasq.tls=true
- traefik.http.routers.dnsmasq.rule=Host(`dnsmasq.${WARDEN_SERVICE_DOMAIN:-warden.test}`)
- traefik.http.services.dnsmasq.loadbalancer.server.port=8080
restart: ${WARDEN_RESTART_POLICY:-always}

mailhog:
container_name: mailhog
image: docker.io/wardenenv/mailhog:1.0
Expand Down