Skip to main content

/deploy-site

Deploy a CODITECT website to Google Cloud Platform.

System Prompt

⚠️ EXECUTION DIRECTIVE: When the user invokes this command, you MUST:

  1. ASK for confirmation before deployment (production impact)
  2. ALWAYS show full output from deployment process
  3. ALWAYS verify site is accessible after deployment

This command modifies production infrastructure.


Usage

/deploy-site [domain] [options]

Arguments

Domain

Target subdomain for deployment:

  • docs.coditect.ai - Documentation site
  • dms.coditect.ai - DMS product site
  • workflow.coditect.ai - Workflow product site

Options

OptionDescriptionDefault
--sourceSource directory (built files)./dist
--platformDeployment platformcloud-run
--regionGCP regionus-central1
--memoryContainer memory256Mi
--cpuCPU allocation1
--min-instancesMinimum instances0
--max-instancesMaximum instances10
--dry-runPreview without deployingfalse

Examples

Deploy Documentation Site

/deploy-site docs.coditect.ai --source ./docs-site/dist

Deploy with Custom Resources

/deploy-site dms.coditect.ai --source ./dist --memory 512Mi --min-instances 1

Dry Run (Preview)

/deploy-site docs.coditect.ai --source ./dist --dry-run

Execution Steps

When invoked, execute these steps:

Step 1: Pre-Flight Checks

# Verify GCP authentication
gcloud auth list
if [ $? -ne 0 ]; then
echo "❌ Not authenticated. Run: gcloud auth login"
exit 1
fi

# Verify project
gcloud config get-value project

# Verify source directory
if [ ! -d "$SOURCE_DIR" ]; then
echo "❌ Source directory not found: $SOURCE_DIR"
exit 1
fi

# Verify index.html exists
if [ ! -f "$SOURCE_DIR/index.html" ]; then
echo "❌ index.html not found in $SOURCE_DIR"
exit 1
fi

Step 2: Create Dockerfile (if not exists)

FROM nginx:alpine
COPY . /usr/share/nginx/html
COPY nginx.conf /etc/nginx/conf.d/default.conf
EXPOSE 8080
CMD ["nginx", "-g", "daemon off;"]

Step 3: Create nginx.conf (if not exists)

server {
listen 8080;
server_name _;
root /usr/share/nginx/html;
index index.html;

location / {
try_files $uri $uri/ /index.html;
}

location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg|woff|woff2)$ {
expires 1y;
add_header Cache-Control "public, immutable";
}

gzip on;
gzip_types text/plain text/css application/json application/javascript;
}

Step 4: Build and Push Container

# Extract service name from domain
SERVICE_NAME=$(echo $DOMAIN | sed 's/.coditect.ai//' | sed 's/\./-/g')

# Build container
gcloud builds submit \
--tag gcr.io/$PROJECT_ID/$SERVICE_NAME:latest \
$SOURCE_DIR

Step 5: Deploy to Cloud Run

gcloud run deploy $SERVICE_NAME \
--image gcr.io/$PROJECT_ID/$SERVICE_NAME:latest \
--region $REGION \
--allow-unauthenticated \
--memory $MEMORY \
--cpu $CPU \
--min-instances $MIN_INSTANCES \
--max-instances $MAX_INSTANCES

Step 6: Map Custom Domain

# Check if domain mapping exists
EXISTING=$(gcloud run domain-mappings list --region $REGION --filter="metadata.name=$DOMAIN" --format="value(metadata.name)")

if [ -z "$EXISTING" ]; then
gcloud run domain-mappings create \
--service $SERVICE_NAME \
--domain $DOMAIN \
--region $REGION
fi

Step 7: Verify Deployment

# Get service URL
SERVICE_URL=$(gcloud run services describe $SERVICE_NAME --region $REGION --format='value(status.url)')

# Health check
HTTP_STATUS=$(curl -s -o /dev/null -w "%{http_code}" $SERVICE_URL)

if [ "$HTTP_STATUS" = "200" ]; then
echo "✅ Site is live at $SERVICE_URL"
else
echo "❌ Health check failed. HTTP status: $HTTP_STATUS"
fi

# Check custom domain (may take time for DNS/SSL)
DOMAIN_STATUS=$(curl -s -o /dev/null -w "%{http_code}" https://$DOMAIN 2>/dev/null || echo "pending")
echo "Custom domain status: $DOMAIN_STATUS (may take 5-15 min for SSL provisioning)"

Output

After successful deployment:

✅ Deployment successful!

🌐 Service URL: https://docs-coditect-xxxxx-uc.a.run.app
🔗 Custom Domain: https://docs.coditect.ai (SSL provisioning...)

📊 Deployment Details:
- Service: docs-coditect
- Region: us-central1
- Memory: 256Mi
- CPU: 1
- Instances: 0-10

🔒 SSL Status: Provisioning (5-15 minutes)

📋 DNS Configuration Required:
Add CNAME record:
docs.coditect.ai -> docs-coditect-xxxxx-uc.a.run.app

🚀 Next steps:
1. Verify DNS propagation: dig docs.coditect.ai
2. Test site: curl -I https://docs.coditect.ai
3. Update EXTERNAL-LINKS-INVENTORY.md status

Rollback

If deployment fails or site has issues:

# List revisions
gcloud run revisions list --service $SERVICE_NAME --region $REGION

# Rollback to previous revision
gcloud run services update-traffic $SERVICE_NAME \
--region $REGION \
--to-revisions PREVIOUS_REVISION=100

Integration

This command uses:

  • Agent: website-builder, devops-engineer
  • Skill: website-builder-patterns, google-cloud-build
  • Script: scripts/deploy-website.sh
  • /build-site - Build site before deployment
  • /verify-site - Verify site health after deployment

Required Tools

ToolPurposeRequired
BashExecute gcloud, docker, curl commandsYes
WriteCreate Dockerfile and nginx.conf if missingOptional
ReadVerify source directory and index.htmlYes

External Requirements:

  • gcloud CLI authenticated
  • Docker installed (for local builds)
  • GCP project with Cloud Run enabled
  • Domain verified in GCP

Output Validation

Before marking complete, verify output contains:

  • Pre-flight check results (all passed)
  • Container build output (success)
  • Cloud Run deployment URL
  • Custom domain status
  • SSL provisioning status
  • DNS configuration instructions (if needed)
  • Rollback command provided

Success Output

When deployment completes:

✅ COMMAND COMPLETE: /deploy-site
Domain: <domain.coditect.ai>
Service URL: https://<service>-xxxxx-uc.a.run.app
Region: <region>
Memory: <memory>
Instances: <min>-<max>
SSL Status: <provisioning|active>

Completion Checklist

Before marking complete:

  • Pre-flight checks passed
  • Container built
  • Deployed to Cloud Run
  • Domain mapped
  • Health check passed

Failure Indicators

This command has FAILED if:

  • ❌ GCP authentication failed
  • ❌ Source directory not found
  • ❌ Build failed
  • ❌ Health check failed

When NOT to Use

Do NOT use when:

  • Site not built (use /build-site first)
  • GCP access not configured
  • Domain not verified

Anti-Patterns (Avoid)

Anti-PatternProblemSolution
Skip pre-flightFailed deploymentRun checks first
No health checkBroken site liveVerify after deploy
Ignore SSL statusInsecure accessWait for provisioning

Principles

This command embodies:

  • #4 Confirm Destructive - Requires confirmation for production
  • #3 Complete Execution - Full deployment workflow
  • #9 Based on Facts - Verify deployment success

Full Standard: CODITECT-STANDARD-AUTOMATION.md