micro--go-micro
239dbfc27e
micro build: - Default: builds Go binaries to ./bin/ - Cross-compile with --os and --arch - Docker is optional via --docker flag micro deploy: - Requires --ssh user@host - Copies pre-built binaries (if ./bin/ exists) - Or syncs source and builds on remote - No Docker dependency Go binaries are self-contained. No runtime needed. Co-authored-by: Shelley <shelley@exe.dev>
2.4 KiB
2.4 KiB
layout
| layout |
|---|
| default |
Deployment
Go produces self-contained binaries. No Docker required.
Quick Start
# Build binaries
micro build --os linux
# Deploy to server
micro deploy --ssh user@host
Building
Basic Build
micro build
This builds Go binaries for all services in micro.mu (or the current directory) to ./bin/.
Cross-Compilation
micro build --os linux # For Linux servers
micro build --os linux --arch arm64 # For ARM64 (e.g., AWS Graviton)
micro build --os darwin # For macOS
micro build --os windows # For Windows (.exe)
Custom Output
micro build --output ./dist
Deploying
SSH Deploy
micro deploy --ssh user@host
This:
- Copies
./bin/*to the remote host (if exists) - Or syncs source and builds on remote
- Restarts services
Workflow
Option 1: Build locally, copy binaries
micro build --os linux # Build for target OS
micro deploy --ssh user@host # Copy and restart
Option 2: Build on remote
micro deploy --ssh user@host # Syncs source, builds there
Remote Structure
~/micro/
├── bin/ # Service binaries
│ ├── users
│ ├── posts
│ └── web
├── logs/ # Service logs
│ ├── users.log
│ ├── posts.log
│ └── web.log
└── src/ # Source (if building on remote)
View Logs
ssh user@host 'tail -f ~/micro/logs/*.log'
Docker (Optional)
If you prefer containers:
micro build --docker # Build images
micro build --docker --push # Build and push to registry
micro build --compose # Generate docker-compose.yml
Then deploy with docker-compose on your server:
scp docker-compose.yml user@host:~/
ssh user@host 'docker compose up -d'
Complete Example
# Development
micro new myapp
cd myapp
micro run # Develop locally
# Build
micro build --os linux
# Deploy
micro deploy --ssh deploy@prod.example.com
# Check
ssh deploy@prod.example.com 'tail -f ~/micro/logs/*.log'
Tips
- Cross-compile locally - Faster than building on remote
- Use
--os linux- Most servers are Linux - Single binary - Go's strength, no runtime needed
- Logs in ~/micro/logs/ - Easy to tail and rotate
- No Docker needed - Unless you want it