Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: revert removal of Colima host.docker.internal setting #6031

Merged
merged 6 commits into from
Mar 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion cmd/ddev/cmd/debug-nfsmount_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import (
// TestDebugNFSMount tries out the `ddev debug nfsmount` command.
// It requires nfsd running of course.
func TestDebugNFSMount(t *testing.T) {
if nodeps.IsWSL2() || dockerutil.IsColima() || dockerutil.IsLima() {
if nodeps.IsWSL2() || dockerutil.IsColima() || dockerutil.IsLima() || dockerutil.IsOrbstack() {
t.Skip("Skipping on WSL2/Lima/Colima since NFS is not used there")
}
assert := asrt.New(t)
Expand Down
8 changes: 4 additions & 4 deletions pkg/ddevapp/ddevapp_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -903,9 +903,9 @@ func TestDdevNoProjectMount(t *testing.T) {

// TestDdevXdebugEnabled tests running with xdebug_enabled = true, etc.
func TestDdevXdebugEnabled(t *testing.T) {
if (dockerutil.IsColima() || dockerutil.IsLima()) && os.Getenv("DDEV_TEST_COLIMA_ANYWAY") != "true" {
t.Skip("Skipping on Lima/Colima because this test doesn't work although manual testing works")
}
//if (dockerutil.IsColima() || dockerutil.IsLima()) && os.Getenv("DDEV_TEST_COLIMA_ANYWAY") != "true" {
// t.Skip("Skipping on Lima/Colima because this test doesn't work although manual testing works")
//}
if nodeps.IsWSL2() && dockerutil.IsDockerDesktop() {
t.Skip("Skipping on WSL2/Docker Desktop because this test doesn't work although manual testing works")
}
Expand Down Expand Up @@ -3707,7 +3707,7 @@ func TestCaptureLogs(t *testing.T) {
// This requires that the test machine must have NFS shares working
// Tests using both app-specific performance_mode: nfs and etc
func TestNFSMount(t *testing.T) {
if nodeps.IsWSL2() || dockerutil.IsColima() || dockerutil.IsLima() {
if nodeps.IsWSL2() || dockerutil.IsColima() || dockerutil.IsLima() || dockerutil.IsOrbstack() {
t.Skip("Skipping on WSL2/Lima/Colima")
}
if nodeps.PerformanceModeDefault == types.PerformanceModeMutagen || nodeps.NoBindMountsDefault {
Expand Down
25 changes: 25 additions & 0 deletions pkg/dockerutil/dockerutils.go
Original file line number Diff line number Diff line change
Expand Up @@ -1206,6 +1206,12 @@ func GetHostDockerInternalIP() (string, error) {
hostDockerInternal = "127.0.0.1"
util.Debug("host.docker.internal=%s because globalconfig.DdevGlobalConfig.XdebugIDELocation=%s", hostDockerInternal, globalconfig.XdebugIDELocationContainer)

case IsColima():
// Lima specifies this as a named explicit IP address at this time
// see https://github.com/lima-vm/lima/blob/master/docs/network.md#host-ip-19216852
hostDockerInternal = "192.168.5.2"
util.Debug("host.docker.internal=%s because running on Colima", hostDockerInternal)

// Gitpod has Docker 20.10+ so the docker-compose has already gotten the host-gateway
case nodeps.IsGitpod():
util.Debug("host.docker.internal='%s' because on Gitpod", hostDockerInternal)
Expand Down Expand Up @@ -1253,6 +1259,11 @@ func GetNFSServerAddr() (string, error) {
nfsAddr := "host.docker.internal"

switch {
case IsColima():
// Lima specifies this as a named explicit IP address at this time
// see https://github.com/lima-vm/lima/blob/master/docs/network.md#host-ip-19216852
nfsAddr = "192.168.5.2"

// Gitpod has Docker 20.10+ so the docker-compose has already gotten the host-gateway
// However, NFS will never be used on Gitpod.
case nodeps.IsGitpod():
Expand Down Expand Up @@ -1587,6 +1598,20 @@ func IsLima() bool {
return false
}

// IsOrbstack detects if running on Orbstack
func IsOrbstack() bool {
ctx, client := GetDockerClient()
info, err := client.Info(ctx)
if err != nil {
util.Warning("IsOrbstack(): Unable to get Docker info, err=%v", err)
return false
}
if strings.HasPrefix(info.Name, "orbstack") {
return true
}
return false
}

// CopyIntoContainer copies a path (file or directory) into a specified container and location
func CopyIntoContainer(srcPath string, containerName string, dstPath string, exclusion string) error {
startTime := time.Now()
Expand Down