From f96855969baad2b029f1515a36eb2daacf85e85f Mon Sep 17 00:00:00 2001 From: Arie Joe Date: Mon, 12 Jan 2026 21:38:20 +1300 Subject: [PATCH 1/2] Add new dependencies: Flask-Migrate, python-dotenv, Flask-Mailman, Celery, itsdangerous, and monitoring/logging tools (structlog, sentry-sdk, flower) --- requirements-ngc.txt | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/requirements-ngc.txt b/requirements-ngc.txt index 2a530d9..2c376e4 100644 --- a/requirements-ngc.txt +++ b/requirements-ngc.txt @@ -12,6 +12,8 @@ openpyxl # Flask dependencies flask>=2.3.2 +itsdangerous>=2.1.0 +python-dotenv>=1.0.0 Flask-Login>=0.6.2 Flask-SQLAlchemy>=3.0.0 Flask-WTF>=1.1.1 @@ -22,9 +24,18 @@ Flask-Caching>=2.0.0 Flask-Limiter>=3.3.0 Flask-Minify>=0.42 flask-assets>=2.0 +Flask-Migrate>=4.0.0 rjsmin rcssmin -alembic>=1.13.0 gunicorn>=21.2.0 psycopg2-binary>=2.9.9 redis>=5.0.0 + +# Job Queue & Email +Flask-Mailman>=1.0.0 +celery[redis]>=5.3.0 + +# Monitoring & Logging +structlog>=24.0.0 +sentry-sdk[flask,celery]>=2.0.0 +flower>=2.0.0 From 4860697ffdb493a03edcc4392eb6b7716456fd4d Mon Sep 17 00:00:00 2001 From: Arie Joe Date: Mon, 12 Jan 2026 21:38:54 +1300 Subject: [PATCH 2/2] Add update script for Docker deployments and ignore job storage directory --- .gitignore | 1 + deploy/update.sh | 76 ++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 77 insertions(+) create mode 100644 deploy/update.sh diff --git a/.gitignore b/.gitignore index f381b32..17a24ed 100644 --- a/.gitignore +++ b/.gitignore @@ -88,3 +88,4 @@ output/ _ul nul /tmpclaude-1fc2-cwd +/webapp/job_storage/ diff --git a/deploy/update.sh b/deploy/update.sh new file mode 100644 index 0000000..0943e3f --- /dev/null +++ b/deploy/update.sh @@ -0,0 +1,76 @@ +#!/bin/bash +# WriteBot Update Script for Docker Deployments +# Usage: ./deploy/update.sh [--production] + +set -e + +# Colors for output +RED='\033[0;31m' +GREEN='\033[0;32m' +YELLOW='\033[1;33m' +NC='\033[0m' # No Color + +log_info() { echo -e "${GREEN}[INFO]${NC} $1"; } +log_warn() { echo -e "${YELLOW}[WARN]${NC} $1"; } +log_error() { echo -e "${RED}[ERROR]${NC} $1"; } + +# Determine compose file and container name +if [ "$1" == "--production" ]; then + COMPOSE_FILE="docker-compose.production.yml" + CONTAINER="writebot-app-production" + log_info "Using production configuration" +else + COMPOSE_FILE="docker-compose.yml" + CONTAINER="writebot-app" + log_info "Using development configuration" +fi + +# Check if container is running +if ! docker ps --format '{{.Names}}' | grep -q "^${CONTAINER}$"; then + log_error "Container ${CONTAINER} is not running!" + log_info "Start it with: docker compose -f ${COMPOSE_FILE} up -d" + exit 1 +fi + +log_info "Starting update process..." + +# Step 1: Pull latest code (if using git) +if [ -d ".git" ]; then + log_info "Pulling latest code..." + git pull origin main +fi + +# Step 2: Rebuild containers with new code +log_info "Rebuilding containers..." +docker compose -f ${COMPOSE_FILE} build + +# Step 3: Run database migrations +log_info "Running database migrations..." +docker exec ${CONTAINER} flask db upgrade + +# Step 4: Restart services with new code +log_info "Restarting services..." +docker compose -f ${COMPOSE_FILE} up -d + +# Step 5: Verify health +log_info "Waiting for health check..." +sleep 10 + +if docker exec ${CONTAINER} python -c "import requests; r = requests.get('http://localhost:5000/api/health', timeout=5); exit(0 if r.status_code == 200 else 1)" 2>/dev/null; then + log_info "Health check passed!" +else + log_warn "Health check failed - check logs with: docker logs ${CONTAINER}" +fi + +# Step 6: Restart Celery workers (if using job queue) +if docker ps --format '{{.Names}}' | grep -q "writebot-celery"; then + log_info "Restarting Celery workers..." + docker compose -f ${COMPOSE_FILE} restart celery-worker celery-beat 2>/dev/null || true +fi + +log_info "Update complete!" +echo "" +echo "Useful commands:" +echo " View logs: docker logs -f ${CONTAINER}" +echo " Check status: docker compose -f ${COMPOSE_FILE} ps" +echo " Run shell: docker exec -it ${CONTAINER} bash"