Last active
March 18, 2022 03:28
-
-
Save khusseini/508c887e916d67f64166609cdfe7abda to your computer and use it in GitHub Desktop.
Update your #hosts file to point to #docker #container #ip
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Update your hosts file to point to docker container ip | |
MAKEFLAGS += --warn-undefined-variables | |
SHELL := bash | |
.SHELLFLAGS := -eu -o pipefail -c | |
.DELETE_ON_ERROR: | |
.SUFFIXES: | |
##Option: Development domain | |
domain = mysite.development.local | |
container = mysite | |
define container_ip | |
docker inspect \ | |
--format '{{ .NetworkSettings.Networks.haneudevelopment_orocommerce.IPAddress }}' \ | |
$$(docker ps | grep $(container) | awk '{print $$1}') | |
endef | |
.PHONY: host | |
host: | |
# Updating /etc/hosts file | |
@grep -q '$(strip $(domain))' /etc/hosts \ | |
&& sudo sed \ | |
-i 's/^.* $(strip $(domain))//' \ | |
/etc/hosts; \ | |
echo "$$($(container_ip)) $(strip $(domain))" | sudo tee --append /etc/hosts |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment