Skip to content

Commit

Permalink
Set default port/route to 8000 instead of 80, fix #152
Browse files Browse the repository at this point in the history
This is to match the defaults between the CLI and the console.
  • Loading branch information
brmzkw committed Nov 20, 2023
1 parent ede7474 commit ce352e9
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 22 deletions.
26 changes: 13 additions & 13 deletions docs/reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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)
Expand Down Expand Up @@ -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
Expand All @@ -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)
Expand Down
18 changes: 9 additions & 9 deletions pkg/koyeb/services.go
Original file line number Diff line number Diff line change
Expand Up @@ -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`,
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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:
Expand Down

0 comments on commit ce352e9

Please sign in to comment.