Skip to content

Terraform ​

DockPod ships a Terraform provider — manage Git Deployment apps, custom domains, and provisioned databases declaratively, against the exact same REST API the web UI itself calls.

TIP

dockpod_deploy_app, dockpod_domain, dockpod_database, dockpod_database_link, and a dockpod_git_providers data source are all available. Full resource reference is on the Registry listing and in the provider's own repo.

1. Generate an API Key ​

Go to Settings → API Keys → Generate key, give it a name (e.g. "Terraform"), and copy the key immediately — it's shown only once, in the form dp_mcp_xxxxxxxxxxxxxxxxxxxx.

This is the same key type MCP clients use — it now also works as a plain Bearer token against DockPod's REST API directly, which is what the provider authenticates with.

2. Configure the Provider ​

hcl
terraform {
  required_providers {
    dockpod = {
      source = "hymns/dockpod"
    }
  }
}

provider "dockpod" {
  host    = "https://your-server:8080" # or set DOCKPOD_HOST
  api_key = var.dockpod_api_key        # or set DOCKPOD_API_KEY
}

host/api_key can come from the provider block or the DOCKPOD_HOST/DOCKPOD_API_KEY environment variables — useful in CI, where committing either value into a .tf file isn't desirable.

3. Declare an App ​

hcl
resource "dockpod_deploy_app" "api" {
  name        = "my-api"
  repo_url    = "https://github.com/you/my-api.git"
  branch      = "main"
  deploy_type = "dockerfile"

  env_vars = {
    NODE_ENV = "production"
  }
}

terraform apply manages the app's configuration only — repo, branch, build type, env vars. It never triggers a build itself. The first deploy (and every one after) happens exactly how it already does outside Terraform: a push to the branch fires the webhook DockPod registers automatically, or you trigger one manually from the web UI, MCP, or DockPod's own API. An apply that only touches config shouldn't have a build — and the container swap that comes with it — as a surprise side effect.

If a Git provider is already connected under Settings → Git Providers, reference it by ID instead of a raw repo_url — this authenticates over the provider's own credentials (no SSH deploy key to manage), and for a GitHub App provider, push-to-deploy works immediately with no extra webhook setup:

hcl
resource "dockpod_deploy_app" "api" {
  name            = "my-api"
  git_provider_id = "<id from Settings -> Git Providers>"
  repo_full_name  = "you/my-api"
  branch          = "main"
  deploy_type     = "dockerfile"
}

4. Add a Domain and a Database ​

hcl
resource "dockpod_domain" "api" {
  deploy_app_id  = dockpod_deploy_app.api.id
  domain         = "api.example.com"
  container_port = 3000
}

resource "dockpod_database" "cache" {
  name = "my-api-cache"
  type = "redis"
}

resource "dockpod_database_link" "cache" {
  deploy_app_id = dockpod_deploy_app.api.id
  database_id   = dockpod_database.cache.id
  env_prefix    = "CACHE"
}

dockpod_domain now has an update endpoint on DockPod's side (PATCH /api/deploy/apps/{id}/domains/{domainId}), so changing a domain's port, service, skip_tls or redirect_www can be an in-place update rather than a replace. dockpod_database and dockpod_database_link still have no update endpoint, so every attribute on those two forces a replace.

An apply does not deploy

Saving a domain, a database link or an app's env vars records the change on the app and leaves the running containers alone until a deploy applies it — see Saving vs. Applying. So a successful terraform apply means the configuration is stored, not that it is live.

Read pending_changes on the app to see what is waiting. To apply it, push to the branch, press Redeploy to apply in the panel, or call POST /api/deploy/apps/{id}/deploy. The provider deliberately does not trigger a build, for the same reason given above.

Full resource reference — including the dockpod_git_providers data source, every attribute, and import support — is on the Registry listing and in the provider's own repo.

The REST API the provider is built on is specified in API Reference, which is the place to look when an attribute here doesn't line up with what DockPod accepts.

Released under a commercial-friendly freemium license.