Keep a submodule's own .git/config out of the build context (closes #88)
check / check (push) Waiting to run
check / check (push) Waiting to run
A submodule that keeps its own `.git` directory, instead of one under `.git/modules/`, still shipped `sub/.git/config` into the build context, credential included. Both git patterns in the canonical `.dockerignore` now start with `**/`: `**/.git/config` and `**/.git/modules/**/config`. A submodule whose name has a `config` segment (`config`, `deploy/config`, `config/lib`) still loses its whole git directory, because the pattern also matches that directory, and Go's version stamping then fails the build loudly. The file records this as a known gap with the way around it, `git submodule add --name`; closing it needs a wildcard re-include that makes every build walk excluded directories. `prompts/REPO_POLICIES.md` and both checklists say the same. Model: opus-5-5
This commit was merged in pull request #96.
This commit is contained in:
+10
-3
@@ -18,9 +18,16 @@
|
|||||||
# does not need .git/config; that file can hold a credential, such as a
|
# does not need .git/config; that file can hold a credential, such as a
|
||||||
# password in a remote URL or the token the CI checkout step stores there.
|
# password in a remote URL or the token the CI checkout step stores there.
|
||||||
# Each submodule keeps a config with the same exposure in its git directory
|
# Each submodule keeps a config with the same exposure in its git directory
|
||||||
# under .git/modules/, nested again for a submodule's own submodules.
|
# under .git/modules/, nested again for a submodule's own submodules, or in
|
||||||
.git/config
|
# its own .git directory when it keeps one.
|
||||||
.git/modules/**/config
|
# KNOWN GAP: a submodule whose name has a `config` segment (`config`,
|
||||||
|
# `deploy/config`, `config/lib`) loses its whole git directory, because
|
||||||
|
# `**/.git/modules/**/config` also matches that segment's directory
|
||||||
|
# under .git/modules/. Go's version stamping then fails the build;
|
||||||
|
# nothing leaks. Name such a submodule without that segment:
|
||||||
|
# `git submodule add --name`.
|
||||||
|
**/.git/config
|
||||||
|
**/.git/modules/**/config
|
||||||
|
|
||||||
# Agent scratch: one full checkout of the repo per in-flight agent.
|
# Agent scratch: one full checkout of the repo per in-flight agent.
|
||||||
# Anchored because it occurs once where agents run at the repo root.
|
# Anchored because it occurs once where agents run at the repo root.
|
||||||
|
|||||||
@@ -21,6 +21,15 @@ fmt-check, and commit.
|
|||||||
|
|
||||||
# Completed Steps
|
# Completed Steps
|
||||||
|
|
||||||
|
- 2026-10-04: The canonical `.dockerignore` now also keeps out the git `config`
|
||||||
|
of a submodule that keeps its own `.git` directory, which still reached the
|
||||||
|
image (issue 88): both git patterns now carry the `**/` prefix. A submodule
|
||||||
|
whose name has a `config` segment (`config`, `deploy/config`, `config/lib`)
|
||||||
|
still loses its whole git directory, so Go's version stamping fails the build;
|
||||||
|
the file records this as a `KNOWN GAP:` with the remedy,
|
||||||
|
`git submodule add --name`. Closing it would take a wildcard re-include, which
|
||||||
|
makes BuildKit walk every excluded directory, such as `node_modules`, on every
|
||||||
|
build. `REPO_POLICIES.md` and both checklists say so in the same words.
|
||||||
- 2026-10-04: The note under the canonical Go `Dockerfile` example in
|
- 2026-10-04: The note under the canonical Go `Dockerfile` example in
|
||||||
`REPO_POLICIES.md` now installs lint-phase system libraries with `apt-get`
|
`REPO_POLICIES.md` now installs lint-phase system libraries with `apt-get`
|
||||||
under their Debian package names (issue 83). The `golangci/golangci-lint`
|
under their Debian package names (issue 83). The `golangci/golangci-lint`
|
||||||
|
|||||||
@@ -63,10 +63,15 @@ with your task.
|
|||||||
here run anywhere other than the repo root, the anchored entry misses
|
here run anywhere other than the repo root, the anchored entry misses
|
||||||
`services/api/.claude/`: add anchored entries for those directories.
|
`services/api/.claude/`: add anchored entries for those directories.
|
||||||
- [ ] If the repo embeds a version in a binary: `.dockerignore` lets `.git` into
|
- [ ] If the repo embeds a version in a binary: `.dockerignore` lets `.git` into
|
||||||
the build context. It keeps out `.git/config` and each submodule's
|
the build context. It keeps out every git `config` at any depth
|
||||||
`config` under `.git/modules/` at any depth (`.git/modules/**/config`),
|
(`**/.git/config`, `**/.git/modules/**/config`): the repository's own,
|
||||||
which `git describe` does not need and which can hold a credential: a
|
each submodule's under `.git/modules/`, and that of a submodule keeping
|
||||||
password in a remote URL, or the token the CI checkout step stores there.
|
its own `.git` directory. `git describe` does not need them, and each can
|
||||||
|
hold a credential: a password in a remote URL, or the token the CI
|
||||||
|
checkout step stores there. A submodule whose name has a `config` segment
|
||||||
|
(`config`, `deploy/config`, `config/lib`) loses its whole git directory to
|
||||||
|
`**/.git/modules/**/config`, and Go's version stamping then fails the
|
||||||
|
build: give it a name without that segment (`git submodule add --name`).
|
||||||
The stage that compiles has `git` (the Debian Go image has it; an alpine
|
The stage that compiles has `git` (the Debian Go image has it; an alpine
|
||||||
one needs `apk add --no-cache git`) and takes the version from the
|
one needs `apk add --no-cache git`) and takes the version from the
|
||||||
`VERSION` build argument when one is given, otherwise from
|
`VERSION` build argument when one is given, otherwise from
|
||||||
|
|||||||
@@ -71,10 +71,15 @@ Template files can be fetched from:
|
|||||||
will run them in subdirectories, `services/api/.claude/` needs its own
|
will run them in subdirectories, `services/api/.claude/` needs its own
|
||||||
anchored entry.
|
anchored entry.
|
||||||
- If the image embeds a version in a binary: `.dockerignore` lets `.git`
|
- If the image embeds a version in a binary: `.dockerignore` lets `.git`
|
||||||
into the build context. It keeps out `.git/config` and each submodule's
|
into the build context. It keeps out every git `config` at any depth
|
||||||
`config` under `.git/modules/` at any depth (`.git/modules/**/config`),
|
(`**/.git/config`, `**/.git/modules/**/config`): the repository's own,
|
||||||
which `git describe` does not need and which can hold a credential: a
|
each submodule's under `.git/modules/`, and that of a submodule keeping
|
||||||
password in a remote URL, or the token the CI checkout step stores there.
|
its own `.git` directory. `git describe` does not need them, and each can
|
||||||
|
hold a credential: a password in a remote URL, or the token the CI
|
||||||
|
checkout step stores there. A submodule whose name has a `config` segment
|
||||||
|
(`config`, `deploy/config`, `config/lib`) loses its whole git directory to
|
||||||
|
`**/.git/modules/**/config`, and Go's version stamping then fails the
|
||||||
|
build: give it a name without that segment (`git submodule add --name`).
|
||||||
The stage that compiles has `git` (the Debian Go image has it; an alpine
|
The stage that compiles has `git` (the Debian Go image has it; an alpine
|
||||||
one needs `apk add --no-cache git`) and takes the version from the
|
one needs `apk add --no-cache git`) and takes the version from the
|
||||||
`VERSION` build argument when one is given, otherwise from
|
`VERSION` build argument when one is given, otherwise from
|
||||||
|
|||||||
@@ -248,11 +248,16 @@ style conventions are in separate documents:
|
|||||||
&& rm -rf /var/lib/apt/lists/*
|
&& rm -rf /var/lib/apt/lists/*
|
||||||
```
|
```
|
||||||
|
|
||||||
- `.dockerignore` lets `.git` into the build context. It keeps out
|
- `.dockerignore` lets `.git` into the build context. It keeps out every git
|
||||||
`.git/config` and each submodule's `config` under `.git/modules/` at any
|
`config` at any depth (`**/.git/config`, `**/.git/modules/**/config`): the
|
||||||
depth (`.git/modules/**/config`), which `git describe` does not need and
|
repository's own, each submodule's under `.git/modules/`, and that of a
|
||||||
which can hold a credential: a password in a remote URL, or the token the
|
submodule keeping its own `.git` directory. `git describe` does not need
|
||||||
CI checkout step stores there. The stage that compiles has `git` (the
|
them, and each can hold a credential: a password in a remote URL, or the
|
||||||
|
token the CI checkout step stores there. A submodule whose name has a
|
||||||
|
`config` segment (`config`, `deploy/config`, `config/lib`) loses its whole
|
||||||
|
git directory to `**/.git/modules/**/config`, and Go's version stamping
|
||||||
|
then fails the build: give it a name without that segment
|
||||||
|
(`git submodule add --name`). The stage that compiles has `git` (the
|
||||||
Debian Go image has it; an alpine one needs `apk add --no-cache git`) and
|
Debian Go image has it; an alpine one needs `apk add --no-cache git`) and
|
||||||
takes the version from the `VERSION` build argument when one is given,
|
takes the version from the `VERSION` build argument when one is given,
|
||||||
otherwise from `git describe --tags --always`. That gives the tag on a
|
otherwise from `git describe --tags --always`. That gives the tag on a
|
||||||
|
|||||||
Reference in New Issue
Block a user