Quick Deploy
Overview
Section titled “Overview”SPEAR provides multiple deployment options to suit different environments - from simple single-server deployments to production setups with SSL termination via Traefik. This guide covers the essential deployment workflows.
Prerequisites
Section titled “Prerequisites”Before deploying SPEAR, ensure your system meets these requirements:
| Requirement | Version | Notes |
|---|---|---|
| Node.js | 18+ | For building the frontend |
| pnpm | 8+ | Package manager |
| Go | 1.23.3+ | For building the backend |
SPEAR_ENCRYPTION_KEY | - | 16, 24, or 32 characters |
The encryption key is required and used for AES encryption of sensitive data such as API keys.
Quick Deploy Method
Section titled “Quick Deploy Method”The simplest way to deploy SPEAR is using the wrapper script:
sudo ./scripts/deploy.sh --version "1.0.0"This script handles the entire deployment process including building, service creation, and startup.
Advanced Deploy Method
Section titled “Advanced Deploy Method”For more control over the deployment, use the full build-and-deploy script:
sudo ./scripts/build-and-deploy.sh [OPTIONS]Available Options
Section titled “Available Options”| Option | Description | Default |
|---|---|---|
-v, --version VERSION | Set the software version | Timestamp |
-k, --key ENCRYPTION_KEY | Set the encryption key | From env or default |
-p, --port PORT | Set the service port | 8090 |
-u, --user USER | Set the service user | spear |
-d, --install-dir DIR | Set installation directory | /opt/spear |
--data-dir DIR | Set data directory | /var/lib/spear |
--skip-frontend | Skip frontend build | - |
--skip-backend | Skip backend build | - |
--skip-service | Skip service creation/update | - |
--dry-run | Preview actions without executing | - |
Examples
Section titled “Examples”# Deploy with specific version and portsudo ./scripts/build-and-deploy.sh -v "1.0.0" -p 8090
# Skip frontend rebuild, update version onlysudo ./scripts/build-and-deploy.sh --skip-frontend --version "1.0.1"
# Preview deployment actionssudo ./scripts/build-and-deploy.sh --dry-runProduction Build
Section titled “Production Build”For cross-platform binary distribution, use the release build script:
./scripts/build-release.sh v1.0.0This generates binaries for all supported platforms:
| Platform | Architectures |
|---|---|
| Linux | amd64, arm64, arm |
| Windows | amd64, arm64 |
| macOS | amd64, arm64 |
Service Management
Section titled “Service Management”After deployment, SPEAR runs as a systemd service. Use these commands to manage it:
# Check service statussudo systemctl status spear
# View real-time logssudo journalctl -u spear -f
# Restart the servicesudo systemctl restart spear
# Stop the servicesudo systemctl stop spear
# Start the servicesudo systemctl start spear
# Enable auto-start on bootsudo systemctl enable spearInstallation Paths
Section titled “Installation Paths”The deployment script installs SPEAR to these default locations:
| Component | Path |
|---|---|
| Install Directory | /opt/spear |
| Data Directory | /var/lib/spear |
| Log Directory | /var/log/spear |
| Binary | /opt/spear/spear |
| Service File | /etc/systemd/system/spear.service |
First-Time Setup
Section titled “First-Time Setup”After deployment:
- Navigate to the PocketBase admin UI at
http://localhost:8090/_/ - Create your admin account
- Configure initial settings (branding, RBAC, etc.)
Access Points
Section titled “Access Points”| Service | URL |
|---|---|
| SPEAR Application | http://localhost:8090 |
| PocketBase Admin | http://localhost:8090/_/ |
| Health Check | http://localhost:8090/api/health |
Troubleshooting
Section titled “Troubleshooting”Port Conflicts
Section titled “Port Conflicts”If port 8090 is already in use:
# Check what's using the portsudo netstat -tlnp | grep :8090
# Or use sssudo ss -tlnp | grep :8090Change the port using the -p flag during deployment.
Permission Errors
Section titled “Permission Errors”If you encounter permission errors:
# Ensure proper ownership of data directoriessudo chown -R spear:spear /var/lib/spear /var/log/spearEncryption Key Validation
Section titled “Encryption Key Validation”The encryption key must be exactly 16, 24, or 32 characters:
# Check key lengthecho -n "$SPEAR_ENCRYPTION_KEY" | wc -cIf validation fails, generate a new key:
# Generate a 32-character keyexport SPEAR_ENCRYPTION_KEY=$(openssl rand -base64 24)Service Startup Failures
Section titled “Service Startup Failures”If the service fails to start:
# Check recent logssudo journalctl -u spear --since "5 minutes ago" --no-pager
# Verify binary permissionsls -la /opt/spear/spear
# Check systemd service filecat /etc/systemd/system/spear.serviceEnvironment Variables
Section titled “Environment Variables”The systemd service file includes these environment variables:
Environment=SPEAR_ENCRYPTION_KEY=<your-key>Environment=SPEAR_VERSION=<version>Environment=SPEAR_PORT=<port>For additional environment configuration, see Environment Variables.
Next Steps
Section titled “Next Steps”- Configure Traefik SSL for HTTPS support
- Review Environment Variables for customization
- Set up automated backups via the Admin panel