Sign inSign up

riteshatri/upload-app

By riteshatri

β€’Updated 9 months ago

Image
0

341

riteshatri/upload-app repository overview

A lightweight Streamlit-based web application, packaged as a Docker image, designed to demonstrate Persistent Volume (PV) and Persistent Volume Claim (PVC) concepts in Docker/Kubernetes.

This app allows users to:

  • Upload multiple images via a browser
  • Persist uploaded images on disk
  • View uploaded images in a clean gallery layout

The repository image is available on Docker Hub and is intentionally kept small, simple, and practical for DevOps & Kubernetes learning use‑cases.


β πŸ” What Does This Image Do?

This Docker image runs a Streamlit web server that:

  1. Accepts image uploads (png, jpg, jpeg)
  2. Stores images inside a local /photos directory
  3. Displays all stored images in a responsive grid

πŸ’‘ Core learning objective:

Demonstrate how application data can be persisted using volumes (PV/PVC) instead of being lost when containers restart.


⁠🧠 Why This App Is Useful (Real Meaning)

In real-world Kubernetes:

  • Containers are ephemeral
  • Pod restarts = data loss ❌ (unless volumes are used)

This app makes that concept visually clear:

  • Upload images β†’ stored in /photos
  • Restart container / pod
  • Images remain available if volume is mounted

Perfect for:

  • Docker volumes practice
  • Kubernetes PV / PVC demos
  • Interviews & concept explanation

β πŸ—‚ Repository Structure (Explained Deeply)

upload-app/
β”œβ”€β”€ manifests/        # (Optional) Kubernetes YAMLs (PV, PVC, Deployment)
β”œβ”€β”€ photos/           # Runtime directory where images are stored
β”œβ”€β”€ Dockerfile        # Container build instructions
β”œβ”€β”€ main.py           # Streamlit application code
β”œβ”€β”€ requirements.txt  # Python dependencies
β”œβ”€β”€ pyproject.toml    # Project metadata (modern Python standard)
β”œβ”€β”€ uv.lock           # Dependency lock file
β”œβ”€β”€ README.md         # Documentation
└── .python-version   # Python version pin (3.11)
β πŸ”Ή photos/

This is the MOST IMPORTANT directory.

  • All uploaded images are stored here
  • This is the directory you mount as:
    • Docker volume
    • Kubernetes PVC

⁠🐳 Docker Image Details

⁠Base Image
python:3.11-slim
  • Lightweight
  • Secure
  • Production-friendly
⁠Exposed Port
8501

(Default Streamlit port)


⁠🧱 Dockerfile Explained (Line by Line)

FROM python:3.11-slim

βœ” Minimal Python image

WORKDIR /app

βœ” All app files live here

COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt

βœ” Dependency installation

COPY . .

βœ” Copy application code

EXPOSE 8501

βœ” Streamlit UI port

CMD ["streamlit", "run", "main.py", "--server.port=8501", "--server.address=0.0.0.0"]

βœ” Starts Streamlit server


⁠▢️ How To Run This Image (Docker)

⁠1️⃣ Pull Image
docker pull riteshatri/upload-app:latest
⁠2️⃣ Run Without Volume (Data will be lost)
docker run -d \
  -p 8501:8501 \
  --name upload-app \
  riteshatri/upload-app:latest

❌ Restart container β†’ images gone


docker volume create photos-data
docker run -d \
  -p 8501:8501 \
  -v photos-data:/app/photos \
  --name upload-app \
  riteshatri/upload-app:latest

βœ… Restart container β†’ images stay


⁠☸️ Kubernetes Use Case (PV / PVC)

⁠Concept Mapping
App PathKubernetes Resource
/app/photosPersistentVolumeClaim
⁠Deployment Example (Conceptual)
volumeMounts:
- name: photos-volume
  mountPath: /app/photos

Now:

  • Pod delete ❌ β†’ data safe
  • Pod recreate βœ… β†’ images still visible

β πŸ–Ό Application Features (UI Level)

⁠Upload Section
  • Multiple file upload
  • Supported formats: png, jpg, jpeg
⁠Storage Logic
PHOTOS_DIR = Path("photos")
PHOTOS_DIR.mkdir(exist_ok=True)

βœ” Directory auto-created

  • 4-column responsive grid
  • Auto-detects stored images

β πŸ“¦ Dependencies

From requirements.txt:

streamlit
pillow
PackagePurpose
StreamlitWeb UI framework
PillowImage processing

β πŸ” Security Notes

  • No authentication (demo app)
  • Not intended for public production exposure
  • Best used inside:
    • Internal cluster
    • Learning environment

β πŸš€ Ideal For

βœ… Docker learners
βœ… Kubernetes beginners
βœ… PV/PVC explanation
βœ… Interview demos
βœ… DevOps labs


⁠πŸ§ͺ Common Test Scenarios

  1. Upload images
  2. Restart container
  3. Observe data loss (without volume)
  4. Attach volume
  5. Restart again
  6. Observe persistence 🎯

β πŸ“Œ Summary (One-Line)

A minimal Streamlit app Docker image designed to visually and practically demonstrate persistent storage using Docker volumes and Kubernetes PV/PVC.


β πŸ‘¨β€πŸ’» Maintainer

Ritesh Sharma
DevOps | Docker | Kubernetes | Azure


⭐ If you are learning containers & Kubernetes β€” this image is made exactly for you.

Tag summary

Content type

Image

Digest

sha256:f7e7e6a13…

Size

168.6 MB

Last updated

9 months ago

docker pull riteshatri/upload-app