── 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>.tmpl
2. 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 Template
2FROM {{if eq .Language "go"}}golang:1.25-alpine{{else if eq .Language "node"}}node:22-alpine{{else}}python:3.12-slim{{end}}
3
4LABEL maintainer="your-team@company.com"
5LABEL app="{{.AppName}}"
6
7WORKDIR /app
8
9{{if eq .Language "go"}}
10COPY go.mod go.sum ./
11RUN go mod download
12COPY . .
13RUN CGO_ENABLED=0 go build -ldflags="-s -w" -o /bin/app .
14FROM scratch
15COPY --from=0 /bin/app /bin/app
16ENTRYPOINT ["/bin/app"]
17{{else if eq .Language "node"}}
18COPY package*.json ./
19RUN npm ci --only=production
20COPY . .
21EXPOSE {{.Port}}
22CMD ["node", "index.js"]
23{{end}}

## Available Template Variables

VariableTypeDescription
.AppNamestringProject name from .exo.yaml
.LanguagestringDetected language (go, node, python)
.FrameworkstringDetected framework (gin, express, django…)
.PortintApplication 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 templates
exo template list
# Pull a remote template
exo template pull <name>
# Validate template syntax
exo template validate ~/.exo/templates/docker/dockerfile.tmpl

## Template Categories

CategoryDirectoryTemplates
Dockerdocker/dockerfile, node, python
CI/CDci/github-actions, gitlab-ci
Kubernetesk8s/deployment, service, ingress
Helmhelm/Chart.yaml, values.yaml, templates/*
Terraformterraform/main.tf, provider.tf, variables.tf (per cloud)
Databasesdb/postgres, mysql, mongo, redis
Monitoringmonitoring/prometheus, docker-compose.monitoring
Otherenv/, gitignore/, makefile/, grafana/, alerts/Various config templates