Lightweight Django project demonstrating a simple CI/CD pipeline with Docker, Kubernetes (Minikube), and Jenkins.
- Quick Start
- Docker
- Kubernetes (Minikube)
- CI / Jenkins
- Project Structure
- Contributing
- License & Contact
Local development using a virtual environment:
- Create and activate a venv
python -m venv venv
source venv/bin/activate # or `venv\\Scripts\\activate` on Windows- Install dependencies and run migrations
pip install -r requirements.txt
python manage.py migrate
python manage.py runserverOpen http://127.0.0.1:8000/ in your browser.
Build and run the app in Docker:
docker build -t django-app:latest .
docker run --rm -p 8000:8000 django-app:latestTip: For production use, serve with gunicorn and configure static files appropriately.
This repo includes Kubernetes manifests in the k8s/ folder. Example commands for Minikube:
minikube start --driver=docker
kubectl apply -f k8s/deployment.yaml
kubectl apply -f k8s/service.yaml
# Forward the service to localhost
kubectl port-forward svc/django-service 8000:8000 --address 0.0.0.0Then open http://<MINIKUBE-IP>:8000/ or http://localhost:8000/ if port-forwarding.
Two Jenkins pipeline files are provided: Jenkinsfile (main) and Jenkinsfile-test (test pipeline). They demonstrate build, test, Docker build, and deploy stages.
manage.py— Django management scriptapp/— small example app withviews.pyandurls.pydjango_demo/— Django project settings and WSGI/ASGIk8s/— Kubernetes manifests (deployment.yaml,service.yaml)Jenkinsfile,Jenkinsfile-test— CI/CD pipeline definitionsDockerfile— Docker image build instructions
sudo apt install -y docker.io sudo usermod -aG docker ubuntu # needed for minikube sudo usermod -aG docker jenkins
sudo reboot
curl -LO https://storage.googleapis.com/minikube/releases/latest/minikube-linux-amd64 sudo install minikube-linux-amd64 /usr/local/bin/minikube
curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl" chmod +x kubectl sudo mv kubectl /usr/local/bin/
sudo usermod -aG docker $USER && newgrp docker minikube start --driver=docker
kubectl get nodes
kubectl port-forward --address 0.0.0.0 svc/django-service 8000:80
http://:8000/hello/
{"message": "Hello from Django CI/CD 🚀 (v1)"}
docker pull 047719618727.dkr.ecr.us-east-1.amazonaws.com/django-cicd-demo:latest minikube image load 047719618727.dkr.ecr.us-east-1.amazonaws.com/django-cicd-demo:latest containers: - name: django image: 047719618727.dkr.ecr.us-east-1.amazonaws.com/django-cicd-demo:latest imagePullPolicy: Never # update this
- Open an issue or submit a PR with a clear description and tests.
This project is provided as-is for demo and learning purposes. For questions, open an issue or contact the maintainer.