Skip to content

Commit

Permalink
feat: resolve environment domain to traefik by default instead of nginx
Browse files Browse the repository at this point in the history
  • Loading branch information
janosmiko committed Feb 12, 2021
1 parent 0efe323 commit 119d073
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 20 deletions.
2 changes: 1 addition & 1 deletion VERSION.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.1.15-beta
0.1.16-beta
14 changes: 13 additions & 1 deletion docs/configuration/dns-resolver.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
In order to allow automatic DNS resolution using the provided dnsmasq service we will need to make sure
DNS request are routed through our local network. This requires some configuration.

#### Windows
### Windows

You will have to add a local DNS resolver and utilize dnsmasq to resolve the *.test domain.

Expand Down Expand Up @@ -100,3 +100,15 @@ When your systemd-resolved is ready, run reinstall reward's DNS settings and res
$ reward install --dns
$ sudo systemctl restart systemd-resolved
```


### DNS resolution to Traefik inside docker network

By default inside the environment's docker network the environment's hostname will be resolved to the traefik container's
IP address.

To change this behaviour you can disable it using the following setting in `~/.reward.yml`

```
reward_resolve_domain_to_traefik: 0
```
11 changes: 0 additions & 11 deletions docs/configuration/nginx.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,14 +69,3 @@ server: nginx/1.16.1
content-length: 169

```

### DNS resolution to nginx inside docker network

By default inside the environment's docker network the environment's hostname will be resolved to the nginx container's
IP address.

To change this behaviour you can disable it using the following setting in `~/.reward.yml`

```
reward_resolve_domain_to_nginx: 0
```
10 changes: 10 additions & 0 deletions internal/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,10 @@ func IsBlackfireEnabled() bool {
return viper.GetString(AppName+"_blackfire") == "1"
}

func ResolveDomainToTraefik() bool {
return viper.GetBool(AppName + "_resolve_domain_to_traefik")
}

// func GetSeleniumEnabled() bool {
// return viper.GetString(AppName+"_selenium") == "1" && viper.GetString(AppName+"_selenium_debug") == "1"
// }
Expand Down Expand Up @@ -793,6 +797,10 @@ func DockerPeeredServices(action, networkName string) error {
for _, v := range dockerPeeredServices {
networkSettings := new(network.EndpointSettings)

if v == "traefik" && ResolveDomainToTraefik() {
networkSettings.Aliases = []string{GetTraefikFullDomain()}
}

f := filters.NewArgs()

f.Add("name", v)
Expand All @@ -809,11 +817,13 @@ func DockerPeeredServices(action, networkName string) error {
for _, container := range containers {
if action == "connect" {
log.Debugf("Connecting container: %v to network %v.", container.Names, networkName)

err = client.NetworkConnect(ctx, networkName, container.ID, networkSettings)

if err != nil {
log.Debugf("%v", err)
}

}

if action == "disconnect" {
Expand Down
2 changes: 1 addition & 1 deletion internal/install.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ debug: false
# By default Reward makes it possible to resolve the environment's domain to the nginx container's IP address
# inside the docker network. To disable this behaviour you can uncomment the following line.
#reward_resolve_domain_to_nginx: 0
#reward_resolve_domain_to_traefik: 0
# By default Reward is not allowed to run commands as root.
# To disable this check you can uncomment the following line.
Expand Down
6 changes: 0 additions & 6 deletions templates/environments/includes/nginx.base.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,3 @@ services:
- ./{{default ".reward/nginx/" .nginx_custom_configs_path}}:/etc/nginx/snippets/
environment:
- XDEBUG_CONNECT_BACK_HOST=${XDEBUG_CONNECT_BACK_HOST:-''}
{{if isEnabledPermissive .reward_resolve_domain_to_nginx}}
networks:
default:
aliases:
- {{.traefik_domain}}
{{end}}

0 comments on commit 119d073

Please sign in to comment.