How to define location of app.py in OpenShift Next Gen Developer Preview?

4.4k views Asked by At

It seems that a Python 2.7 application in OpenShift requires an app.py file in the top level directory of the associated repo.

My application structure, however, is like this:

wsgi
- application (which solely contains from mybottleapp import application)
- mybottleapp.py

When I look at the logs for one of the pods, it shows this error:

WARNING: file 'app.py' not found.
ERROR: don't know how to run your application.
Please set either APP_MODULE or APP_FILE environment variables, or create a file 'app.py' to launch your application.

Can I set that instead of looking for app.py in the top level directory, it instead looks for /wsgi/application?

These are the relevant areas from the documentation:

https://docs.openshift.com/online/dev_guide/environment_variables.html#set-environment-variables

https://docs.openshift.com/online/dev_guide/environment_variables.html#list-environment-variables

But when I try the following to view available variables:

oc env pod/username-1-gx3h8 --list

I get:

# pods username-1-gx3h8, container username

I also tried:

oc env pod/username-1-gx3h8 APP_FILE=/wsgi/application

And got:

error: Pod "username-1-gx3h8" is invalid: spec: Forbidden: pod updates may not change fields other than `containers[*].image` or `spec.activeDeadlineSeconds`
2

There are 2 answers

1
user1063287 On BEST ANSWER

This seems to have worked, but I don't know if it was the correct way to do it:

oc env dc/username APP_FILE=wsgi/application  
deploymentconfig "username" updated  

dc stands for deploymentconfig and the name of the deploymentconfig was shown at the top of the Pods >> username-1-gx3h8 screen.

0
YoFlynn On

I modified the sample Bottle app for this exact purpose, but it's built in, just not well documented yet.

https://github.com/jfmatth/v3simplebottle.git

you need to change the file .s2i/environment.

It's laid out in the python-s2i docs, but not super clearly.

HTH