When running my Docker image and requesting the Swagger UI I receive: 502 Bad Gateway
.
I am attempting to run Connexion (Flask-based Swagger UI generator) with uWSGI on nginx. I assume it is because uWSGI does not correctly pick up my Flask instance. However, it appears to me that my container instance is correctly configured.
If you look here https://github.com/Microsoft/python-sample-vscode-flask-tutorial, the setup of my application and the configuration is similar and it works without issues.
According to the Connexion documentation I should be able to expose the app instance to uWSGI using
app = connexion.App(__name__, specification_dir='swagger/')
application = app.app # expose global WSGI application object
You can find my complete application code here:
https://bitbucket.org/lammy123/flask_nginx_docker_connexion/src/master/
The Flask/Connexion object is in application/__init__.py
uwsgi.ini:
[uwsgi]
module = application.webapp
callable = app
uid = 1000
master = true
threads = 2
processes = 4
__init__.py:
import connexion
app = connexion.App(__name__, specification_dir='openapi/')
app.add_api('helloworld-api.yaml', arguments={'title': 'Hello World Example'})
webapp.py:
from . import app # For application discovery by the 'flask' command.
from . import views # For import side-effects of setting up routes.
from . import app
import connexion
application = app.app
Running the code with the build-in development server works.
Expected behavior is that the Swagger UI is available at:
http://localhost:5000/v1.0/ui/#/
when running from a Docker container.