Chapter 21: Deployment
Wyn compiles to native binaries - deploy anywhere with zero dependencies.
Building for Production
bash
wyn build src/main.wyn --release
# Produces: src/main (optimized binary, ~170KB)The --release flag enables:
-O3optimization- Slim runtime header (30% faster)
- System C compiler (clang/gcc)
Cross-Compilation
bash
wyn cross linux src/main.wyn # Linux x64
wyn cross macos src/main.wyn # macOS
wyn cross windows src/main.wyn # Windows (.exe)
wyn cross ios src/main.wyn # iOS (arm64)
wyn cross android src/main.wyn # Android (arm64)Deploy with wyn.toml
toml
[deploy.prod]
host = "myapp.example.com"
user = "deploy"
key = "~/.ssh/id_ed25519"
path = "/opt/myapp"
os = "linux"
pre = "systemctl stop myapp"
post = "systemctl start myapp"bash
wyn deploy prod
# Cross-compiles for target OS, uploads, runs pre/post commandsDocker
dockerfile
FROM ubuntu:22.04
COPY myapp /usr/local/bin/myapp
EXPOSE 3000
CMD ["myapp"]Wyn binaries are statically linked - no runtime dependencies needed in the container.
Binary Size
| Language | Hello World Binary |
|---|---|
| Wyn | ~170 KB |
| Go | ~2.3 MB |
| Rust | ~3.5 MB |
Systemd Service
ini
[Unit]
Description=My Wyn App
After=network.target
[Service]
ExecStart=/opt/myapp/myapp
Restart=always
User=deploy
[Install]
WantedBy=multi-user.targetHealth Checks
wyn
fn handle(method: string, path: string, body: string, fd: int) {
if path == "/health" {
Http.respond(fd, 200, "ok")
return
}
// ... app routes
}