From ce352e9e9bd27f5e949c98a1d078a278948577ab Mon Sep 17 00:00:00 2001 From: Julien Castets Date: Mon, 20 Nov 2023 14:07:56 +0100 Subject: [PATCH] Set default port/route to 8000 instead of 80, fix #152 This is to match the defaults between the CLI and the console. --- docs/reference.md | 26 +++++++++++++------------- pkg/koyeb/services.go | 18 +++++++++--------- 2 files changed, 22 insertions(+), 22 deletions(-) diff --git a/docs/reference.md b/docs/reference.md index 12b971bb..f2e39f50 100644 --- a/docs/reference.md +++ b/docs/reference.md @@ -281,8 +281,8 @@ koyeb apps init NAME [flags] --instance-type string Instance type (default "nano") --max-scale int Max scale (default 1) --min-scale int Min scale (default 1) - --ports strings Update service ports (available for services of type "web" only) using the format PORT[:PROTOCOL], for example --port 80:http - If no protocol is specified, it defaults to "http". Supported protocols are "http" and "http2" + --ports strings Update service ports (available for services of type "web" only) using the format PORT[:PROTOCOL], for example --port 8080:http + PROTOCOL defaults to "http". Supported protocols are "http" and "http2" To delete an exposed port, prefix its number with '!', for example --port '!80' --privileged Whether the service container should run in privileged mode @@ -291,7 +291,7 @@ koyeb apps init NAME [flags] If the region is not specified on service creation, the service is deployed in fra --routes strings Update service routes (available for services of type "web" only) using the format PATH[:PORT], for example '/foo:8080' - If no port is specified, it defaults to 80 + PORT defaults to 8000 To delete a route, use '!PATH', for example --route '!/foo' --scale int Set both min-scale and max-scale (default 1) @@ -1146,11 +1146,11 @@ koyeb services create NAME [flags] ``` -# Deploy a nginx docker image, with default port (80:http), default route (/:80) -$> koyeb service create myservice --app myapp --docker nginx +# Deploy a nginx docker image, listening on port 80 +$> koyeb service create myservice --app myapp --docker nginx --port 80 -# Build and deploy a GitHub repository using buildpack (default), set the environment variable PORT, and expose the port 8000 to the root route -$> koyeb service create myservice --app myapp --git github.com/koyeb/example-flask --git-branch main --env PORT=8000 --port 8000:http --route /:8000 +# Build and deploy a GitHub repository using buildpack (default), set the environment variable PORT, and expose the port 9000 to the root route +$> koyeb service create myservice --app myapp --git github.com/koyeb/example-flask --git-branch main --env PORT=9000 --port 9000:http --route /:9000 # Build and deploy a GitHub repository using docker $> koyeb service create myservice --app myapp --git github.com/org/name --git-branch main --git-builder docker @@ -1192,8 +1192,8 @@ $> koyeb service create myservice --app myapp --git github.com/org/name --git-br --instance-type string Instance type (default "nano") --max-scale int Max scale (default 1) --min-scale int Min scale (default 1) - --ports strings Update service ports (available for services of type "web" only) using the format PORT[:PROTOCOL], for example --port 80:http - If no protocol is specified, it defaults to "http". Supported protocols are "http" and "http2" + --ports strings Update service ports (available for services of type "web" only) using the format PORT[:PROTOCOL], for example --port 8080:http + PROTOCOL defaults to "http". Supported protocols are "http" and "http2" To delete an exposed port, prefix its number with '!', for example --port '!80' --privileged Whether the service container should run in privileged mode @@ -1202,7 +1202,7 @@ $> koyeb service create myservice --app myapp --git github.com/org/name --git-br If the region is not specified on service creation, the service is deployed in fra --routes strings Update service routes (available for services of type "web" only) using the format PATH[:PORT], for example '/foo:8080' - If no port is specified, it defaults to 80 + PORT defaults to 8000 To delete a route, use '!PATH', for example --route '!/foo' --scale int Set both min-scale and max-scale (default 1) @@ -1581,8 +1581,8 @@ $> koyeb service update myapp/myservice --env PORT=8001 --env '!DEBUG' --max-scale int Max scale (default 1) --min-scale int Min scale (default 1) --override Override the service configuration with the new configuration instead of merging them - --ports strings Update service ports (available for services of type "web" only) using the format PORT[:PROTOCOL], for example --port 80:http - If no protocol is specified, it defaults to "http". Supported protocols are "http" and "http2" + --ports strings Update service ports (available for services of type "web" only) using the format PORT[:PROTOCOL], for example --port 8080:http + PROTOCOL defaults to "http". Supported protocols are "http" and "http2" To delete an exposed port, prefix its number with '!', for example --port '!80' --privileged Whether the service container should run in privileged mode @@ -1591,7 +1591,7 @@ $> koyeb service update myapp/myservice --env PORT=8001 --env '!DEBUG' If the region is not specified on service creation, the service is deployed in fra --routes strings Update service routes (available for services of type "web" only) using the format PATH[:PORT], for example '/foo:8080' - If no port is specified, it defaults to 80 + PORT defaults to 8000 To delete a route, use '!PATH', for example --route '!/foo' --scale int Set both min-scale and max-scale (default 1) diff --git a/pkg/koyeb/services.go b/pkg/koyeb/services.go index e518d7de..1de400b5 100644 --- a/pkg/koyeb/services.go +++ b/pkg/koyeb/services.go @@ -27,11 +27,11 @@ func NewServiceCmd() *cobra.Command { Short: "Create service", Args: cobra.ExactArgs(1), Example: ` -# Deploy a nginx docker image, with default port (80:http), default route (/:80) -$> koyeb service create myservice --app myapp --docker nginx +# Deploy a nginx docker image, listening on port 80 +$> koyeb service create myservice --app myapp --docker nginx --port 80 -# Build and deploy a GitHub repository using buildpack (default), set the environment variable PORT, and expose the port 8000 to the root route -$> koyeb service create myservice --app myapp --git github.com/koyeb/example-flask --git-branch main --env PORT=8000 --port 8000:http --route /:8000 +# Build and deploy a GitHub repository using buildpack (default), set the environment variable PORT, and expose the port 9000 to the root route +$> koyeb service create myservice --app myapp --git github.com/koyeb/example-flask --git-branch main --env PORT=9000 --port 9000:http --route /:9000 # Build and deploy a GitHub repository using docker $> koyeb service create myservice --app myapp --git github.com/org/name --git-branch main --git-builder docker`, @@ -272,14 +272,14 @@ func addServiceDefinitionFlags(flags *pflag.FlagSet) { "routes", nil, "Update service routes (available for services of type \"web\" only) using the format PATH[:PORT], for example '/foo:8080'\n"+ - "If no port is specified, it defaults to 80\n"+ + "PORT defaults to 8000\n"+ "To delete a route, use '!PATH', for example --route '!/foo'\n", ) flags.StringSlice( "ports", nil, - "Update service ports (available for services of type \"web\" only) using the format PORT[:PROTOCOL], for example --port 80:http\n"+ - "If no protocol is specified, it defaults to \"http\". Supported protocols are \"http\" and \"http2\"\n"+ + "Update service ports (available for services of type \"web\" only) using the format PORT[:PROTOCOL], for example --port 8080:http\n"+ + "PROTOCOL defaults to \"http\". Supported protocols are \"http\" and \"http2\"\n"+ "To delete an exposed port, prefix its number with '!', for example --port '!80'\n", ) flags.StringSlice( @@ -554,8 +554,8 @@ func setDefaultPortsAndRoutes(definition *koyeb.DeploymentDefinition, currentPor switch { // If no route and no port is specified, add the default route and port case len(currentPorts) == 0 && len(currentRoutes) == 0: - definition.SetPorts(getDeploymentPort(80)) - definition.SetRoutes(getDeploymentRoute(80)) + definition.SetPorts(getDeploymentPort(8000)) + definition.SetRoutes(getDeploymentRoute(8000)) // One or more port set, no route set case len(currentPorts) > 0 && len(currentRoutes) == 0: