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