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