Deployment
January 20, 2026 ยท View on GitHub
Deploy your Zigly service to Fastly Compute.
Prerequisites
- A Fastly account
- The Fastly CLI installed
- An API token with appropriate permissions
Installing Fastly CLI
# macOS
brew install fastly/tap/fastly
# Other platforms: download from GitHub releases
# https://github.com/fastly/cli/releases
Configure authentication:
fastly profile create
# Enter your API token when prompted
Project Configuration
Create or update fastly.toml:
manifest_version = 3
name = "my-edge-service"
description = "My Zigly service"
authors = ["you@example.com"]
language = "other"
service_id = "" # Filled after first deploy
[scripts]
build = "zig build -Doptimize=ReleaseSmall && mkdir -p bin && cp zig-out/bin/service.wasm bin/main.wasm"
The build script:
- Compiles with size optimizations
- Copies the binary to where Fastly CLI expects it
Backends
Configure backends in your Fastly service. You can do this via the Fastly web UI or CLI.
Via CLI
# Create a backend
fastly backend create --version latest --name origin --address api.example.com --port 443 --use-ssl
Via fastly.toml
For new services, define backends:
[setup.backends]
[setup.backends.origin]
address = "api.example.com"
port = 443
Building
Build the WebAssembly binary:
# Using the fastly.toml script
fastly compute build
# Or manually
zig build -Doptimize=ReleaseSmall
mkdir -p bin
cp zig-out/bin/service.wasm bin/main.wasm
Build Optimizations
For production, use ReleaseSmall:
zig build -Doptimize=ReleaseSmall
This produces the smallest binary. Use ReleaseFast if you need maximum performance and can tolerate a larger binary.
Deploying
First Deployment
Create a new Fastly service and deploy:
fastly compute publish
This will:
- Create a new Compute service (if
service_idis empty) - Upload your WebAssembly binary
- Activate the new version
The CLI updates fastly.toml with your service_id.
Subsequent Deployments
fastly compute publish
Deploy Without Activating
Deploy but don't activate (useful for staging):
fastly compute publish --skip-activation
Activate later:
fastly service-version activate --version <version_number>
Domain Configuration
Custom Domains
Add your domain via the Fastly UI or CLI:
fastly domain create --name www.example.com --version latest
Point your DNS to Fastly:
- CNAME:
www.example.comโ<service-id>.global.ssl.fastly.net
Default Domain
Every service gets a default domain:
https://<random>.edgecompute.app
This is useful for testing before configuring custom domains.
Environment-Specific Configuration
Edge Dictionaries
Store configuration that varies between environments:
# Create a dictionary
fastly dictionary create --name config --version latest
# Add items
fastly dictionary-item create --dictionary-id <id> --key api_url --value "https://api.example.com"
Access in code:
const zigly = @import("zigly");
fn start() !void {
const allocator = std.heap.page_allocator;
var config = try zigly.Dictionary.open("config");
const api_url = try config.get(allocator, "api_url");
// Use api_url...
}
KV Stores
For larger or more dynamic data:
# Create a KV store
fastly kv-store create --name my-store
# Link to your service
fastly resource-link create --version latest --resource-id <store-id>
Logging
Configure log endpoints in the Fastly UI or CLI:
# Example: S3 logging
fastly logging s3 create \
--name access-logs \
--bucket my-bucket \
--access-key <key> \
--secret-key <secret> \
--version latest
Use in code:
var logger = try zigly.Logger.open("access-logs");
try logger.write("Request processed");
Monitoring
Real-time Stats
fastly stats --service-id <id>
Logs
fastly log-tail --service-id <id>
vCPU Usage
Monitor compute costs in code:
const runtime = zigly.runtime;
fn start() !void {
// ... handle request ...
const vcpu_ms = try runtime.getVcpuMs();
std.debug.print("vCPU time: {}ms\n", .{vcpu_ms});
}
CI/CD
GitHub Actions Example
name: Deploy
on:
push:
branches: [main]
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup Zig
uses: goto-bus-stop/setup-zig@v2
with:
version: 0.16.0
- name: Build
run: zig build -Doptimize=ReleaseSmall
- name: Setup Fastly CLI
uses: fastly/compute-actions/setup@v6
- name: Deploy
run: fastly compute publish --token ${{ secrets.FASTLY_API_TOKEN }}
Rollback
Revert to a previous version:
# List versions
fastly service-version list
# Activate a previous version
fastly service-version activate --version <version_number>
Troubleshooting
Build Failures
Check that your binary is at bin/main.wasm:
ls -la bin/main.wasm
Runtime Errors
Check logs:
fastly log-tail
Backend Timeouts
Verify backend configuration:
fastly backend list --version latest
Next Steps
- Architecture - Understand the runtime
- Guides - Learn common patterns