First timer error - deploying a hello-world flask app


#1

I am getting my hands dirty with habitat for the first time with a “hello world” flask app. After exporting / building the docker image, I get the following error when I try to spin up a container using the image.

 Vagrant@salt:~/repos/habitat-examples/python-hello$ docker run npsoni88/nishant-flask
hab-sup(MR): Supervisor Member-ID d9c323e703e2497bac2e412923141855
hab-sup(AG): The npsoni88/nishant-flask service was successfully loaded
hab-sup(MR): Starting npsoni88/nishant-flask
nishant-flask.default(UCW): Watching user.toml
hab-sup(MR): Starting gossip-listener on 0.0.0.0:9638
hab-sup(MR): Starting ctl-gateway on 127.0.0.1:9632
hab-sup(MR): Starting http-gateway on 0.0.0.0:9631
nishant-flask.default(HK): init, compiled to /hab/svc/nishant-flask/hooks/init
nishant-flask.default(HK): run, compiled to /hab/svc/nishant-flask/hooks/run
nishant-flask.default(HK): Hooks compiled
nishant-flask.default(SR): Hooks recompiled
nishant-flask.default(SR): Initializing
nishant-flask.default hook[init]:(HK): ln: failed to create symbolic link '/hab/svc/nishant-flask/app.py': Permission denied
nishant-flask.default(HK): Initialization failed! 'init' exited with status code 1
nishant-flask.default(SR): Initializing
nishant-flask.default hook[init]:(HK): ln: failed to create symbolic link '/hab/svc/nishant-flask/app.py': Permission denied
nishant-flask.default(HK): Initialization failed! 'init' exited with status code 1
nishant-flask.default(SR): Initializing
nishant-flask.default hook[init]:(HK): ln: failed to create symbolic link '/hab/svc/nishant-flask/app.py': Permission denied
nishant-flask.default(HK): Initialization failed! 'init' exited with status code 1
nishant-flask.default(SR): Initializing
nishant-flask.default hook[init]:(HK): ln: failed to create symbolic link '/hab/svc/nishant-flask/app.py': Permission denied
nishant-flask.default(HK): Initialization failed! 'init' exited with status code 1
nishant-flask.default(SR): Initializing
nishant-flask.default hook[init]:(HK): ln: failed to create symbolic link '/hab/svc/nishant-flask/app.py': Permission denied
nishant-flask.default(HK): Initialization failed! 'init' exited with status code 1
nishant-flask.default(SR): Initializing
nishant-flask.default hook[init]:(HK): ln: failed to create symbolic link '/hab/svc/nishant-flask/app.py': Permission denied
nishant-flask.default(HK): Initialization failed! 'init' exited with status code 1
nishant-flask.default(SR): Initializing
nishant-flask.default hook[init]:(HK): ln: failed to create symbolic link '/hab/svc/nishant-flask/app.py': Permission denied
nishant-flask.default(HK): Initialization failed! 'init' exited with status code 1
nishant-flask.default(SR): Initializing
nishant-flask.default hook[init]:(HK): ln: failed to create symbolic link '/hab/svc/nishant-flask/app.py': Permission denied
nishant-flask.default(HK): Initialization failed! 'init' exited with status code 1
nishant-flask.default(SR): Initializing
nishant-flask.default hook[init]:(HK): ln: failed to create symbolic link '/hab/svc/nishant-flask/app.py': Permission denied
nishant-flask.default(HK): Initialization failed! 'init' exited with status code 1
^Chab-sup(MR): Gracefully departing from butterfly network.
hab-sup(MR): Unable to cleanup service health cache, nishant-flask.default [npsoni88/nishant-flask/0.1.0/20180925105104], No such file or directory (os error 2)
hab-launch(SV): Hasta la vista, services.

Here’s my plan.sh
pkg_name=nishant-flask
pkg_version=0.1.0
pkg_deps=(core/python2)
pkg_build_deps=(core/coreutils core/gcc core/python2)
pkg_origin=‘npsoni88’
pkg_maintainer=‘Demo User’

# we copy in the source code in the `unpack` phase and need to put
# something here due to https://github.com/habitat-sh/habitat/issues/870
pkg_source="fake"

# Need to opt-out of all of these steps, as we're copying in source code
do_download() {
  return 0
}
do_verify() {
  return 0
}
do_clean() {
  return 0
}

do_unpack() {
  mkdir -p $pkg_prefix
  build_line "Copying src/ to $pkg_prefix/"
  cp -r $PLAN_CONTEXT/src/ $pkg_prefix/
}

do_build() {
  pip install --upgrade pip
}

do_install() {
  cd $pkg_prefix/src
  pip install -r requirements.txt
}
~

#2

Update - I’ve ensured that “/hab” dir is owned (recursively) by user “Vagrant” thats trying to run the docker image, and still no luck.


#3

Hello Nishant!

I’m not entirely sure exactly what the problem with your image is, but it looks like it’s based on a pretty old sample repo.

I built a new sample repo here that should get you up and running. Let me know if you have any other questions!