项目文件夹

文件
Asim Aslam 239dbfc27e fix: make build/deploy Go-native, Docker optional (#2835)
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>
2026-01-27 12:47:07 +00:00

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:

  1. Copies ./bin/* to the remote host (if exists)
  2. Or syncs source and builds on remote
  3. 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

  1. Cross-compile locally - Faster than building on remote
  2. Use --os linux - Most servers are Linux
  3. Single binary - Go's strength, no runtime needed
  4. Logs in ~/micro/logs/ - Easy to tail and rotate
  5. No Docker needed - Unless you want it