Pre-launch — Gluecron is in final validation. Public signups and git hosting for non-owner users open after launch review.
CodeIssuesDiscussionsWikiPull RequestsProjectsCommitsActionsReleasesContributorsPulse● GatesSecuritySettingsDeploymentsPipelineInsightsAgents✨ Explain✨ Ask AI✨ Workspace✨ Spec✨ Tests▓ Debt Map✨ NL Search🏛 Archaeology
Blame · Line-by-line history

deploy.sh

Each line is annotated with the commit that last touched it. Click any SHA to jump to that commit and see the surrounding change.

deploy.shBlame129 lines · 2 contributors
8ade77bClaude1#!/bin/bash
2set -euo pipefail
3
4# ============================================
5# Gluecron Deploy Script
6# One command to deploy to production.
7# ============================================
8
9APP_NAME="gluecron"
10APP_DIR="/opt/gluecron"
11REPO_URL="https://github.com/ccantynz-alt/Gluecron.com.git"
9ffa60eClaude12BRANCH="${BRANCH:-main}"
13
14# NOTE: For the production Crontech bare-metal box (45.76.171.37 → gluecron.com),
15# prefer scripts/deploy-crontech.sh — it knows about Caddy, /etc/gluecron.env, and
16# the systemd unit. This deploy.sh is the generic single-server bootstrapper.
8ade77bClaude17
18echo "=========================================="
19echo " Deploying $APP_NAME"
20echo "=========================================="
21
22# 1. Check prerequisites
23command -v git >/dev/null 2>&1 || { echo "git required"; exit 1; }
24command -v bun >/dev/null 2>&1 || {
25 echo "Installing Bun..."
ea52715copilot-swe-agent[bot]26 curl -fsSL --output /tmp/bun-install.sh https://bun.sh/install
27 bash /tmp/bun-install.sh
28 rm -f /tmp/bun-install.sh
8ade77bClaude29 export PATH="$HOME/.bun/bin:$PATH"
30}
31
32# 2. Check for DATABASE_URL
33if [ -z "${DATABASE_URL:-}" ]; then
34 if [ -f "$APP_DIR/.env" ]; then
35 export $(grep -v '^#' "$APP_DIR/.env" | xargs)
36 fi
37fi
38
39if [ -z "${DATABASE_URL:-}" ]; then
40 echo "ERROR: DATABASE_URL not set."
41 echo "Set it in $APP_DIR/.env or export it."
42 echo ""
43 echo "Get a free database at https://neon.tech"
44 echo "Then: echo 'DATABASE_URL=postgresql://...' > $APP_DIR/.env"
45 exit 1
46fi
47
48# 3. Clone or update repo
49if [ -d "$APP_DIR" ]; then
50 echo "Updating existing installation..."
51 cd "$APP_DIR"
52 git fetch origin "$BRANCH"
53 git reset --hard "origin/$BRANCH"
54else
55 echo "Fresh install..."
56 sudo mkdir -p "$APP_DIR"
57 sudo chown "$(whoami)" "$APP_DIR"
58 git clone --branch "$BRANCH" "$REPO_URL" "$APP_DIR"
59 cd "$APP_DIR"
60fi
61
62# 4. Install dependencies
63echo "Installing dependencies..."
64bun install --frozen-lockfile --production
65
66# 5. Run database migration
67echo "Running database migration..."
68psql "$DATABASE_URL" -f drizzle/0000_init.sql 2>/dev/null || {
69 echo "psql not found or migration failed — trying via bun..."
70 bun run -e "
71 const { neon } = require('@neondatabase/serverless');
72 const sql = neon(process.env.DATABASE_URL);
73 const fs = require('fs');
74 const migration = fs.readFileSync('drizzle/0000_init.sql', 'utf-8');
75 // Split by semicolons and execute each statement
76 const statements = migration.split(';').filter(s => s.trim());
77 (async () => {
78 for (const stmt of statements) {
79 try { await sql(stmt); } catch(e) { /* table may already exist */ }
80 }
81 console.log('Migration complete');
82 })();
83 "
84}
85
86# 6. Create repos directory
87mkdir -p /data/repos 2>/dev/null || mkdir -p "$APP_DIR/repos"
88export GIT_REPOS_PATH="${GIT_REPOS_PATH:-/data/repos}"
89
90# 7. Set up systemd service
91echo "Setting up systemd service..."
92sudo tee /etc/systemd/system/gluecron.service > /dev/null << UNIT
93[Unit]
94Description=Gluecron - AI-native code intelligence
95After=network.target
96
97[Service]
98Type=simple
99User=$(whoami)
100WorkingDirectory=$APP_DIR
101EnvironmentFile=$APP_DIR/.env
102ExecStart=$(which bun) run src/index.ts
103Restart=always
104RestartSec=5
105StandardOutput=journal
106StandardError=journal
107
108[Install]
109WantedBy=multi-user.target
110UNIT
111
112sudo systemctl daemon-reload
113sudo systemctl enable gluecron
114sudo systemctl restart gluecron
115
116echo ""
117echo "=========================================="
118echo " $APP_NAME is now running!"
119echo "=========================================="
120echo ""
121echo " URL: http://$(hostname -I | awk '{print $1}'):3000"
122echo " Logs: journalctl -u gluecron -f"
123echo " Status: systemctl status gluecron"
124echo ""
125echo " Next steps:"
126echo " 1. Set up reverse proxy (nginx/caddy) for HTTPS"
127echo " 2. Point gluecron.com DNS to this server"
128echo " 3. Register your admin account at /register"
129echo ""