Skip to content

Commit ef28b86

Browse files
chapterjasonclaude
andcommitted
Pin workspace image by digest so every push triggers a re-pull
pull_triggers was a side-channel hint; the provider could still decide the image was "already there" and skip pulling. Encoding the digest directly in docker_image.name (as name@sha256:<digest>) makes the resource's identity a function of the remote content — any digest change forces a resource replacement, which pulls the image and propagates through to docker_container.workspace. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 4a3121c commit ef28b86

1 file changed

Lines changed: 9 additions & 7 deletions

File tree

main.tf

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -395,18 +395,20 @@ resource "docker_volume" "projects_volume" {
395395
}
396396
}
397397

398-
# Re-pull the workspace image on every plan when the registry digest has
399-
# advanced. The data source reads the remote digest; docker_image.pull_triggers
400-
# fires when it changes, yielding a new local image_id; the container depends
401-
# on that image_id so a new push → container recreate on next apply.
398+
# Pin the workspace image to its current remote digest. Every plan re-reads
399+
# the registry data source; when the remote `:tag` points at a new digest,
400+
# docker_image.name changes (different `name@sha256:...`), forcing the
401+
# resource to be replaced — which downloads the new image and advances
402+
# image_id, which in turn replaces docker_container.workspace. Beats
403+
# pull_triggers: the identity of the resource itself is the digest, so there
404+
# is no way for the provider to "already have it" and skip.
402405
data "docker_registry_image" "workspace" {
403406
name = local.workspace_images[data.coder_parameter.workspace_image.value]
404407
}
405408

406409
resource "docker_image" "workspace" {
407-
name = data.docker_registry_image.workspace.name
408-
pull_triggers = [data.docker_registry_image.workspace.sha256_digest]
409-
keep_locally = true
410+
name = "${data.docker_registry_image.workspace.name}@${data.docker_registry_image.workspace.sha256_digest}"
411+
keep_locally = true
410412
}
411413

412414
resource "docker_container" "workspace" {

0 commit comments

Comments
 (0)