This guide covers Docker deployment on Apple M2 Mac with Docker Desktop and Kubernetes integration.
!!! info “CLI Container Deployment” PyBiorythm containers run CLI applications, not web servers. The deployment patterns shown here demonstrate:
- **Interactive containers** for development and testing
- **Batch processing** with Docker Compose
- **One-shot containers** for generating charts
References to health endpoints and load balancers are **demonstration examples** of production deployment patterns for web applications.
desktop-linux
(Docker Desktop’s Linux VM)# One-shot biorhythm generation
docker run --rm pybiorythm:latest python main.py -y 1990 -m 5 -d 15
# Interactive CLI session
docker run -it --rm pybiorythm:latest
# Generate JSON output and save to host
docker run --rm -v $(pwd)/output:/output pybiorythm:latest \
sh -c "python main.py -y 1990 -m 5 -d 15 --orientation json-vertical > /output/biorhythm.json"
# Health check verification
docker run --rm pybiorythm:latest python -c "import biorythm; print('✅ Container healthy')"
# Development with volume mount
docker run -it --rm -v $(pwd):/app -w /app python:3.12-slim bash
# Fast local build
./docker-build-m2.sh
# Or manually
docker build --platform linux/arm64 -t pybiorythm:local .
# For deployment to various architectures
./docker-build-m2.sh v1.0.0 multi
# Build and deploy locally
./docker-build-m2.sh latest compose
# Or manually
docker-compose -f docker-compose.local.yml up -d
# Build and deploy to Docker Desktop K8s
./docker-build-m2.sh latest k8s
# Or manually
kubectl apply -f k8s-deployment.yaml
docker-build-m2.sh
)Command | Description | Use Case |
---|---|---|
./docker-build-m2.sh |
Build for local M2 Mac | Development |
./docker-build-m2.sh v1.0.0 multi |
Multi-architecture build | CI/CD |
./docker-build-m2.sh latest compose |
Build + Docker Compose | Local testing |
./docker-build-m2.sh latest k8s |
Build + Kubernetes | Local K8s testing |
./docker-build-m2.sh latest all |
Build + Deploy everywhere | Full local setup |
./docker-build-m2.sh clean |
Clean old images | Maintenance |
# Start services
docker-compose -f docker-compose.local.yml up -d
# View logs
docker-compose -f docker-compose.local.yml logs -f
# Access container
docker-compose -f docker-compose.local.yml exec biorythm bash
# Stop services
docker-compose -f docker-compose.local.yml down
# Start with development tools
docker-compose -f docker-compose.local.yml --profile dev up -d
# Deploy application
kubectl apply -f k8s-deployment.yaml
# Check status
kubectl get pods -l app=biorythm
kubectl get services
# Access application
kubectl port-forward svc/biorythm-service 8080:8080
# View logs
kubectl logs -l app=biorythm -f
# Delete deployment
kubectl delete -f k8s-deployment.yaml
docker-compose.local.yml
k8s-deployment.yaml
.actrc
(Updated for M2)# Use BuildKit for faster builds
export DOCKER_BUILDKIT=1
# Enable build cache
docker buildx create --use
# Parallel builds
docker buildx build --platform linux/arm64,linux/amd64
# Pull the required image
docker pull catthehacker/ubuntu:act-latest
# Specify platform explicitly
docker run --platform linux/arm64 pybiorythm:local
# Switch to Docker Desktop context
kubectl config use-context docker-desktop
# Verify context
kubectl config current-context
# Check Docker Desktop resource limits
docker system df
docker system prune -f
biorythm
userpython:3.12-slim
./docker-build-m2.sh latest local
./docker-build-m2.sh latest compose
./docker-build-m2.sh latest k8s
./docker-build-m2.sh v1.0.0 multi
# Access K8s dashboard (if enabled)
kubectl proxy
# Open: http://localhost:8001/api/v1/namespaces/kubernetes-dashboard/services/https:kubernetes-dashboard:/proxy/
# Docker stats
docker stats
# K8s resource usage
kubectl top pods
kubectl top nodes
# Application logs
kubectl logs -l app=biorythm --tail=100 -f
This setup provides optimal Docker experience on M2 Mac with seamless local development and production deployment capabilities.