The Flask app with Redis - caching service and containerization with Docker
flask_app/
│── .dockerignore # List of Docker ignore folders/files
│── .env-example # Environment variables example
│── .gitignore # List of git ignore folders/files
│── app.py # Flask entry point
│── configs.py # Project configs
│── Dockerfile # Source code of container image
│── docker-compose.yaml # Config for multi-container setup
│── gunicorn.conf.py # Gunicorn server configs
│── requirements.txt # Dependencies
│── README.md # Documentation- Clone the project repository
git clone git@github.com:mirzomumin/flask_app.git- Move to the project directory
cd flask_app- Create
.envfile and copy the content of.env-examplefile into it with default parameters.
cp .env-example .envYou can change .env file parameters value at any time as you wish.
- Launch the app with Docker
docker compose up --build -d- GET /ping → Check flask app liveness
Request
curl -X 'GET' \
'http://127.0.0.1:5000/ping' \
-H 'accept: application/json' \
-H 'Content-Type: application/json'Response
{"status":"ok"}- GET /count → Return visit count
Request
curl -X 'GET' \
'http://127.0.0.1:5000/count' \
-H 'accept: application/json' \
-H 'Content-Type: application/json'Response
{"visit_count": 12}- Stop and remove containers, networks
docker compose down