mirror of
https://github.com/balena-os/balena-supervisor.git
synced 2025-02-18 17:00:25 +00:00
Make sure the PORT env var is a valid port number before trying to bind it.
This commit is contained in:
parent
9ca8077daa
commit
ab642470ec
@ -65,7 +65,11 @@ exports.start = start = (app) ->
|
||||
console.log("Creating container:", app.imageId)
|
||||
ports = {}
|
||||
if app.env.PORT?
|
||||
ports[app.env.PORT + '/tcp'] = {}
|
||||
maybePort = parseInt(app.env.PORT, 10)
|
||||
if parseFloat(app.env.PORT) is maybePort and maybePort > 0 and maybePort < 65535
|
||||
port = maybePort
|
||||
if port?
|
||||
ports[port + '/tcp'] = {}
|
||||
docker.createContainerAsync(
|
||||
Image: app.imageId
|
||||
Cmd: ['/bin/bash', '-c', '/start']
|
||||
@ -77,8 +81,8 @@ exports.start = start = (app) ->
|
||||
.then (container) ->
|
||||
console.log('Starting container:', app.imageId)
|
||||
ports = {}
|
||||
if app.env.PORT?
|
||||
ports[app.env.PORT + '/tcp'] = [ HostPort: app.env.PORT ]
|
||||
if port?
|
||||
ports[port + '/tcp'] = [ HostPort: port ]
|
||||
container.startAsync(
|
||||
Privileged: true
|
||||
PortBindings: ports
|
||||
|
Loading…
x
Reference in New Issue
Block a user