Internal
Public Access
- Add Dockerfile for production (multi-stage build) - Add Dockerfile.dev for development with hot reload - Add docker-compose.yml with 5 services (web, mariadb, redis, celery-worker, celery-beat) - Add docker-compose.dev.yml for development overrides - Add .dockerignore for optimized builds - Add docker/entrypoint.sh startup script - Add .env.docker.example template - Add Makefile for common commands - Add deploy.sh for one-command deployment - Update config/settings/selfhosted.py to support MariaDB via DATABASE_URL - Add mysqlclient to requirements.txt for MariaDB support - Update .gitignore to exclude .env.docker 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
97 lines
2.5 KiB
Bash
Executable File
97 lines
2.5 KiB
Bash
Executable File
#!/bin/bash
|
|
set -e
|
|
|
|
# Colors for 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}KeepItGoing Server - Deployment Script${NC}"
|
|
echo -e "${BLUE}========================================${NC}"
|
|
echo ""
|
|
|
|
# Check if .env.docker exists
|
|
if [ ! -f ".env.docker" ]; then
|
|
echo -e "${RED}ERROR: .env.docker file not found!${NC}"
|
|
echo -e "${YELLOW}Please copy .env.docker.example to .env.docker and configure it.${NC}"
|
|
exit 1
|
|
fi
|
|
|
|
# Step 1: Pull latest code
|
|
echo -e "${YELLOW}[1/6] Pulling latest code from git...${NC}"
|
|
if git pull; then
|
|
echo -e "${GREEN}✓ Code updated${NC}"
|
|
else
|
|
echo -e "${RED}✗ Git pull failed${NC}"
|
|
exit 1
|
|
fi
|
|
echo ""
|
|
|
|
# Step 2: Build containers
|
|
echo -e "${YELLOW}[2/6] Building Docker containers...${NC}"
|
|
if docker-compose build; then
|
|
echo -e "${GREEN}✓ Containers built${NC}"
|
|
else
|
|
echo -e "${RED}✗ Build failed${NC}"
|
|
exit 1
|
|
fi
|
|
echo ""
|
|
|
|
# Step 3: Start containers
|
|
echo -e "${YELLOW}[3/6] Starting containers...${NC}"
|
|
if docker-compose up -d; then
|
|
echo -e "${GREEN}✓ Containers started${NC}"
|
|
else
|
|
echo -e "${RED}✗ Failed to start containers${NC}"
|
|
exit 1
|
|
fi
|
|
echo ""
|
|
|
|
# Step 4: Wait for services to be ready
|
|
echo -e "${YELLOW}[4/6] Waiting for services to be ready...${NC}"
|
|
sleep 10
|
|
echo -e "${GREEN}✓ Services ready${NC}"
|
|
echo ""
|
|
|
|
# Step 5: Run migrations
|
|
echo -e "${YELLOW}[5/6] Running database migrations...${NC}"
|
|
if docker-compose exec -T web python manage.py migrate --noinput; then
|
|
echo -e "${GREEN}✓ Migrations complete${NC}"
|
|
else
|
|
echo -e "${RED}✗ Migrations failed${NC}"
|
|
exit 1
|
|
fi
|
|
echo ""
|
|
|
|
# Step 6: Collect static files
|
|
echo -e "${YELLOW}[6/6] Collecting static files...${NC}"
|
|
if docker-compose exec -T web python manage.py collectstatic --noinput; then
|
|
echo -e "${GREEN}✓ Static files collected${NC}"
|
|
else
|
|
echo -e "${RED}✗ Failed to collect static files${NC}"
|
|
exit 1
|
|
fi
|
|
echo ""
|
|
|
|
# Restart web service for good measure
|
|
echo -e "${YELLOW}Restarting web service...${NC}"
|
|
docker-compose restart web
|
|
echo -e "${GREEN}✓ Web service restarted${NC}"
|
|
echo ""
|
|
|
|
# Show status
|
|
echo -e "${BLUE}========================================${NC}"
|
|
echo -e "${GREEN}Deployment Complete!${NC}"
|
|
echo -e "${BLUE}========================================${NC}"
|
|
echo ""
|
|
echo -e "${YELLOW}Container Status:${NC}"
|
|
docker-compose ps
|
|
echo ""
|
|
echo -e "${YELLOW}Recent logs:${NC}"
|
|
docker-compose logs --tail=20 web
|
|
echo ""
|
|
echo -e "${GREEN}Deployment successful! ✓${NC}"
|