Skip to content

Commit e293667

Browse files
author
Matthew Fisher
committed
chore(controller): remove $PORT logic from fleet
For buildpack apps, [$PORT is exposed][1] as part of slugrunner's job. For Dockerfile/Docker images, the internal port numbers are already known to the developer, so if they want to follow 12-factor best practices then they will have set up $PORT in their own image. deis/publisher exposes the port with the lowest numerical value to the router, which is why the documentation is reflected to show this. https://github.com/deis/deis/blob/e6a078b4119887b4de73e8a6d04291b7cdeb823b/builder/image/slugrunner/Dockerfile#L10-L12
1 parent e6a078b commit e293667

4 files changed

Lines changed: 5 additions & 4 deletions

File tree

controller/scheduler/fleet.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -379,7 +379,7 @@ def attach(self, name):
379379
{"section": "Unit", "name": "Description", "value": "{name}"},
380380
{"section": "Service", "name": "ExecStartPre", "value": '''/bin/sh -c "IMAGE=$(etcdctl get /deis/registry/host 2>&1):$(etcdctl get /deis/registry/port 2>&1)/{image}; docker pull $IMAGE"'''}, # noqa
381381
{"section": "Service", "name": "ExecStartPre", "value": '''/bin/sh -c "docker inspect {name} >/dev/null 2>&1 && docker rm -f {name} || true"'''}, # noqa
382-
{"section": "Service", "name": "ExecStart", "value": '''/bin/sh -c "IMAGE=$(etcdctl get /deis/registry/host 2>&1):$(etcdctl get /deis/registry/port 2>&1)/{image}; port=$(docker inspect -f '{{{{range $k, $v := .ContainerConfig.ExposedPorts }}}}{{{{$k}}}}{{{{end}}}}' $IMAGE | cut -d/ -f1) ; docker run --name {name} {memory} {cpu} {hostname} -P -e PORT=$port $IMAGE {command}"'''}, # noqa
382+
{"section": "Service", "name": "ExecStart", "value": '''/bin/sh -c "IMAGE=$(etcdctl get /deis/registry/host 2>&1):$(etcdctl get /deis/registry/port 2>&1)/{image}; docker run --name {name} {memory} {cpu} {hostname} -P $IMAGE {command}"'''}, # noqa
383383
{"section": "Service", "name": "ExecStop", "value": '''/usr/bin/docker stop {name}'''},
384384
{"section": "Service", "name": "ExecStop", "value": '''/usr/bin/docker rm -f {name}'''},
385385
{"section": "Service", "name": "TimeoutStartSec", "value": "20m"},

docs/using_deis/using-docker-images.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ Docker Image Requirements
3131
In order to deploy Docker images, they must conform to the following requirements:
3232

3333
* The Docker image must EXPOSE only one port
34-
* The exposed port must be an HTTP service that can be connected to an HTTP router
34+
* The port must be listening for a HTTP connection
3535
* A default CMD must be specified for running the container
3636

3737
.. note::

docs/using_deis/using-dockerfiles.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ Dockerfile Requirements
2222
In order to deploy Dockerfile applications, they must conform to the following requirements:
2323

2424
* The Dockerfile must EXPOSE only one port
25-
* The exposed port must be an HTTP service that can be connected to an HTTP router
25+
* The port must be listening for a HTTP connection
2626
* A default CMD must be specified for running the container
2727

2828
.. note::

publisher/server/publisher.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,8 @@ func (s *Server) publishContainer(container *docker.APIContainers, ttl time.Dura
100100
keyPath := fmt.Sprintf("/deis/services/%s", appPath)
101101
dirPath := fmt.Sprintf("/deis/services/%s", appName)
102102
for _, p := range container.Ports {
103+
// lowest port wins (docker sorts the ports)
104+
// TODO (bacongobbler): support multiple exposed ports
103105
port := strconv.Itoa(int(p.PublicPort))
104106
hostAndPort := host + ":" + port
105107
if s.IsPublishableApp(containerName) && s.IsPortOpen(hostAndPort) {
@@ -109,7 +111,6 @@ func (s *Server) publishContainer(container *docker.APIContainers, ttl time.Dura
109111
safeMap.data[container.ID] = appPath
110112
safeMap.Unlock()
111113
}
112-
// TODO: support multiple exposed ports
113114
break
114115
}
115116
}

0 commit comments

Comments
 (0)