refactor(templates): DRY the two remaining byte-identical startup blocks - #195
Merged
Conversation
|
Registry-mirror configuration and the ~/.bashrc symlink-safety guard
were duplicated verbatim across all three templates' startup scripts
(the docker-daemon logic was already extracted in a prior commit).
Unlike other similar-looking sections of these scripts, these two were
confirmed byte-for-byte identical across all three, so extracting them
changes nothing behaviorally.
- Registry-mirror config folds into the existing modules/docker-daemon
module (it configures /etc/docker/daemon.json right before the
daemon starts, so it belongs with the rest of the Docker lifecycle
logic); the module gains a docker_registry_mirror input variable
that each template now passes through from its own variable of the
same name.
- The bashrc-symlink guard needs no variables and creates no resource,
so it's vendored as a plain shared/bashrc-symlink-guard.sh (same
vendoring technique as shared/vscode-extensions.tf) and pulled into
each startup_script via file("${path.module}/bashrc-symlink-guard.sh").
Verified on staging-coder.ddev.com (d12-1): registry mirror still
auto-detected and configured, Docker daemon still starts cleanly.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
rfay
force-pushed
the
20260806_dry_startup_common
branch
from
August 8, 2026 00:31
033a07c to
8ed27fb
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
startup_scriptwere duplicated byte-for-byte identically across all three templates (confirmed via diff, unlike other similar-looking sections that have already drifted in small ways) — the Docker registry-mirror configuration and the~/.bashrcsymlink-safety guard.modules/docker-daemon(it configures/etc/docker/daemon.jsonright before the daemon starts, so it belongs with the rest of the Docker lifecycle logic already there); the module gained adocker_registry_mirrorinput variable that each template passes through from its own variable of the same name.shared/bashrc-symlink-guard.sh(same vendoring technique asshared/vscode-extensions.tf) and pulled into eachstartup_scriptviafile("${path.module}/bashrc-symlink-guard.sh").template.tffiles themselves is ~140 lines).Depends on #194 (this branch is stacked on
20260806_docker_survivalsince it extends thedocker-daemonmodule that PR introduces) — will need a rebase once that merges, but the two PRs don't touch overlapping lines so there's no actual conflict.Test plan
terraform fmt -recursivecleanmake validate— all three templates validmake test-templates— all Terraform mock tests passd12-1: registry mirror still auto-detected/configured (Detected registry mirror on Coder host: ...), Docker daemon started cleanly, all DDEV containers came up healthy