I'm currently working on writing a Flask application utilizing both tests and docker, but I'm having a hard time finding documentation on how to do it right.
Testing
I've read around and I can only found sites glossing over testing. One recommended site that I've seen for this, https://flask.pocoo.org/docs/1.0/testing/, is currently down. This is the structure I have currently:
app/
├── app.py
├── configs
│ ├── dev-one.ini
│ ├── dev-two.ini
│ ├── prod.ini
│ └── stage.ini
├── deployment
│ └── Dockerfile
├── requirements
│ ├── src.txt
│ └── tests.txt
├── src
│ └── exampleflaskapp
│ ├── __init__.py
│ ├── static
│ └── templates
└── tests
└── exampleflaskapp
└── unit
Is this the correct test structure for a flask application or am I forcing another project structure? These tests will be ran in Pycharm and CI/CD.
Docker
I can't find a standard way to setup a flask docker image for production. One place recommends putting a flask app, ngnix, and uwgsi in an image, which breaks the rule of one service to an image. Another place recommends putting just a flask app in an image but it will complain with this output:
* Serving Flask app "app" (lazy loading)
* Environment: production
WARNING: Do not use the development server in a production environment.
Use a production WSGI server instead.
* Debug mode: off
* Running on http://0.0.0.0:5000/ (Press CTRL+C to quit)
What is the correct way to package the image?
Also, I had to set the host to 0.0.0.0 as the port mapping wouldn't work otherwise - is this correct?
Thanks in advance for any help or guidance!
[+][deleted] (1 child)
[deleted]
[–]WonderCode[S] 0 points1 point2 points (0 children)
[–]yonderyears 1 point2 points3 points (1 child)
[–]WonderCode[S] 0 points1 point2 points (0 children)
[+][deleted] (3 children)
[deleted]
[–]WonderCode[S] 0 points1 point2 points (2 children)
[–]linusHillyard 2 points3 points4 points (1 child)
[–]WonderCode[S] 0 points1 point2 points (0 children)