Deployment improvements: - Add template env files (.envs.example/) for documentation - Create init-production.sh for one-time server setup - Create build-activepieces.sh for building/deploying AP image - Update deploy.sh with --deploy-ap flag - Make custom-pieces-metadata.sql idempotent - Update DEPLOYMENT.md with comprehensive instructions Frontend: - Redirect logged-in business owners from root domain to tenant dashboard - Redirect logged-in users from /login to /dashboard on their tenant - Log out customers on wrong subdomain instead of redirecting 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
116 lines
3.7 KiB
Bash
Executable File
116 lines
3.7 KiB
Bash
Executable File
#!/bin/bash
|
|
# ==============================================================================
|
|
# Build and Deploy Activepieces Docker Image
|
|
#
|
|
# This script builds the Activepieces image locally and optionally
|
|
# transfers it to the production server.
|
|
#
|
|
# Usage:
|
|
# ./scripts/build-activepieces.sh # Build only
|
|
# ./scripts/build-activepieces.sh deploy # Build and deploy to server
|
|
# ./scripts/build-activepieces.sh deploy user@server # Custom server
|
|
# ==============================================================================
|
|
|
|
set -e
|
|
|
|
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
PROJECT_ROOT="$(dirname "$SCRIPT_DIR")"
|
|
AP_DIR="$PROJECT_ROOT/activepieces-fork"
|
|
|
|
# Colors
|
|
GREEN='\033[0;32m'
|
|
YELLOW='\033[1;33m'
|
|
RED='\033[0;31m'
|
|
NC='\033[0m'
|
|
|
|
print_status() { echo -e "${GREEN}>>> $1${NC}"; }
|
|
print_warning() { echo -e "${YELLOW}>>> $1${NC}"; }
|
|
print_error() { echo -e "${RED}>>> $1${NC}"; }
|
|
|
|
# Parse arguments
|
|
ACTION="${1:-build}"
|
|
SERVER="${2:-poduck@smoothschedule.com}"
|
|
|
|
IMAGE_NAME="smoothschedule_production_activepieces"
|
|
TEMP_FILE="/tmp/activepieces-image.tar.gz"
|
|
|
|
echo ""
|
|
echo "==========================================="
|
|
echo " Activepieces Docker Image Builder"
|
|
echo "==========================================="
|
|
echo ""
|
|
|
|
# Check we have the activepieces-fork directory
|
|
if [ ! -d "$AP_DIR" ]; then
|
|
print_error "activepieces-fork directory not found at: $AP_DIR"
|
|
exit 1
|
|
fi
|
|
|
|
# ==============================================================================
|
|
# Build the image
|
|
# ==============================================================================
|
|
print_status "Building Activepieces Docker image..."
|
|
print_warning "This may take 5-10 minutes and requires 4GB+ RAM"
|
|
|
|
cd "$AP_DIR"
|
|
|
|
# Build with progress output
|
|
docker build \
|
|
--progress=plain \
|
|
-t "$IMAGE_NAME" \
|
|
.
|
|
|
|
print_status "Build complete!"
|
|
|
|
# Show image size
|
|
docker images "$IMAGE_NAME" --format "Image size: {{.Size}}"
|
|
|
|
# ==============================================================================
|
|
# Deploy to server (if requested)
|
|
# ==============================================================================
|
|
if [ "$ACTION" = "deploy" ]; then
|
|
echo ""
|
|
print_status "Preparing to deploy to: $SERVER"
|
|
|
|
# Save image to compressed archive
|
|
print_status "Saving image to $TEMP_FILE..."
|
|
docker save "$IMAGE_NAME" | gzip > "$TEMP_FILE"
|
|
|
|
# Show file size
|
|
ls -lh "$TEMP_FILE" | awk '{print "Archive size: " $5}'
|
|
|
|
# Transfer to server
|
|
print_status "Transferring to server (this may take a few minutes)..."
|
|
scp "$TEMP_FILE" "$SERVER:/tmp/activepieces-image.tar.gz"
|
|
|
|
# Load on server
|
|
print_status "Loading image on server..."
|
|
ssh "$SERVER" "gunzip -c /tmp/activepieces-image.tar.gz | docker load && rm /tmp/activepieces-image.tar.gz"
|
|
|
|
# Restart Activepieces on server
|
|
print_status "Restarting Activepieces on server..."
|
|
ssh "$SERVER" "cd ~/smoothschedule/smoothschedule && docker compose -f docker-compose.production.yml up -d activepieces"
|
|
|
|
# Clean up local temp file
|
|
rm -f "$TEMP_FILE"
|
|
|
|
print_status "Deployment complete!"
|
|
echo ""
|
|
echo "Activepieces should now be running with the new image."
|
|
echo "Check status with:"
|
|
echo " ssh $SERVER 'cd ~/smoothschedule/smoothschedule && docker compose -f docker-compose.production.yml ps activepieces'"
|
|
echo ""
|
|
else
|
|
echo ""
|
|
print_status "Image built successfully: $IMAGE_NAME"
|
|
echo ""
|
|
echo "To deploy to production, run:"
|
|
echo " $0 deploy"
|
|
echo ""
|
|
echo "Or manually:"
|
|
echo " docker save $IMAGE_NAME | gzip > /tmp/ap.tar.gz"
|
|
echo " scp /tmp/ap.tar.gz $SERVER:/tmp/"
|
|
echo " ssh $SERVER 'gunzip -c /tmp/ap.tar.gz | docker load'"
|
|
echo ""
|
|
fi
|