Skip to content

Commit

Permalink
fix: no need to expose edge runtime port (#2499)
Browse files Browse the repository at this point in the history
  • Loading branch information
sweatybridge committed Jul 6, 2024
1 parent 2016b7a commit 5520be2
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions internal/functions/serve/serve.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"fmt"
"os"
"path/filepath"
"strconv"
"strings"

"github.com/docker/docker/api/types/container"
Expand Down Expand Up @@ -157,13 +158,15 @@ func ServeFunctions(ctx context.Context, envFilePath string, noVerifyJWT *bool,
EOF
`}
// 5. Parse exposed ports
ports := []string{fmt.Sprintf("::%d/tcp", dockerRuntimeServerPort)}
dockerRuntimePort := nat.Port(fmt.Sprintf("%d/tcp", dockerRuntimeServerPort))
exposedPorts := nat.PortSet{dockerRuntimePort: struct{}{}}
portBindings := nat.PortMap{}
if runtimeOption.InspectMode != nil {
ports = append(ports, fmt.Sprintf(":%d:%d/tcp", utils.Config.EdgeRuntime.InspectorPort, dockerRuntimeInspectorPort))
}
exposedPorts, portBindings, err := nat.ParsePortSpecs(ports)
if err != nil {
return errors.Errorf("failed to expose ports: %w", err)
dockerInspectorPort := nat.Port(fmt.Sprintf("%d/tcp", dockerRuntimeInspectorPort))
exposedPorts[dockerInspectorPort] = struct{}{}
portBindings[dockerInspectorPort] = []nat.PortBinding{{
HostPort: strconv.FormatUint(uint64(utils.Config.EdgeRuntime.InspectorPort), 10),
}}
}
// 6. Start container
_, err = utils.DockerStart(
Expand Down

0 comments on commit 5520be2

Please sign in to comment.