vps_pilot

Quick Start: Embedded UI Build

πŸš€ Build Single Executable

# From project root
./build.sh

Output: server/vps_pilot (single executable with UI)

πŸ“¦ Run

cd server
./vps_pilot

Access: http://localhost:8000

πŸ“‹ What Gets Embedded?

πŸ”§ Build Process

  1. Frontend Build (client/)
    npm run build
    # Creates: client/dist/
    
  2. Copy to Server
    cp -r client/dist server/cmd/app/
    
  3. Embed & Build
    go build -o vps_pilot .
    # Embeds: cmd/app/dist/ into binary
    

🎯 Result

Single vps_pilot binary that serves:

πŸ“ URLs

What URL
UI http://localhost:8000
API http://localhost:8000/api/v1
Login http://localhost:8000/api/v1/auth/login

βš™οΈ Environment

Create server/.env:

DB_PATH=./data
TOKEN_LIFESPAN=60
TOKEN_SECRET=your-secret-key
TCP_SERVER_PORT=55001

πŸ§ͺ Test

# Build
./build.sh

# Run
cd server && ./vps_pilot

# Test API
curl http://localhost:8000/api/v1/auth/login

# Test UI (in browser)
open http://localhost:8000

πŸ“Š Binary Size

πŸ”„ Development vs Production

Development (Hot Reload)

# Backend
cd server && go run main.go

# Frontend (separate terminal)
cd client && npm run dev

Production (Embedded)

./build.sh
cd server && ./vps_pilot

πŸ› οΈ Makefile Commands

cd server

make migrate          # Run migrations
make build            # Build server only
make build-full       # Build with UI (runs ../build.sh)
make run              # Run server
make create-superuser # Create admin user
make clean            # Remove build artifacts

βœ… Success Checklist

πŸ› Troubleshooting

Build fails:

# Check frontend builds
cd client && npm run build

# Check Go compiles
cd server && go build .

UI doesn’t load:

# Verify dist was copied
ls server/cmd/app/dist/

# Rebuild
./build.sh

Binary size too large:

# Strip and compress
cd server
go build -ldflags "-s -w" -o vps_pilot .
upx --best vps_pilot

Done! πŸŽ‰