Skip to content

Commit

Permalink
Support xdebug on Docker Toolbox, fixes #1297 (#1391)
Browse files Browse the repository at this point in the history
* Support xdebug on Docker Toolbox, fixes #1297

* Add actual test for Xdebug

* Various test improvements

* Give more time for bgsync to come up in TestWebserverType()

* Add docs on docker toolbox firewall disable
  • Loading branch information
rfay committed Jan 23, 2019
1 parent 105201d commit 1aa0109
Show file tree
Hide file tree
Showing 8 changed files with 146 additions and 102 deletions.
5 changes: 2 additions & 3 deletions cmd/ddev/cmd/logs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,10 @@ import (
"github.com/drud/ddev/pkg/ddevapp"
"github.com/drud/ddev/pkg/fileutil"
"github.com/drud/ddev/pkg/version"
"os"
"path/filepath"
"testing"

"os"

"github.com/drud/ddev/pkg/exec"
"github.com/drud/ddev/pkg/testcommon"
asrt "github.com/stretchr/testify/assert"
Expand Down Expand Up @@ -46,7 +45,7 @@ func TestLogs(t *testing.T) {
ddevapp.WaitForSync(app, 2)

url := "http://" + v.Name + "." + version.DDevTLD + "/logtest.php"
_, _, err = testcommon.GetLocalHTTPResponse(t, url)
_, err = testcommon.EnsureLocalHTTPContent(t, url, "Notice to demonstrate logging", 5)
assert.NoError(err)

args := []string{"logs"}
Expand Down
5 changes: 3 additions & 2 deletions docs/developers/buildkite-testmachine-setup.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ We are using [Buildkite](https://buildkite.com/drud) for Windows and macOS testi

0. Create the user "testbot" on the machine. The password should be the password of testbot@drud.com.
1. Install [chocolatey](https://chocolatey.org/)
2. Install golang/mysql-cli/make/git/docker-ce/nssm with `choco install -y git mysql-cli golang make docker-desktop nssm GoogleChrome zip jq composer cmder` (If docker-toolbox, use that instead; you may have to download the release separately to get correct version.)
2. Install golang/mysql-cli/make/git/docker-ce/nssm with `choco install -y git mysql-cli golang make docker-desktop nssm GoogleChrome zip jq composer cmder netcat` (If docker-toolbox, use that instead; you may have to download the release separately to get correct version.)
3. Enable gd and curl extensions in /c/tools/php73/php.ini
3. Install bats: `git clone git://github.com/bats-core/bats-core; cd bats-core; git checkout v1.1.0; ./install.sh`
3. If a laptop, set the "lid closing" setting in settings to do nothing.
Expand Down Expand Up @@ -36,13 +36,14 @@ We are using [Buildkite](https://buildkite.com/drud) for Windows and macOS testi

1. `docker-machine rm default`
2. `docker-machine create -d virtualbox --virtualbox-cpu-count=2 --virtualbox-memory=4096 --virtualbox-disk-size=50000 default`
3. Disable "Windows Defender Firewall", as it always blocks our Xdebug test.

### macOS Test Agent Setup

0. Create the user "testbot" on the machine. The password should be the password of testbot@drud.com.
1. Change the name of the machine to something in keeping with current style. Maybe `testbot-macstadium-macos-3`.
1. Install [homebrew](https://brew.sh/) `xcode select --install` and `/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"`
2. Install golang/git/docker with `brew cask install item2 google-chrome docker nosleep && brew tap buildkite/buildkite && brew tap drud/ddev && brew install golang git buildkite-agent mariadb jq p7zip bats-core composer ddev`
2. Install golang/git/docker with `brew cask install item2 google-chrome docker nosleep && brew tap buildkite/buildkite && brew tap drud/ddev && brew install golang git buildkite-agent mariadb jq p7zip bats-core composer ddev netcat`
4. If the xcode command line tools are not yet installed, install them with `xcode select --install`
5. Edit the buildkite-agent.cfg in /usr/local/etc/buildkite-agent.cfg to add
* the agent token
Expand Down
89 changes: 54 additions & 35 deletions pkg/ddevapp/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package ddevapp
import (
"bytes"
"fmt"
"github.com/drud/ddev/pkg/dockerutil"
"html/template"
"io/ioutil"
"os"
Expand Down Expand Up @@ -459,36 +460,37 @@ func (app *DdevApp) CheckCustomConfig() {
}

type composeYAMLVars struct {
Name string
Plugin string
AppType string
MailhogPort string
DBAPort string
DBPort string
DdevGenerated string
ExtraHost string
ComposeVersion string
MountType string
WebMount string
OmitDBA bool
OmitSSHAgent bool
WebcacheEnabled bool
IsWindowsFS bool
Name string
Plugin string
AppType string
MailhogPort string
DBAPort string
DBPort string
DdevGenerated string
HostDockerInternalHostname string
HostDockerInternalIP string
ComposeVersion string
MountType string
WebMount string
OmitDBA bool
OmitSSHAgent bool
WebcacheEnabled bool
IsWindowsFS bool
}

// RenderComposeYAML renders the contents of docker-compose.yaml.
func (app *DdevApp) RenderComposeYAML() (string, error) {
var doc bytes.Buffer
var err error
var docker0Addr = "127.0.0.1"
var docker0Hostname = "unneeded"
var hostDockerInternalIP = ""
var hostDockerInternalHostname = "unneeded"
templ := template.New("compose template")
templ, err = templ.Parse(DDevComposeTemplate)
if err != nil {
return "", err
}

// Docker 18.03 on linux doesn't define host.docker.internal
// Docker 18.09 on linux and docker-toolbox don't define host.docker.internal
// so we need to go get the ip address of docker0
// We would hope to be able to remove this when
// https://github.com/docker/for-linux/issues/264 gets resolved.
Expand All @@ -499,28 +501,45 @@ func (app *DdevApp) RenderComposeYAML() (string, error) {
addr := regexp.MustCompile(`inet *[0-9\.]+`).FindString(out)
components := strings.Split(addr, " ")
if len(components) == 2 {
docker0Addr = components[1]
docker0Hostname = "host.docker.internal"
hostDockerInternalIP = components[1]
}
}
} else if util.IsDockerToolbox() {
dockerIP, err := dockerutil.GetDockerIP()
if err != nil {
return "", err
}
octets := strings.Split(dockerIP, ".")
if len(octets) != 4 {
return "", fmt.Errorf("dockerIP %s does not have 4 octets", dockerIP)
}
// If the docker IP is 192.168.99.100, the *router* ip is 192.168.99.1
// So replace the final octet with 1.
hostDockerInternalIP = fmt.Sprintf("%s.%s.%s.1", octets[0], octets[1], octets[2])
}
// If we've come up with a host.docker.internal IP, set the hostname explicitly in
// docker-compose.yaml
if hostDockerInternalIP != "" {
hostDockerInternalHostname = "host.docker.internal"
}

templateVars := composeYAMLVars{
Name: app.Name,
Plugin: "ddev",
AppType: app.Type,
MailhogPort: appports.GetPort("mailhog"),
DBAPort: appports.GetPort("dba"),
DBPort: appports.GetPort("db"),
DdevGenerated: DdevFileSignature,
ExtraHost: docker0Hostname + `:` + docker0Addr,
ComposeVersion: version.DockerComposeFileFormatVersion,
OmitDBA: util.ArrayContainsString(app.OmitContainers, "dba"),
OmitSSHAgent: util.ArrayContainsString(app.OmitContainers, "ddev-ssh-agent"),
WebcacheEnabled: app.WebcacheEnabled,
IsWindowsFS: runtime.GOOS == "windows",
MountType: "bind",
WebMount: "../",
Name: app.Name,
Plugin: "ddev",
AppType: app.Type,
MailhogPort: appports.GetPort("mailhog"),
DBAPort: appports.GetPort("dba"),
DBPort: appports.GetPort("db"),
DdevGenerated: DdevFileSignature,
HostDockerInternalHostname: hostDockerInternalHostname,
HostDockerInternalIP: hostDockerInternalIP,
ComposeVersion: version.DockerComposeFileFormatVersion,
OmitDBA: util.ArrayContainsString(app.OmitContainers, "dba"),
OmitSSHAgent: util.ArrayContainsString(app.OmitContainers, "ddev-ssh-agent"),
WebcacheEnabled: app.WebcacheEnabled,
IsWindowsFS: runtime.GOOS == "windows",
MountType: "bind",
WebMount: "../",
}
if templateVars.WebcacheEnabled {
templateVars.MountType = "volume"
Expand Down
Loading

0 comments on commit 1aa0109

Please sign in to comment.