Skip to content

Quick Deploy

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.

Before deploying SPEAR, ensure your system meets these requirements:

RequirementVersionNotes
Node.js18+For building the frontend
pnpm8+Package manager
Go1.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.

The simplest way to deploy SPEAR is using the wrapper script:

Terminal window
sudo ./scripts/deploy.sh --version "1.0.0"

This script handles the entire deployment process including building, service creation, and startup.

For more control over the deployment, use the full build-and-deploy script:

Terminal window
sudo ./scripts/build-and-deploy.sh [OPTIONS]
OptionDescriptionDefault
-v, --version VERSIONSet the software versionTimestamp
-k, --key ENCRYPTION_KEYSet the encryption keyFrom env or default
-p, --port PORTSet the service port8090
-u, --user USERSet the service userspear
-d, --install-dir DIRSet installation directory/opt/spear
--data-dir DIRSet data directory/var/lib/spear
--skip-frontendSkip frontend build-
--skip-backendSkip backend build-
--skip-serviceSkip service creation/update-
--dry-runPreview actions without executing-
Terminal window
# Deploy with specific version and port
sudo ./scripts/build-and-deploy.sh -v "1.0.0" -p 8090
# Skip frontend rebuild, update version only
sudo ./scripts/build-and-deploy.sh --skip-frontend --version "1.0.1"
# Preview deployment actions
sudo ./scripts/build-and-deploy.sh --dry-run

For cross-platform binary distribution, use the release build script:

Terminal window
./scripts/build-release.sh v1.0.0

This generates binaries for all supported platforms:

PlatformArchitectures
Linuxamd64, arm64, arm
Windowsamd64, arm64
macOSamd64, arm64

After deployment, SPEAR runs as a systemd service. Use these commands to manage it:

Terminal window
# Check service status
sudo systemctl status spear
# View real-time logs
sudo journalctl -u spear -f
# Restart the service
sudo systemctl restart spear
# Stop the service
sudo systemctl stop spear
# Start the service
sudo systemctl start spear
# Enable auto-start on boot
sudo systemctl enable spear

The deployment script installs SPEAR to these default locations:

ComponentPath
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

After deployment:

  1. Navigate to the PocketBase admin UI at http://localhost:8090/_/
  2. Create your admin account
  3. Configure initial settings (branding, RBAC, etc.)
ServiceURL
SPEAR Applicationhttp://localhost:8090
PocketBase Adminhttp://localhost:8090/_/
Health Checkhttp://localhost:8090/api/health

If port 8090 is already in use:

Terminal window
# Check what's using the port
sudo netstat -tlnp | grep :8090
# Or use ss
sudo ss -tlnp | grep :8090

Change the port using the -p flag during deployment.

If you encounter permission errors:

Terminal window
# Ensure proper ownership of data directories
sudo chown -R spear:spear /var/lib/spear /var/log/spear

The encryption key must be exactly 16, 24, or 32 characters:

Terminal window
# Check key length
echo -n "$SPEAR_ENCRYPTION_KEY" | wc -c

If validation fails, generate a new key:

Terminal window
# Generate a 32-character key
export SPEAR_ENCRYPTION_KEY=$(openssl rand -base64 24)

If the service fails to start:

Terminal window
# Check recent logs
sudo journalctl -u spear --since "5 minutes ago" --no-pager
# Verify binary permissions
ls -la /opt/spear/spear
# Check systemd service file
cat /etc/systemd/system/spear.service

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.