init project structer

This commit is contained in:
2025-10-08 14:12:48 +07:00
commit 9c177abda0
22 changed files with 6737 additions and 0 deletions

66
scripts/build-go.sh Normal file
View File

@@ -0,0 +1,66 @@
#!/bin/bash
echo "🔨 Building CatSave 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/catsave-linux main.go
echo " ✅ Built: dist/catsave-linux"
# Build for current OS
go build -ldflags="-s -w" -o ../../dist/catsave main.go
echo " ✅ Built: dist/catsave"
cd ../..
# Get file sizes
SIZE_LINUX=$(du -h dist/catsave-linux 2>/dev/null | cut -f1)
SIZE_LOCAL=$(du -h dist/catsave 2>/dev/null | cut -f1)
echo ""
echo -e "${GREEN}✅ Build complete!${NC}"
echo ""
echo "📦 Output:"
echo " - dist/catsave (${SIZE_LOCAL:-N/A})"
echo " - dist/catsave-linux (${SIZE_LINUX:-N/A})"
echo ""
echo -e "${YELLOW}To run:${NC}"
echo " ./dist/catsave"
echo ""
echo -e "${YELLOW}To deploy to Linux server:${NC}"
echo " scp dist/catsave-linux user@server:/opt/catsave"
echo " ssh user@server '/opt/catsave'"
echo ""

27
scripts/sync-static.sh Normal file
View File

@@ -0,0 +1,27 @@
#!/bin/bash
echo "🔄 Syncing Next.js static files to Go..."
# Check if Next.js build exists
if [ ! -d "apps/web/out" ]; then
echo "❌ Next.js build not found. Run 'npm run build:web' first."
exit 1
fi
# Remove old static files (except .gitkeep if exists)
echo " - Cleaning old files..."
rm -rf apps/server-go/static/*
# Copy new files
echo " - Copying files..."
cp -r apps/web/out/* apps/server-go/static/
# Count files
FILE_COUNT=$(find apps/server-go/static -type f | wc -l)
echo "✅ Synced ${FILE_COUNT} files to apps/server-go/static/"
echo ""
echo "Next steps:"
echo " cd apps/server-go && go run main.go"
echo " Open http://localhost:8080"