Deployment & Rollbacks¶
This document outlines the standard operating procedures for deploying and rolling back the Cloudflare worker.
1. Deployment Process¶
Local Development¶
For local development that requires access to bound services like Vectorize and Workers AI, use the --remote flag.
# Navigate to the worker's directory
cd cloudflare/
# Start a remote development session
wrangler dev --remote
# Test the local server
curl -s http://127.0.0.1:8787/rag/health | jq
Staging Environment¶
Deploying to the stage environment is the standard step before production.
# Ensure the API_KEY secret is set for the staging environment
wrangler secret put API_KEY --env stage
# Deploy to staging
wrangler deploy --env stage
# Tail logs to monitor the deployment
wrangler tail --env stage
Production Environment¶
Production Deployment
Ensure that all changes have been thoroughly tested in the staging environment before deploying to production.
# Ensure the API_KEY secret is set for the production environment
wrangler secret put API_KEY --env prod
# Deploy to production
wrangler deploy --env prod
API Cache Reload¶
After deploying a new worker, especially if its URL or API key has changed, you must clear the configuration cache in the Labeeb API service to ensure it picks up the new settings from the .env file.
# Execute from the project root
docker compose exec api php artisan config:clear && docker compose exec api php artisan config:cache
2. Rollback Procedure¶
If a deployment introduces a critical issue, you can quickly roll back to a previous, stable version of the worker.
-
List available versions:
-
Roll back to a specific version: Copy the ID of the version you want to restore.
For the API service, the standard rollback procedure is to revert the relevant pull request or redeploy a previous Docker image version, followed by clearing the configuration cache.