Files
NekoFlow/scripts/build-go.sh
2025-10-08 14:23:46 +07:00

67 lines
1.5 KiB
Bash

#!/bin/bash
echo "🔨 Building NekoFlow Single Binary..."
# Colors
GREEN='\033[0;32m'
BLUE='\033[0;34m'
YELLOW='\033[1;33m'
NC='\033[0m'
# Step 1: Build Next.js static export
echo -e "${BLUE}Step 1: Building Next.js...${NC}"
cd apps/web
npm run build
if [ ! -d "out" ]; then
echo -e "${YELLOW}❌ Next.js build failed${NC}"
exit 1
fi
cd ../..
# Step 2: Copy static files to Go project
echo -e "${BLUE}Step 2: Copying static files to Go...${NC}"
rm -rf apps/server-go/static
mkdir -p apps/server-go/static
cp -r apps/web/out/* apps/server-go/static/
echo " ✅ Copied $(ls -1 apps/server-go/static | wc -l) items"
# Step 3: Build Go binary
echo -e "${BLUE}Step 3: Building Go binary...${NC}"
cd apps/server-go
# Get dependencies
go mod download
# Build for Linux
GOOS=linux GOARCH=amd64 go build -ldflags="-s -w" -o ../../dist/nekoflow-linux main.go
echo " ✅ Built: dist/nekoflow-linux"
# Build for current OS
go build -ldflags="-s -w" -o ../../dist/nekoflow main.go
echo " ✅ Built: dist/nekoflow"
cd ../..
# Get file sizes
SIZE_LINUX=$(du -h dist/nekoflow-linux 2>/dev/null | cut -f1)
SIZE_LOCAL=$(du -h dist/nekoflow 2>/dev/null | cut -f1)
echo ""
echo -e "${GREEN}✅ Build complete!${NC}"
echo ""
echo "📦 Output:"
echo " - dist/nekoflow (${SIZE_LOCAL:-N/A})"
echo " - dist/nekoflow-linux (${SIZE_LINUX:-N/A})"
echo ""
echo -e "${YELLOW}To run:${NC}"
echo " ./dist/nekoflow"
echo ""
echo -e "${YELLOW}To deploy to Linux server:${NC}"
echo " scp dist/nekoflow-linux user@server:/opt/nekoflow"
echo " ssh user@server '/opt/nekoflow'"
echo ""