How clouddevopshub/dockerfile-advance-demo works
Purpose
A minimal Docker optimization demonstration. It builds the same Python application with two Dockerfiles to compare image size and likely dependency/layer practices.
Entry Point
• app.py is the application runtime entry point.
• Dockerfile.bloated and Dockerfile.optimized define alternative container build paths for that application.
• requirements.txt supplies Python dependencies to both image variants.
Application Runtime
The repository packages a Python application:
• Source: app.py
• Dependencies: requirements.txt
• Container execution is controlled by the CMD/ENTRYPOINT definitions expected in Dockerfile.bloated and Dockerfile.optimized.
Bloated Build Path
Dockerfile.bloated is the baseline image design intended to demonstrate inefficient image construction. Its architecture is the reference point for size comparison and may include unnecessary build context, package caches, broad base layers, or non-minimized dependency installation.
Optimized Build Path
Dockerfile.optimized is the alternative production-oriented build design. It packages the same app.py and requirements.txt while aiming to reduce final image size through Docker-layer and dependency/build-artifact minimization.
Build and Comparison Flow
1. Docker receives the repository directory as build context.
2. Build app:bloated from Dockerfile.bloated.
3. Build app:optimized from Dockerfile.optimized.
4. Compare resulting local image sizes using Docker image metadata.
The key boundary is build-time Docker image construction versus runtime execution of app.py; no external services, persistent infrastructure, or web-facing interface are indicated.
Material Infrastructure
• Docker daemon/build system is required.
• Python runtime is supplied by the selected Docker base images.
• Image tags app:bloated and app:optimized are local Docker artifacts.
Components 12
Docker Build Paths
Alternative builds from the same repository context.
- Repository build context
- Python dependencies
requirements.txt - Docker daemon / builder
- Bloated Dockerfile · Demonstrates inefficient image construction.
Dockerfile.bloated - Optimized Dockerfile · Minimizes layers and build artifacts.
Dockerfile.optimized - app:bloated
- app:optimized
- Image size comparison · Compares resulting local image sizes.
Container Runtime
- Python application · Shared application entry point.
app.py - Bloated container
- Optimized container
- Python runtime · Supplied by each selected base image.
Connections 17
- Repository build context → Docker daemon / builder: sent as build context
- Python dependencies → Bloated Dockerfile: installed by
- Python dependencies → Optimized Dockerfile: installed by
- Python application → Bloated Dockerfile: packaged by
- Python application → Optimized Dockerfile: packaged by
- Bloated Dockerfile → Docker daemon / builder: build recipe
- Optimized Dockerfile → Docker daemon / builder: build recipe
- Docker daemon / builder → app:bloated: builds
- Docker daemon / builder → app:optimized: builds
- app:bloated → Image size comparison: size metadata
- app:optimized → Image size comparison: size metadata
- app:bloated → Bloated container: runs as
- app:optimized → Optimized container: runs as
- Bloated container → Python application: executes
- Optimized container → Python application: executes
- Python runtime → Bloated container: provides runtime
- Python runtime → Optimized container: provides runtime