── ADVANCED ──
Custom Templates
Override built-in templates or create entirely new ones with Go template syntax.
## Template Resolution Order
Exo resolves templates in a three-tier hierarchy. Local overrides always take priority:
text
1. LOCAL: ~/.exo/templates/<category>/<name>.tmpl2. EMBEDDED: templates/<category>/<name>.tmpl (built-in)3. REMOTE: (future) Remote template registries## Creating a Custom Template
Templates use Go's text/template syntax with access to .AppName, .Language, .Framework, and .Port variables.
~/.exo/templates/docker/dockerfile.tmpl
1# Custom Dockerfile Template2FROM {{if eq .Language "go"}}golang:1.25-alpine{{else if eq .Language "node"}}node:22-alpine{{else}}python:3.12-slim{{end}}34LABEL maintainer="your-team@company.com"5LABEL app="{{.AppName}}"67WORKDIR /app89{{if eq .Language "go"}}10COPY go.mod go.sum ./11RUN go mod download12COPY . .13RUN CGO_ENABLED=0 go build -ldflags="-s -w" -o /bin/app .14FROM scratch15COPY --from=0 /bin/app /bin/app16ENTRYPOINT ["/bin/app"]17{{else if eq .Language "node"}}18COPY package*.json ./19RUN npm ci --only=production20COPY . .21EXPOSE {{.Port}}22CMD ["node", "index.js"]23{{end}}## Available Template Variables
| Variable | Type | Description |
|---|---|---|
.AppName | string | Project name from .exo.yaml |
.Language | string | Detected language (go, node, python) |
.Framework | string | Detected framework (gin, express, django…) |
.Port | int | Application port (default 8080) |
## Go Template Syntax Cheatsheet
go
# Conditionals{{if eq .Language "go"}}...{{end}}{{if and (eq .Language "node") (eq .Framework "express")}}...{{end}}# Range{{range .Services}} - {{.Name}}: {{.Port}}{{end}}# Variables{{$port := .Port}}EXPOSE {{$port}}# Default values{{or .Framework "none"}}# Pipelines{{.AppName | printf "%s-service"}}## Template Management Commands
bash
# List all available templatesexo template list# Pull a remote templateexo template pull <name># Validate template syntaxexo template validate ~/.exo/templates/docker/dockerfile.tmpl## Template Categories
| Category | Directory | Templates |
|---|---|---|
| Docker | docker/ | dockerfile, node, python |
| CI/CD | ci/ | github-actions, gitlab-ci |
| Kubernetes | k8s/ | deployment, service, ingress |
| Helm | helm/ | Chart.yaml, values.yaml, templates/* |
| Terraform | terraform/ | main.tf, provider.tf, variables.tf (per cloud) |
| Databases | db/ | postgres, mysql, mongo, redis |
| Monitoring | monitoring/ | prometheus, docker-compose.monitoring |
| Other | env/, gitignore/, makefile/, grafana/, alerts/ | Various config templates |