-
Notifications
You must be signed in to change notification settings - Fork 0
Deployment Fixes #91
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Deployment Fixes #91
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -88,3 +88,4 @@ output/ | |
| _ul | ||
| nul | ||
| /tmpclaude-1fc2-cwd | ||
| /webapp/job_storage/ | ||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -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 | ||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||
| git pull origin main | |
| if [ -n "${UPDATE_BRANCH:-}" ]; then | |
| git pull origin "${UPDATE_BRANCH}" | |
| else | |
| git pull | |
| fi |
Copilot
AI
Jan 12, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The migration command runs on a container that may still be using the old code. The sequence should be: (1) rebuild containers, (2) restart services with new code, (3) run migrations on the updated container. Currently, migrations run at step 3 (line 49) but the services are restarted at step 4 (line 53), which means migrations could run against old code if the container hasn't been recreated yet. Consider moving the migration step after the service restart.
| # 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 3: Restart services with new code | |
| log_info "Restarting services..." | |
| docker compose -f ${COMPOSE_FILE} up -d | |
| # Step 4: Run database migrations | |
| log_info "Running database migrations..." | |
| docker exec ${CONTAINER} flask db upgrade |
Copilot
AI
Jan 12, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The health check script uses the requests library, but requests is not listed as a dependency in requirements-ngc.txt. The health check command on line 59 runs import requests; r = requests.get(...), which will fail if the requests library is not installed in the container. Either add requests to the requirements file or modify the health check to use a different approach, such as using curl or Python's built-in urllib.
| 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 | |
| if docker exec ${CONTAINER} python -c "import urllib.request, sys; req = urllib.request.Request('http://localhost:5000/api/health'); r = urllib.request.urlopen(req, timeout=5); sys.exit(0 if r.getcode() == 200 else 1)" 2>/dev/null; then |
Copilot
AI
Jan 12, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The grep pattern "writebot-celery" will not match the actual Celery container names. In the development docker-compose.yml, the containers are named "writebot-celery-worker" and "writebot-celery-beat", not "writebot-celery". The pattern should be changed to match the actual container names, for example using "writebot-celery-worker" or a pattern like "writebot-celery-.*" to match both worker and beat containers.
| if docker ps --format '{{.Names}}' | grep -q "writebot-celery"; then | |
| if docker ps --format '{{.Names}}' | grep -q "writebot-celery-"; then |
Copilot
AI
Jan 12, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The script doesn't account for Docker Compose profiles used in production. The docker-compose.production.yml file uses profiles: [celery] for celery-worker and celery-beat services, which means these services won't be started by default with docker compose up -d. To restart Celery services in production when using profiles, you need to specify the profile explicitly, e.g., docker compose -f ${COMPOSE_FILE} --profile celery restart celery-worker celery-beat. Without this, the restart command on line 68 will fail for production deployments that use Celery.
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
|
|
@@ -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 | ||||||||
|
||||||||
| Flask-Migrate>=4.0.0 | |
| Flask-Migrate>=4.0.0 | |
| alembic>=1.13.0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use single equals sign for string comparison in bash instead of double equals for better POSIX compliance and portability. While
==works in bash,=is the standard POSIX comparison operator and is more portable across different shell implementations.