I need to create a docker-compose file for flask based API back end application. But this application is based on several other libraries following. All need to run on docker containers only. Can you suggest how will be the docker-compose file and related if any?
- psycopg2
- aniso8601==8.0.0
- argon2-cffi==19.2.0
- certifi==2019.11.28
- cffi==1.14.0
- chardet==3.0.4
- click==7.1.1
- cryptography==2.9
- defusedxml==0.6.0
- Flask==1.1.2
- Flask-Caching==1.8.0
- Flask-JWT-Extended==3.24.1
- Flask-Login==0.4.1
- Flask-OAuthlib==0.9.5
- Flask-OpenID==1.2.5
- Flask-RESTful==0.3.8
- Flask-SQLAlchemy==2.4.1
- flask-swagger==0.2.13
- Flask-WTF==0.14.3
- graphviz==0.14
- gunicorn==19.10.0
- idna==2.9
- itsdangerous==0.24
- Jinja2==2.10.1
- kazoo==2.5.0
- Mako==1.1.2
- MarkupSafe==1.1.1
- oauthlib==2.1.0
- passlib==1.7.2
- pika==1.1.0
- pycparser==2.20
- PyJWT==1.7.1
- pykafka==2.8.0
- pymemcache==3.1.1
- pymongo==3.5.1
- pypyodbc==1.3.5.2
- python-dateutil==2.8.1
- python-editor==1.0.4
- python3-openid==3.1.0
- pytz==2019.3
- PyYAML==5.3.1
- redis==3.5.0
- requests==2.23.0
- requests-oauthlib==0.8.0
- six==1.14.0
- SQLAlchemy==1.3.15
- SQLAlchemy-Utils==0.36.3
- tabulate==0.8.7
- urllib3==1.25.8
- Werkzeug==0.15.3
- WTForms==2.2.1
- python-ldap
2
Answers
My example is with Django but you can use for your flask container too
You can create a Dockerfile, for example if your flask container run within app folder of the container:
docker-compose.yml:
You need a requirements.txt file to list all your packages
And write a
Dockerfile
to install all package into app container folder when run docker-compose up:The best way here is to go through this file – https://docs.docker.com/compose/gettingstarted/. But if you want to try it fast, then here is some short instructions:
Of course in reality it will be more complex (you will have Data Base, maybe Redis, etc – for big project this tool can help you https://github.com/cookiecutter-flask/cookiecutter-flask)