From 73b2ff09458bf43419983aeab8196f3723ebaba0 Mon Sep 17 00:00:00 2001 From: Anmol Sethi Date: Thu, 14 May 2020 21:57:10 -0400 Subject: [PATCH] $PORT should always override port in --bind-addr --- README.md | 7 +++++-- src/node/cli.ts | 9 ++++----- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index afb42f6f6..4a6c79926 100644 --- a/README.md +++ b/README.md @@ -53,14 +53,17 @@ code-server ```bash brew install code-server -brew service start code-server +brew services start code-server # Now visit http://127.0.0.1:8080. Your password is in ~/.config/code-server/config.yaml ``` ### Docker ```bash -docker run -it -p 127.0.0.1:8080:8080 -v "$PWD:/home/coder/project" -u "$(id -u):$(id -g)" codercom/code-server:latest +docker run -it -p 127.0.0.1:8080:8080 \ + -v "$PWD:/home/coder/project" \ + -u "$(id -u):$(id -g)" \ + codercom/code-server:latest ``` This will start a code-server container and expose it at http://127.0.0.1:8080. It will also mount diff --git a/src/node/cli.ts b/src/node/cli.ts index de18f61e1..bce0d000b 100644 --- a/src/node/cli.ts +++ b/src/node/cli.ts @@ -380,6 +380,10 @@ function bindAddrFromArgs(addr: Addr, args: Args): Addr { if (args.host) { addr.host = args.host } + + if (process.env.PORT) { + addr.port = parseInt(process.env.PORT, 10) + } if (args.port !== undefined) { addr.port = args.port } @@ -393,11 +397,6 @@ export function bindAddrFromAllSources(cliArgs: Args, configArgs: Args): [string } addr = bindAddrFromArgs(addr, configArgs) - - if (process.env.PORT) { - addr.port = parseInt(process.env.PORT, 10) - } - addr = bindAddrFromArgs(addr, cliArgs) return [addr.host, addr.port]