- Updated all static asset URLs to use iceymi.b-cdn.net CDN - Changed favicon, CSS, and JS file references in index.html, admin.html, and privacy.html - API calls remain pointed to origin server for dynamic content - Ready for CDN deployment with proper cache separation
133 lines
4.4 KiB
Bash
133 lines
4.4 KiB
Bash
#!/bin/bash
|
|
|
|
# Great Lakes Ice Report Deployment Script for Debian 12 ARM64
|
|
# Run this script on your server: drone@91.99.139.235
|
|
|
|
set -e
|
|
|
|
echo "🚀 Starting Great Lakes Ice Report deployment..."
|
|
|
|
# Update system
|
|
echo "📦 Updating system packages..."
|
|
sudo apt update && sudo apt upgrade -y
|
|
|
|
# Install Node.js (ARM64 compatible)
|
|
echo "📦 Installing Node.js..."
|
|
curl -fsSL https://deb.nodesource.com/setup_20.x | sudo -E bash -
|
|
sudo apt install -y nodejs build-essential
|
|
|
|
# Install Go (required for xcaddy)
|
|
echo "📦 Installing Go..."
|
|
wget -q https://go.dev/dl/go1.21.5.linux-arm64.tar.gz
|
|
sudo rm -rf /usr/local/go
|
|
sudo tar -C /usr/local -xzf go1.21.5.linux-arm64.tar.gz
|
|
export PATH=$PATH:/usr/local/go/bin
|
|
echo 'export PATH=$PATH:/usr/local/go/bin' >> ~/.bashrc
|
|
|
|
# Install xcaddy to build Caddy with plugins
|
|
echo "📦 Installing xcaddy..."
|
|
go install github.com/caddyserver/xcaddy/cmd/xcaddy@latest
|
|
export PATH=$PATH:$(go env GOPATH)/bin
|
|
|
|
# Build Caddy with rate limiting plugin
|
|
echo "🔧 Building Caddy with rate limiting plugin..."
|
|
xcaddy build --with github.com/mholt/caddy-ratelimit
|
|
|
|
# Install the custom Caddy binary
|
|
echo "📦 Installing custom Caddy..."
|
|
sudo mv caddy /usr/local/bin/caddy
|
|
sudo chmod +x /usr/local/bin/caddy
|
|
|
|
# Create Caddy user and directories
|
|
sudo groupadd --system caddy
|
|
sudo useradd --system --gid caddy --create-home --home-dir /var/lib/caddy --shell /usr/sbin/nologin caddy
|
|
sudo mkdir -p /etc/caddy /var/log/caddy
|
|
sudo chown -R caddy:caddy /var/log/caddy
|
|
|
|
# Create systemd service for custom Caddy
|
|
echo "⚙️ Creating Caddy systemd service..."
|
|
sudo tee /etc/systemd/system/caddy.service > /dev/null <<EOF
|
|
[Unit]
|
|
Description=Caddy
|
|
Documentation=https://caddyserver.com/docs/
|
|
After=network.target network-online.target
|
|
Requires=network-online.target
|
|
|
|
[Service]
|
|
Type=notify
|
|
User=caddy
|
|
Group=caddy
|
|
ExecStart=/usr/local/bin/caddy run --environ --config /etc/caddy/Caddyfile
|
|
ExecReload=/usr/local/bin/caddy reload --config /etc/caddy/Caddyfile --force
|
|
TimeoutStopSec=5s
|
|
LimitNOFILE=1048576
|
|
LimitNPROC=1048576
|
|
PrivateTmp=true
|
|
ProtectSystem=full
|
|
AmbientCapabilities=CAP_NET_BIND_SERVICE
|
|
|
|
[Install]
|
|
WantedBy=multi-user.target
|
|
EOF
|
|
|
|
# Clean up Go archive
|
|
rm -f go1.21.5.linux-arm64.tar.gz
|
|
|
|
echo "✅ Caddy with rate limiting plugin installed successfully!"
|
|
|
|
# Create app directory
|
|
echo "📁 Setting up app directory..."
|
|
sudo mkdir -p /opt/great-lakes-ice-report
|
|
sudo chown $USER:$USER /opt/great-lakes-ice-report
|
|
|
|
# Navigate to app directory
|
|
cd /opt/great-lakes-ice-report
|
|
|
|
# Create great-lakes-ice-report user for security
|
|
echo "👤 Creating great-lakes-ice-report user..."
|
|
sudo useradd --system --shell /bin/false --home /opt/great-lakes-ice-report --create-home great-lakes-ice-report
|
|
|
|
# Download additional configuration files from S3
|
|
echo "📥 Downloading configuration files..."
|
|
S3_BASE_URL="https://greatlakes-conditions.s3.amazonaws.com/scripts"
|
|
|
|
# Download systemd service file
|
|
echo "📥 Downloading systemd service..."
|
|
curl -sSL "$S3_BASE_URL/great-lakes-ice-report.service" | sudo tee /etc/systemd/system/great-lakes-ice-report.service > /dev/null
|
|
|
|
# Download Caddyfile template
|
|
echo "📥 Downloading Caddy configuration..."
|
|
curl -sSL "$S3_BASE_URL/Caddyfile" | sudo tee /etc/caddy/Caddyfile.template > /dev/null
|
|
|
|
echo "✅ Server setup complete!"
|
|
echo ""
|
|
echo "🚀 Next steps to deploy Great Lakes Ice Report:"
|
|
echo ""
|
|
echo "1. Clone your repository:"
|
|
echo " git clone git@github.com:deco/great-lakes-ice-report.git /opt/great-lakes-ice-report"
|
|
echo ""
|
|
echo "2. Set up the application:"
|
|
echo " cd /opt/great-lakes-ice-report"
|
|
echo " npm install"
|
|
echo " cp .env.example .env"
|
|
echo " nano .env # Add your MapBox token and admin password"
|
|
echo ""
|
|
echo "3. Configure domain in Caddyfile:"
|
|
echo " sudo nano /etc/caddy/Caddyfile.template"
|
|
echo " # Replace 'yourdomain.com' with your actual domain"
|
|
echo " sudo mv /etc/caddy/Caddyfile.template /etc/caddy/Caddyfile"
|
|
echo ""
|
|
echo "4. Set permissions:"
|
|
echo " sudo chown -R great-lakes-ice-report:great-lakes-ice-report /opt/great-lakes-ice-report"
|
|
echo " sudo chmod 660 /opt/great-lakes-ice-report/.env"
|
|
echo ""
|
|
echo "5. Start services:"
|
|
echo " sudo systemctl daemon-reload"
|
|
echo " sudo systemctl enable great-lakes-ice-report caddy"
|
|
echo " sudo systemctl start great-lakes-ice-report caddy"
|
|
echo ""
|
|
echo "6. Check status:"
|
|
echo " sudo systemctl status great-lakes-ice-report"
|
|
echo " sudo systemctl status caddy"
|
|
echo ""
|
|
echo "🌐 Your Great Lakes Ice Report app will be available at: https://ice.puremichigan.lol"
|