This repository contains my tested, production-ready Dockerfile blueprints for three common backend stacks. This is the companion repo for my "2025 Docker Roadmap" post on LinkedIn.
Each blueprint follows modern, secure practices:
- Multi-Stage Builds: To create small, clean production images.
- Non-Root Users: To enhance security by following the principle of least privilege.
- Minimal Base Images: (
alpine,-slim) to reduce attack surfaces.
docker-blueprints/
│
├── python/ # Flask + Gunicorn app
├── node/ # Express.js app
├── java/ # Spring Boot app
│
└── compose-stack/ # Orchestration logic
├── docker-compose.yml
└── .env.example
---
## Projects
* `python/`: A "Hello, World" Flask app served with Gunicorn.
* `java/`: A "Hello, World" Spring Boot app.
* `node/`: A "Hello, World" Express.js app.
- Files:
Dockerfile,app.py,requirements.txt
# 1. Go to the python directory
cd python
# 2. Build the image
docker build -t my-python-app .
# 3. Run the container
docker run -d -p 5000:5000 --name python-test my-python-appVerify at: http://localhost:5000
- Files:
Dockerfile,pom.xml,src/...
# 1. Go to the java directory
cd java
# 2. Build the image
docker build -t my-java-app .
# 3. Run the container
docker run -d -p 8080:8080 --name java-test my-java-appVerify at: http://localhost:8080/hello
- Files:
Dockerfile,index.js,package.json
# 1. Go to the node directory
cd node
# 2. Build the image
docker build -t my-node-app .
# 3. Run the container
docker run -d -p 3000:3000 --name node-test my-node-appVerify at: http://localhost:3000
After you're done, here's how to clean up your running containers.
# Stop the container
docker stop python-test
# Remove the container
docker rm python-testdocker stop python-test java-test node-test
docker rm python-test java-test node-testThe full "Apartment Complex" (orchestration) lives inside the compose-stack/ directory. This spins up all three services plus a Postgres database, connected via a private network.
Navigate to the compose directory and create your environment file:
cd compose-stack
cp .env.example .envOpen .env and set your secure credentials (or use the defaults for local dev):
POSTGRES_USER=youruser
POSTGRES_PASSWORD=yourpassword
POSTGRES_DB=yourdb
DATABASE_URL=postgresql://youruser:yourpassword@db:5432/yourdb
Build and start the entire system in detached mode:
docker compose up --build -ddocker compose logs -fStop & Clean Up:
# Stops containers and removes the private network & volumes
docker compose down -v- Inside Docker Compose, containers communicate using Service Discovery. They resolve IP addresses by their service name, not hardcoded IPs.
- Python connects to the database at hostname: dbNode could call the Java service at hostname: java.
- This creates a portable environment that works exactly the same on your laptop as it does in the cloud.
These configurations follow the "2025 Roadmap" for containerization: text
- ✅ Multi-stage builds: Separating build tools from runtime artifacts.
- ✅ Non-root users: Enforcing the Principle of Least Privilege.
- ✅ Minimal Base Images: Using alpine and slim variants to reduce vulnerabilities.
- ✅ No Secrets in Dockerfiles: All credentials injected at runtime via .env.
- ✅ Immutable Infrastructure: "Cattle, not Pets" mindset.
LicenseMIT © Vanisha ParwalYou are free to use, modify, and build upon these blueprints for your own projects.