A template repository for deploying a Dagger Engine on Civo Cloud, providing distributed build caching and efficient CI/CD pipelines using Civo's managed Kubernetes and Object Storage services.
- 🚀 Managed Kubernetes cluster on Civo Cloud
- 📦 Object Storage configuration for Dagger's build cache
- 🔒 Secure network and firewall setup
- ⚙️ Automated Helm deployment of the Dagger Engine
- 💾 Persistent cache storage across builds
-
Use this template
- Click the "Use this template" button above or click here
- Clone your new repository
-
Configure Civo credentials
The provider will use the credentials of the Civo CLI (stored in ~/.civo.json
) if no other credentials have been set up. The provider will use credentials in the following order:
- Environment variable (
CIVO_TOKEN
). - Token provided via a credentials file (See
credentials_file
input below). - CLI configuration (
~/.civo.json
).
That means that if the CIVO_TOKEN
variable is set, all other credentials will be ignored, and if the credentials_file
is set, that will be used over the CLI credentials.
To set the CIVO_TOKEN
environment variable:
export CIVO_TOKEN="your-api-token"
- Deploy the infrastructure
cd terraform
terraform init
terraform apply
- Configure kubectl
export KUBECONFIG=$(pwd)/kubeconfig
kubectl get nodes
- Connect to Dagger Engine
# Get the Dagger Engine pod name
DAGGER_ENGINE_POD_NAME="$(kubectl get pod \
--selector=name=dagger-dagger-helm-engine \
--namespace=dagger \
--output=jsonpath='{.items[0].metadata.name}')"
# Configure Dagger runner
export _EXPERIMENTAL_DAGGER_RUNNER_HOST="kube-pod://$DAGGER_ENGINE_POD_NAME?namespace=dagger"
- Verify the setup
dagger query <<EOF
{
container {
from(address:"alpine") {
withExec(args: ["uname", "-a"]) { stdout }
}
}
}
EOF
Modify terraform.tfvars
or set variables during apply:
civo_region = "LON1" # Civo region
cluster_node_count = 3 # Number of K8s nodes
cluster_node_size = "g4s.kube.medium" # Node size
object_store_size = 500 # Cache storage in GB
Infrastructure Components Here's an overview of the infrastructure deployed in Civo:
graph TB
subgraph Civo["Civo Cloud"]
subgraph Network["Dagger Network"]
subgraph K8s["Kubernetes Cluster"]
subgraph DaggerNS["Dagger Namespace"]
Engine["Dagger Engine Pod"]
Secret["Cache Config Secret"]
end
Nodes["Worker Nodes (x3)"]
end
FW["Firewall"]
end
subgraph Storage["Object Storage"]
Bucket["Dagger Cache Bucket"]
Creds["Object Store Credentials"]
end
end
%% Connections
Engine -->|"Read/Write Cache"| Bucket
Engine -->|"Uses"| Secret
Secret -.->|"References"| Creds
FW -->|"Controls Access to"| K8s
%% Styling
classDef civoBox fill:#326CE5,stroke:#fff,stroke-width:2px,color:#fff
classDef k8sBox fill:#326CE5,stroke:#fff,stroke-width:2px,color:#fff
classDef storageBox fill:#FFA500,stroke:#fff,stroke-width:2px,color:#fff
class Civo,Network civoBox
class K8s,DaggerNS k8sBox
class Storage,Bucket storageBox
The infrastructure consists of:
- Kubernetes Cluster: Runs the Dagger Engine
- Object Storage: Persistent cache for build artifacts
- Firewall: Secure access control
- Helm Release: Dagger Engine deployment
- Kubernetes Secret: Cache configuration
View your cache usage:
- Civo Console: Object Storage → Buckets
- Dagger CLI:
dagger core engine local-cache entry-set
Remove all resources:
terraform destroy
The Terraform state is stored locally by default. For production environments, it is recommended to store the state remotely using a backend such as a remote object storage. Modify the Terraform configuration to suit your production needs.
This template is available under the MIT License.