From 3fa3b3384f186da3510f81a70f362be493ac8058 Mon Sep 17 00:00:00 2001 From: Quo-Studio Date: Mon, 20 Feb 2023 10:16:36 +0100 Subject: [PATCH] first commit | makeFile and .env modified --- .env | 2 +- Makefile | 25 +++++++++++++------------ README.md | 5 +++++ docker-compose.yml | 4 ++-- 4 files changed, 21 insertions(+), 15 deletions(-) diff --git a/.env b/.env index ee5376a..ca3dde6 100644 --- a/.env +++ b/.env @@ -1,2 +1,2 @@ LOCAL_DOMAIN=docker.local -SUB_DOMAINS= +SUB_DOMAINS=*.env.docker.local \ No newline at end of file diff --git a/Makefile b/Makefile index f628295..949c771 100644 --- a/Makefile +++ b/Makefile @@ -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; @@ -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; \ No newline at end of file diff --git a/README.md b/README.md index 53dd2c8..d487dbf 100644 --- a/README.md +++ b/README.md @@ -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. diff --git a/docker-compose.yml b/docker-compose.yml index c6f1797..8d01933 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -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: