Set up CoreDNS for containers

This sends all requests to *.pretendo.cc or *.pretendo.network coming from inside a container to the nginx container.
This commit is contained in:
Matthew Lopez 2023-12-18 20:42:21 -05:00
parent a500189e83
commit 2bd74b71c4
No known key found for this signature in database
GPG Key ID: 302A6EE3D63B7E0E
2 changed files with 42 additions and 1 deletions

View File

@ -15,11 +15,26 @@ services:
command: mitmweb --web-host 0.0.0.0
tty: true
coredns:
image: coredns/coredns:latest
volumes:
- type: bind
source: ./config/Corefile
target: /etc/coredns/Corefile
networks:
internal:
ipv4_address: 172.20.0.2
command: -conf /etc/coredns/Corefile
nginx:
build: ./nginx
ports:
- 80:80
- 443:443
dns: 172.20.0.2
networks:
default:
internal:
mongodb:
image: mongo:latest
@ -30,6 +45,10 @@ services:
- type: volume
source: mongodb-database
target: /data/db
dns: 172.20.0.2
networks:
internal:
command: --config "/etc/mongod.conf" --replSet rs
minio:
image: minio/minio:latest
@ -44,6 +63,9 @@ services:
source: minio-s3-data
target: /data
command: server /data --console-address ":9090"
dns: 172.20.0.2
networks:
internal:
# redis:
# image: redis:latest
@ -65,10 +87,22 @@ services:
- type: volume
source: account-certificates
target: /app/certs
dns: 172.20.0.2
networks:
internal:
volumes:
mitmproxy-pretendo-data:
mongodb-database:
minio-s3-data:
redis-data:
account-certificates:
networks:
# We need to use a custom network so that we can set a static IP address for
# CoreDNS and use it as a DNS server for the other containers.
internal:
driver: bridge
ipam:
config:
- subnet: 172.20.0.0/16

7
config/Corefile Normal file
View File

@ -0,0 +1,7 @@
. {
log
rewrite name regex .*pretendo\.cc nginx
rewrite name regex .*pretendo\.network nginx
rewrite name regex .*minio minio
forward . /etc/resolv.conf
}