Fuego apps compile to a single binary, making deployment straightforward across any platform.
Building for Production
# Using Fuego CLI
fuego build
# Or directly with Go
go build -o myapp .
# With optimizations
go build -ldflags="-s -w" -o myapp .
The -ldflags="-s -w" strips debug information, reducing binary size by ~30%.
Docker
Simple Dockerfile
FROM golang:1.23-alpine AS builder
WORKDIR /app
COPY go.mod go.sum ./
RUN go mod download
COPY . .
RUN go build -ldflags="-s -w" -o server .
FROM alpine:latest
RUN apk --no-cache add ca-certificates
WORKDIR /app
COPY --from=builder /app/server .
COPY --from=builder /app/static ./static
EXPOSE 3000
CMD ["./server"]
Multi-stage with Tailwind
If using Tailwind CSS:
FROM golang:1.23-alpine AS builder
WORKDIR /app
# Install Fuego CLI for Tailwind
RUN go install github.com/abdul-hamid-achik/fuego/cmd/fuego@latest
COPY go.mod go.sum ./
RUN go mod download
COPY . .
# Build Tailwind CSS
RUN fuego tailwind build
# Build Go binary
RUN go build -ldflags="-s -w" -o server .
FROM alpine:latest
RUN apk --no-cache add ca-certificates
WORKDIR /app
COPY --from=builder /app/server .
COPY --from=builder /app/static ./static
EXPOSE 3000
CMD ["./server"]
Docker Compose
version: '3.8'
services:
app:
build: .
ports:
- "3000:3000"
environment:
- FUEGO_PORT=3000
- FUEGO_HOST=0.0.0.0
restart: unless-stopped
Fly.io
Railway
Render
Heroku
Fly.io is excellent for Go apps with global distribution.# Install flyctl
curl -L https://fly.io/install.sh | sh
# Launch (creates fly.toml)
fly launch
# Deploy
fly deploy
fly.toml:app = "myapp"
primary_region = "dfw"
[build]
builder = "paketobuildpacks/builder:base"
[http_service]
internal_port = 3000
force_https = true
[[services]]
internal_port = 3000
protocol = "tcp"
[[services.ports]]
port = 80
handlers = ["http"]
[[services.ports]]
port = 443
handlers = ["tls", "http"]
Railway auto-detects Go projects.
- Push your code to GitHub
- Connect Railway to your repo
- Railway automatically builds and deploys
Environment variables:FUEGO_PORT=3000
FUEGO_HOST=0.0.0.0
- Create a new Web Service on Render
- Connect your GitHub repository
- Configure:
- Build Command:
go build -ldflags="-s -w" -o server .
- Start Command:
./server
- Environment: Go
Procfile:heroku create myapp
heroku buildpacks:set heroku/go
git push heroku main
AWS
Lambda
ECS/Fargate
Elastic Beanstalk
Use a Lambda adapter:package main
import (
"github.com/aws/aws-lambda-go/lambda"
"github.com/awslabs/aws-lambda-go-api-proxy/httpadapter"
"github.com/abdul-hamid-achik/fuego/pkg/fuego"
)
var app *fuego.App
func init() {
app = fuego.New()
// Configure routes
}
func main() {
lambda.Start(httpadapter.New(app).ProxyWithContext)
}
Use the Docker image with ECS task definition:{
"containerDefinitions": [
{
"name": "myapp",
"image": "your-ecr-repo/myapp:latest",
"portMappings": [
{
"containerPort": 3000,
"protocol": "tcp"
}
],
"environment": [
{"name": "FUEGO_PORT", "value": "3000"}
]
}
]
}
-
Create
Procfile:
-
Create
Buildfile:
build: go build -o application .
-
Deploy:
eb init
eb create myapp-env
eb deploy
Cloud Run is ideal for containerized Go apps:# Build and push
gcloud builds submit --tag gcr.io/PROJECT_ID/myapp
# Deploy
gcloud run deploy myapp \
--image gcr.io/PROJECT_ID/myapp \
--platform managed \
--region us-central1 \
--allow-unauthenticated
Or deploy from source:gcloud run deploy --source .
app.yaml:runtime: go122
env: standard
handlers:
- url: /static
static_dir: static
- url: /.*
script: auto
Deploy: deployment.yaml:apiVersion: apps/v1
kind: Deployment
metadata:
name: myapp
spec:
replicas: 3
selector:
matchLabels:
app: myapp
template:
metadata:
labels:
app: myapp
spec:
containers:
- name: myapp
image: gcr.io/PROJECT_ID/myapp:latest
ports:
- containerPort: 3000
env:
- name: FUEGO_PORT
value: "3000"
---
apiVersion: v1
kind: Service
metadata:
name: myapp
spec:
type: LoadBalancer
ports:
- port: 80
targetPort: 3000
selector:
app: myapp
Configuration
Environment Variables
Fuego reads configuration from environment variables:
| Variable | Description | Default |
|---|
FUEGO_PORT | Server port | 3000 |
FUEGO_HOST | Server host | localhost |
FUEGO_ENV | Environment (dev/prod) | dev |
FUEGO_LOG_LEVEL | Log level | info |
fuego.yaml
port: 3000
host: "0.0.0.0"
app_dir: "app"
static_dir: "static"
static_path: "/static"
# Production settings
prod:
hot_reload: false
Health Checks
Add a health endpoint for load balancers:
// app/api/health/route.go
package health
import "github.com/abdul-hamid-achik/fuego/pkg/fuego"
func Get(c *fuego.Context) error {
return c.JSON(200, map[string]string{
"status": "healthy",
})
}
Configure your load balancer to check /api/health.
Static Files
Ensure static files are included in deployment:
app.Static("/static", "static")
For Docker, copy the static directory:
COPY --from=builder /app/static ./static
Graceful Shutdown
Fuego handles SIGINT and SIGTERM for graceful shutdown automatically. In Kubernetes, configure a termination grace period:
spec:
terminationGracePeriodSeconds: 30
Production Checklist
- Enable HTTPS
- Set secure headers (
app.Use(fuego.SecureHeaders()))
- Use environment variables for secrets
- Enable CORS properly
- Add health check endpoint
- Configure logging level for production
- Set up metrics collection
- Configure alerting
- Use graceful shutdown
- Configure request timeouts
- Add rate limiting
- Set up load balancing
Next Steps