Skip to content
Open
Show file tree
Hide file tree
Changes from all 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
2 changes: 1 addition & 1 deletion .env
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
LOCAL_DOMAIN=docker.local
SUB_DOMAINS=
SUB_DOMAINS=*.env.docker.local
25 changes: 13 additions & 12 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -28,39 +28,40 @@ logs: ## Show containers logs
@docker-compose logs -f;

generate_certificate: ## Generate a trusted certificate for local domain
echo "${PWD}/certs";
@docker run --rm \
-v ${PWD}/certs:/opt/mkcert/data \
--workdir /opt/mkcert/data \
-e CAROOT=/opt/mkcert/data \
-v ${PWD}/certs://opt/mkcert/data \
--workdir //opt/mkcert/data \
-e CAROOT=//opt/mkcert/data \
flesch/mkcert:latest \
mkcert -key-file ${LOCAL_DOMAIN}.key -cert-file ${LOCAL_DOMAIN}.crt *.${LOCAL_DOMAIN} ${SUB_DOMAINS} \
mkcert -key-file "${LOCAL_DOMAIN}".key -cert-file "${LOCAL_DOMAIN}".crt *.${LOCAL_DOMAIN} ${SUB_DOMAINS} \
; \
sudo security add-trusted-cert -d -r trustRoot -k /Library/Keychains/System.keychain ${PWD}/certs/rootCA.pem \
certutil -addstore -f "ROOT" ${PWD}/certs/rootCA.pem \
;

remove_certificate: ## Remove certificate generated for local domain
@rm ${PWD}/certs/${LOCAL_DOMAIN}.key && \
rm ${PWD}/certs/${LOCAL_DOMAIN}.crt && \
sudo security remove-trusted-cert -d ${PWD}/certs/rootCA.pem && \
rm ${PWD}/certs/rootCA-key.pem && \
certutil -delstore "ROOT" ${PWD}/certs/rootCA.pem && \
rm ${PWD}/certs/rootCA-key.pem -f && \
rm ${PWD}/certs/rootCA.pem \
;

generate_dnsmasq_config: ## Generate dnsmasq config in host
@cp ${PWD}/dnsmasq.conf.dist ${PWD}/dnsmasq-ext.conf && \
cp ${PWD}/dnsmasq.conf.dist ${PWD}/dnsmasq-int.conf && \
sudo bash -c 'echo "address=/.${LOCAL_DOMAIN}/127.0.0.1" >> ${PWD}/dnsmasq-ext.conf' && \
sudo bash -c 'echo "address=/.${LOCAL_DOMAIN}/172.25.0.255" >> ${PWD}/dnsmasq-int.conf' \
bash -c 'echo "address=/.${LOCAL_DOMAIN}/127.0.0.1" >> ${PWD}/dnsmasq-ext.conf' && \
bash -c 'echo "address=/.${LOCAL_DOMAIN}/172.25.0.255" >> ${PWD}/dnsmasq-int.conf' \
;

remove_dsnmasq_config: ## Remove dnsmasq config generated in host
@rm ${PWD}/dnsmasq-ext.conf && rm ${PWD}/dnsmasq-int.conf;

add_resolver: ## Add resolver for local domain in host
@sudo mkdir -p /etc/resolver && sudo bash -c 'echo "nameserver 127.0.0.1" > /etc/resolver/${LOCAL_DOMAIN}';
@mkdir -p /etc/resolver && bash -c 'echo "nameserver 127.0.0.1" > /etc/resolver/${LOCAL_DOMAIN}';

remove_resolver: ## Remove resolver for local domain in host
@sudo rm /etc/resolver/${LOCAL_DOMAIN};
@rm /etc/resolver/${LOCAL_DOMAIN};

terminal: ## Enter in nginx-proxy terminal
@docker exec -it nginx-proxy /bin/bash;
Expand All @@ -69,4 +70,4 @@ terminal-dnsmasq-ext: ## Enter in dnsmasq for host terminal
@docker exec -it dnsmasq-ext /bin/sh;

terminal-dnsmasq-int: ## Enter in dnsmasq for containers terminal
@docker exec -it dnsmasq-int /bin/sh;
@docker exec -it dnsmasq-int /bin/sh;
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Docker dev routing

> ⚠️ For Windows
>
> Use the git bash terminal with administrator rights to use makeFile commands


> This project is a Docker stack handling routing to containers during development.

When you come to work with docker locally, you can expose your containers on a given host ports, or eventually, you bind them to an url, and with a solution like jwilder/nginx-proxy, you achieve that goal pretty easily. But, because there is always a but, you have to update your /etc/hosts. And if you want your containers to communicate through their respective url, you will have to bind them (for example with option `--link my-container-name:my-freaky-url.test`). Furthermore, this linking makes them now codependant, and you can not run one without the other.
Expand Down
4 changes: 2 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ services:
ipv4_address: 172.25.0.255
ports:
- 80:80
- 443:443
# - 443:443
volumes:
- ./nginx-proxy.conf:/etc/nginx/conf.d/my_proxy.conf:ro
- /var/run/docker.sock:/tmp/docker.sock:ro
- ./certs:/etc/nginx/certs:ro
#- ./certs:/etc/nginx/certs:ro
restart: unless-stopped
# Dnsmasq for host
dnsmasq-ext:
Expand Down