deis / helloworld

A hello world app, written in Go.
MIT License
10 stars 30 forks source link

Make entrypoint an absolute path. #2

Closed kastork closed 10 years ago

kastork commented 10 years ago

Using deis 0.9.1 in a local development environment (vagrant) the example was failing to find the helloworld go executable.

For example: Jun 22 05:23:07 deis-1 sh[14724]: 2014/06/22 05:23:07 exec: "helloworld": executable file not found in $PATH

gabrtv commented 10 years ago

ping @bacongobbler

bacongobbler commented 10 years ago

Weird. Works outside of Deis, but not when deployed:

$ docker build -t deis/helloworld .
$ docker run -d -p 8000:80 deis/helloworld
$ curl localhost:8000
[...]
$ deis create && git push deis master
$ fleetctl status luxury-nuthatch_v2.cmd.1.service
● luxury-nuthatch_v2.cmd.1.service - luxury-nuthatch_v2.cmd.1
   Loaded: loaded (/run/fleet/units/luxury-nuthatch_v2.cmd.1.service; linked-runtime)
   Active: failed (Result: exit-code) since Wed 2014-06-25 00:33:13 UTC; 1min 14s ago
  Process: 13531 ExecStop=/usr/bin/docker rm -f luxury-nuthatch_v2.cmd.1 (code=exited, status=0/SUCCESS)
  Process: 13492 ExecStart=/bin/sh -c port=$(docker inspect -f '{{range $k, $v := .ContainerConfig.ExposedPorts }}{{$k}}{{end}}' 172.17.8.100:5000/luxury-nuthatch:v2 | cut -d/ -f1) ; docker run --name luxury-nuthatch_v2.cmd.1 -P -e PORT=$port 172.17.8.100:5000/luxury-nuthatch:v2  (code=exited, status=1/FAILURE)
  Process: 13482 ExecStartPre=/bin/sh -c docker inspect luxury-nuthatch_v2.cmd.1 >/dev/null 2>&1 && docker rm -f luxury-nuthatch_v2.cmd.1 || true (code=exited, status=0/SUCCESS)
  Process: 12419 ExecStartPre=/usr/bin/docker pull 172.17.8.100:5000/luxury-nuthatch:v2 (code=exited, status=0/SUCCESS)
 Main PID: 13492 (code=exited, status=1/FAILURE)

Jun 25 00:32:56 deis-1 docker[12419]: Pulling repository 172.17.8.100:5000/luxury-nuthatch
Jun 25 00:33:12 deis-1 systemd[1]: Started luxury-nuthatch_v2.cmd.1.
Jun 25 00:33:13 deis-1 sh[13492]: 2014/06/25 00:33:13 exec: "helloworld": executable file not found in $PATH
Jun 25 00:33:13 deis-1 systemd[1]: luxury-nuthatch_v2.cmd.1.service: main process exited, code=exited, status=1/FAILURE
Jun 25 00:33:13 deis-1 docker[13531]: luxury-nuthatch_v2.cmd.1
Jun 25 00:33:13 deis-1 systemd[1]: Unit luxury-nuthatch_v2.cmd.1.service entered failed state.

I saw this same behaviour occur when deploying dotcloud/docker-registry. Looks like ENV entries in the Dockerfile aren't respected when you send -e to docker run. @gabrtv luckily for us this will be fixed with your new-and-improved registry backend for last-mile layer configuration in deis/deis#1190. I'd rather wait until that is merged, IMO. Is this an upstream bug?

In the meantime, the fix for this is to run deis config:set PATH='$PATH:/go/bin' and you should see the app running again. The single quotes are important or else $PATH will get expanded to your own local $PATH envvar.

$ deis config:set PATH='$PATH:/usr/local/go/bin:/go/bin'
Creating config... done, v3

=== luxury-nuthatch
PATH: $PATH:/usr/local/go/bin:/go/bin
$ fleetctl status luxury-nuthatch_v3.cmd.1.service
● luxury-nuthatch_v3.cmd.1.service - luxury-nuthatch_v3.cmd.1
   Loaded: loaded (/run/fleet/units/luxury-nuthatch_v3.cmd.1.service; linked-runtime)
   Active: active (running) since Wed 2014-06-25 00:49:47 UTC; 19s ago
 Main PID: 3273 (sh)
   CGroup: /system.slice/luxury-nuthatch_v3.cmd.1.service
           ├─3273 /bin/sh -c port=$(docker inspect -f '{{range $k, $v := .ContainerConfig.ExposedPorts }}{{$k}}{{end}}' 172.17.8.100:5000/luxury-nuthatch:v3 | cut -d/ -f1) ; docker run --name luxury-nuthatch_v3.cmd.1 -P -e PORT=$port 172.17.8.100:5000/luxury-nuthatch:v3
           └─3285 docker run --name luxury-nuthatch_v3.cmd.1 -P -e PORT=80 172.17.8.100:5000/luxury-nuthatch:v3

Jun 25 00:49:46 deis-1 docker[3022]: Pulling repository 172.17.8.100:5000/luxury-nuthatch
Jun 25 00:49:47 deis-1 systemd[1]: Started luxury-nuthatch_v3.cmd.1.
$ curl http://luxury-nuthatch.local.deisapp.com
Welcome to Deis!
See the documentation at http://docs.deis.io/ for more information.
kastork commented 10 years ago

I have noticed that the docker docks use absolute paths in the entry point list for examples like this too. Not sure what the authoritative best practice is.