Implements production-ready Docker setup with multi-stage builds and separate development/production configurations. New Files: - Dockerfile: Multi-stage build with Python 3.13 * Builder stage: Compiles dependencies with build tools * Runtime stage: Minimal image (~150-200MB) with non-root user * Health checks and security hardening - docker-compose.yml: Production config (pulls from Docker Hub) * Image: manticorum67/major-domo-discordapp:latest * Resource limits: 512MB RAM, 1 CPU * Volumes: /app/data (ro), /app/logs (rw) - docker-compose.dev.yml: Development config (builds locally) * Higher resource limits: 1GB RAM, 2 CPU * DEBUG log level by default - .dockerignore: Excludes unnecessary files from build context - build-and-push.sh: Interactive build/push script for Docker Hub - DOCKER.md: Comprehensive deployment guide (13K) - BUILD_AND_PUSH.md: Docker Hub build/push guide (7.7K) Configuration Updates: - config.py: Updated sheets_credentials_path to /app/data location - requirements.txt: Pinned all package versions for reproducibility - .env.example: Added Docker-specific configuration Key Features: - Multi-stage build for optimized image size - Non-root user (botuser, UID 1000) for security - Separate dev/prod compose files - Volume mounts for persistence (/app/data, /app/logs) - Health checks and automatic restarts - Resource limits and log rotation - Docker Hub integration for production deployments Docker Hub Repository: manticorum67/major-domo-discordapp 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
98 lines
2.3 KiB
Bash
Executable File
98 lines
2.3 KiB
Bash
Executable File
#!/bin/bash
|
|
# ============================================
|
|
# Build and Push Docker Image to Docker Hub
|
|
# ============================================
|
|
# Usage:
|
|
# ./build-and-push.sh # Build and push as 'latest'
|
|
# ./build-and-push.sh 2.0.0 # Build and push as 'latest' and '2.0.0'
|
|
|
|
set -e # Exit on error
|
|
|
|
# Configuration
|
|
VERSION="${1:-2.0.0}"
|
|
DOCKER_REPO="manticorum67/major-domo-discordapp"
|
|
|
|
# Color output
|
|
RED='\033[0;31m'
|
|
GREEN='\033[0;32m'
|
|
YELLOW='\033[1;33m'
|
|
BLUE='\033[0;34m'
|
|
NC='\033[0m' # No Color
|
|
|
|
echo -e "${BLUE}======================================${NC}"
|
|
echo -e "${BLUE}Docker Build and Push${NC}"
|
|
echo -e "${BLUE}======================================${NC}"
|
|
echo ""
|
|
echo -e "${YELLOW}Repository:${NC} ${DOCKER_REPO}"
|
|
echo -e "${YELLOW}Version:${NC} ${VERSION}"
|
|
echo ""
|
|
|
|
# Check if Docker is running
|
|
if ! docker info > /dev/null 2>&1; then
|
|
echo -e "${RED}❌ Error: Docker is not running${NC}"
|
|
exit 1
|
|
fi
|
|
|
|
# Check if logged in to Docker Hub
|
|
if ! docker info 2>/dev/null | grep -q "Username"; then
|
|
echo -e "${YELLOW}⚠️ Not logged in to Docker Hub${NC}"
|
|
echo -e "${YELLOW}Please log in:${NC}"
|
|
docker login
|
|
echo ""
|
|
fi
|
|
|
|
# Build image
|
|
echo -e "${BLUE}🔨 Building Docker image...${NC}"
|
|
echo ""
|
|
|
|
if [ "$VERSION" = "latest" ]; then
|
|
# Only tag as latest
|
|
docker build -t ${DOCKER_REPO}:latest .
|
|
else
|
|
# Tag as both latest and version
|
|
docker build \
|
|
-t ${DOCKER_REPO}:latest \
|
|
-t ${DOCKER_REPO}:${VERSION} \
|
|
.
|
|
fi
|
|
|
|
echo ""
|
|
echo -e "${GREEN}✅ Build complete!${NC}"
|
|
echo ""
|
|
|
|
# Confirm push
|
|
echo -e "${YELLOW}Ready to push to Docker Hub${NC}"
|
|
read -p "Continue? (y/n) " -n 1 -r
|
|
echo ""
|
|
|
|
if [[ ! $REPLY =~ ^[Yy]$ ]]; then
|
|
echo -e "${YELLOW}❌ Push cancelled${NC}"
|
|
exit 0
|
|
fi
|
|
|
|
# Push image
|
|
echo ""
|
|
echo -e "${BLUE}📤 Pushing to Docker Hub...${NC}"
|
|
echo ""
|
|
|
|
docker push ${DOCKER_REPO}:latest
|
|
|
|
if [ "$VERSION" != "latest" ]; then
|
|
docker push ${DOCKER_REPO}:${VERSION}
|
|
fi
|
|
|
|
echo ""
|
|
echo -e "${GREEN}✅ Push complete!${NC}"
|
|
echo ""
|
|
echo -e "${GREEN}🎉 Image available at:${NC}"
|
|
echo -e " docker pull ${DOCKER_REPO}:latest"
|
|
|
|
if [ "$VERSION" != "latest" ]; then
|
|
echo -e " docker pull ${DOCKER_REPO}:${VERSION}"
|
|
fi
|
|
|
|
echo ""
|
|
echo -e "${BLUE}======================================${NC}"
|
|
echo -e "${GREEN}Done!${NC}"
|
|
echo -e "${BLUE}======================================${NC}"
|