A production-ready template for Python/Flask applications with Nginx reverse proxy and MongoDB database.
.
├── compose.yaml
├── flask
│ ├── Dockerfile
│ ├── requirements.txt
│ └── server.py
└── nginx
└── nginx.conf
- Nginx: High-performance web server and reverse proxy
- Flask: Lightweight Python web framework
- MongoDB: NoSQL document database
- Docker: Containerization platform
- Docker Compose: Multi-container orchestration
- Docker installed
- Docker Compose installed
- Port 80 available on host machine
- Clone the repository
- Navigate to project directory
- Start the services:
$ docker compose up -d
After deployment, you should see three running containers:
$ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
a0f4ebe686ff nginx "/bin/bash -c 'envsu…" 2 minutes ago Up 2 minutes 0.0.0.0:80->80/tcp nginx-flask-mongo_web_1
dba87a080821 nginx-flask-mongo_backend "./server.py" 2 minutes ago Up 2 minutes nginx-flask-mongo_backend_1
d7eea5481c77 mongo "docker-entrypoint.s…" 2 minutes ago Up 2 minutes 27017/tcp nginx-flask-mongo_mongo_1
- Verify the application is running:
$ curl localhost:80
Hello from the MongoDB client!
- To stop and remove containers:
$ docker compose down
- Start the services in development mode:
$ docker compose -f compose.dev.yaml up -d
-
Access the application at
http://localhost:80
-
Flask server will automatically reload on code changes
This project is licensed under the MIT License - see the LICENSE file for details.