Skip to content

Commit

Permalink
fix: add support for "host:port" forwardPorts syntax
Browse files Browse the repository at this point in the history
fixes: #305
  • Loading branch information
lizardruss committed May 19, 2023
1 parent 99a4b23 commit 24d7db2
Show file tree
Hide file tree
Showing 8 changed files with 254 additions and 94 deletions.
8 changes: 8 additions & 0 deletions e2e/e2e_suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import (
"testing"
"time"

"github.com/loft-sh/devpod/e2e/framework"

"github.com/onsi/ginkgo/v2"

"github.com/onsi/gomega"
Expand All @@ -24,5 +26,11 @@ import (
func TestRunE2ETests(t *testing.T) {
rand.Seed(time.Now().UTC().UnixNano())
gomega.RegisterFailHandler(ginkgo.Fail)
go func() {
err := framework.StartAgentServer()
if err != nil {
t.Error(err)
}
}()
ginkgo.RunSpecs(t, "DevPod e2e suite")
}
33 changes: 33 additions & 0 deletions e2e/framework/agent_server.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package framework

import (
"net"
"net/http"
"os"
"path/filepath"
)

const agentServerPort = "9191"

func StartAgentServer() error {
wd, err := os.Getwd()
if err != nil {
return err
}

listener, err := net.Listen("tcp", ":"+agentServerPort)
if err != nil {
return err
}

err = os.Setenv("DEVPOD_AGENT_URL", "http://localhost:"+agentServerPort)
if err != nil {
return err
}

if err := http.Serve(listener, http.FileServer(http.Dir(filepath.Join(wd, "bin")))); err != nil {
return err
}

return nil
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"name": "Go",
"dockerComposeFile": "./docker-compose.yaml",
"service": "app",
"runServices": ["nginx"],
"workspaceFolder": "/workspaces",
"forwardPorts": [
4000,
"3000",
"nginx:8989"
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
version: '3'

services:
app:
image: mcr.microsoft.com/devcontainers/go:0-1.19-bullseye
command: sleep infinity
volumes:
- .:/workspaces:cached
nginx:
image: nginx
ports:
- "8989:80"
Loading

0 comments on commit 24d7db2

Please sign in to comment.