-
Notifications
You must be signed in to change notification settings - Fork 3
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
Add dnsmasq as an optional container #8
base: legacy
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
#!/usr/bin/env bash | ||
set -e | ||
|
||
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" | ||
|
||
cd $DIR | ||
docker build -t liip/pontsun-dnsmasq:latest dnsmasq |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
FROM alpine:edge | ||
|
||
RUN apk --no-cache add dnsmasq | ||
|
||
ADD dnsmasq.conf /etc/ | ||
|
||
EXPOSE 53 53/udp | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would probably avoid creating an image with a root user just in case. |
||
ENTRYPOINT ["dnsmasq", "-d"] |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#dnsmasq config, for a complete example, see: | ||
# http://oss.segetech.com/intra/srv/dnsmasq.conf | ||
#log all dns queries | ||
log-queries | ||
#dont use hosts nameservers | ||
no-resolv | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should we consider |
||
#use cloudflare as default nameservers, prefer 1^4 | ||
server=1.0.0.1 | ||
server=1.1.1.1 | ||
strict-order | ||
conf-dir=/etc/dnsmasq.d/,*.conf |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
version: '3.5' | ||
services: | ||
dns: | ||
image: liip/pontsun-dnsmasq:latest | ||
container_name: pontsun_dns | ||
restart: always | ||
volumes: | ||
- "$PONTSUN_DIR_ETC/dnsmasq.d/:/etc/dnsmasq.d/" | ||
ports: | ||
- 53:53/udp | ||
networks: | ||
- pontsun | ||
logging: | ||
options: | ||
max-size: 20m |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
#!/usr/bin/env bash | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe this part should added to |
||
set -e | ||
|
||
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" | ||
PONTSUN_DNS=$(docker inspect -f '{{.State.Running}}' pontsun_dns 2> /dev/null || echo 'false') | ||
|
||
if [[ $PONTSUN_DNS == 'true' ]]; then | ||
DOCKER_COMPOSE="docker-compose -f docker-compose.yml -f docker-compose.dns.yml" | ||
cd $DIR/../containers/ | ||
if $DOCKER_COMPOSE exec dns ash -c "if [[ -f /etc/dnsmasq.d/$1.conf ]]; then exit 1; fi; echo address=/$1/127.0.0.1 > /etc/dnsmasq.d/$1.conf" | ||
then | ||
$DOCKER_COMPOSE restart dns | ||
fi | ||
else | ||
# no DNS container. | ||
# write it to system dnsmasq | ||
|
||
if [[ "$OSTYPE" == "darwin"* ]]; then | ||
ETC_PREFIX=$(brew --prefix)'/etc' | ||
else | ||
ETC_PREFIX='/etc' | ||
fi | ||
|
||
if [[ ! -d $ETC_PREFIX/dnsmasq.d/ ]]; then | ||
RED='\033[0;31m' | ||
NC='\033[0m' # No Color | ||
|
||
printf "${RED}pontsun_dns is not running and can't find $ETC_PREFIX/dnsmasq.d${NC}\n" | ||
printf "Please install dnsmasq locally or start potsun_dns" | ||
exit 1 | ||
fi | ||
|
||
if [[ ! -f $ETC_PREFIX/dnsmasq.d/$1.conf ]]; then | ||
if [[ "$OSTYPE" == "darwin"* ]]; then | ||
echo address=/$1/127.0.0.1 > $ETC_PREFIX/dnsmasq.d/$1.conf | ||
echo 'strict-order' >> $ETC_PREFIX/dnsmasq.d/$1.conf | ||
else | ||
echo address=/$1/127.0.0.1 | sudo tee $ETC_PREFIX/dnsmasq.d/$1.conf | ||
echo 'strict-order' | sudo tee --append $ETC_PREFIX/dnsmasq.d/$1.conf | ||
fi | ||
echo "dnsmasq entry updated, you may restart it to take effect." | ||
else | ||
echo "No dnsmasq changes done, $ETC_PREFIX/dnsmasq.d/$1.conf already exists." | ||
fi | ||
fi | ||
|
||
if [[ "$OSTYPE" == "darwin"* ]] && [[ ! -f /etc/resolver/$1 ]]; then | ||
echo "Adding to /etc/resolver/$1" | ||
sudo mkdir -vp /etc/resolver | ||
sudo bash -c "echo 'nameserver 127.0.0.1' > /etc/resolver/$1" | ||
fi |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ideally this should not be part of this repo but available as a global image on the Liip docker registry.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
where would you put the Dockerfile then?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe in a dedicated repo so it can be managed in parallel of Pontsun. But this can be later of course.