Containerized Machine Learning serving workflow using Docker, FastAPI, Docker Compose and GitHub Actions.
This project demonstrates a production-oriented ML serving workflow with:
- training container
- persistent ML artifact
- FastAPI inference service
- Docker Compose orchestration
- GitHub Actions CI/CD
- GitHub Container Registry (GHCR)
The goal is to understand the fundamentals of:
- ML serving
- containerization
- deployment workflows
- CI/CD
- MLOps foundations
training container
↓
persistent ML artifact
↓
FastAPI serving container
↓
GitHub Actions CI/CD
↓
GitHub Container Registry
↓
docker pull / docker run
The system separates:
- model training
- artifact persistence
- inference serving
- image publishing
using independent Docker workflows.
- Python
- scikit-learn
- FastAPI
- Docker
- Docker Compose
- GitHub Actions
- GitHub Container Registry (GHCR)
- joblib
ml-serving-stack/
│
├── training/
│ ├── train.py
│ ├── Dockerfile
│ └── requirements.txt
│
├── api/
│ ├── main.py
│ ├── Dockerfile
│ └── requirements.txt
│
├── data/
│ └── models/
│
├── docs/
│ ├── docker_week1.md
│ ├── docker_week2.md
│ ├── docker_week3.md
│ └── docker_week4.md
│
├── .github/
│ └── workflows/
│ └── ci.yml
│
├── docker-compose.yml
├── .gitignore
└── README.md
docker compose --profile train run --rm trainingThis generates:
data/models/model.joblib
docker compose up apiAPI available at:
http://localhost:8000
curl http://localhost:8000/healthcurl -X POST http://localhost:8000/predict \
-H "Content-Type: application/json" \
-d '{"features": [5.1, 3.5, 1.4, 0.2]}'http://localhost:8000/docs
The repository includes a GitHub Actions workflow that:
- builds the FastAPI Docker image
- publishes the image to GitHub Container Registry
- enables image portability across environments
Workflow file:
.github/workflows/ci.yml
Published image:
ghcr.io/donatocorbaciodev/ml-api:latest
Pull image from GHCR:
docker pull ghcr.io/donatocorbaciodev/ml-api:latestRun container with mounted ML artifact:
docker run --rm -p 8000:8000 \
-v "$(pwd)/data/models:/data/models:ro" \
ghcr.io/donatocorbaciodev/ml-api:latest- Docker containerization
- Layer caching
- Bind mounts
- Persistent ML artifacts
- FastAPI model serving
- Docker Compose orchestration
- Container networking
- Read-only volumes
- Docker HEALTHCHECK
- Non-root containers
- Docker Scout vulnerability scanning
- GitHub Actions CI/CD
- Container registry publishing
- ML artifact separation
The project includes several production-oriented practices:
- startup model loading
- container health monitoring
- non-root container execution
- vulnerability scanning
- CI/CD automation
- image publishing workflow
- artifact separation from application image
The repository currently focuses on:
- Docker-based ML serving
- local deployment workflows
- CI/CD fundamentals
- ML artifact management
- container lifecycle understanding
Advanced orchestration technologies such as Kubernetes are intentionally out of scope at this stage.
This repository is part of a hands-on learning path focused on:
- ML Engineering
- Docker
- API serving
- deployment workflows
- CI/CD
- MLOps fundamentals
Possible future extensions:
- forecasting model serving
- model versioning
- automated testing
- MLflow integration
- cloud deployment
- Kubernetes orchestration
- GPU-based inference