Skip to content

fix(docker): add .dockerignore to tighten build context - #109

Open
DavidHLP wants to merge 1 commit into
mainfrom
fix/docker-build-context
Open

fix(docker): add .dockerignore to tighten build context#109
DavidHLP wants to merge 1 commit into
mainfrom
fix/docker-build-context

Conversation

@DavidHLP

@DavidHLP DavidHLP commented Jul 5, 2026

Copy link
Copy Markdown
Owner

Project root had no .dockerignore. With docker-compose.ci.yml using build.context: "." for all three app images, the entire repo (.git, wiki/, docs/, host node_modules/, target/, local .env) was sent to the daemon per build — slow + risk of local secrets entering image layers.

Excludes VCS/IDE/docs/build-artifacts/secrets/tooling/standalone-image-contexts. Build-critical paths (console/management/shared/backend-spring + their package.json/pnpm-lock.yaml/mvnw/src/public) verified preserved. Saves ~173M of context transfer.

Closes #103

Project root had no .dockerignore (confirmed). docker-compose.ci.yml uses
build.context: "." for console/management/backend, so the entire repo —
.git, wiki/, docs/, host node_modules/, target/, local .env — was being
sent to the daemon as build context for every image: slow builds plus the
risk of local secrets landing in an image layer.

Build context stays "." (monorepo: console/management Dockerfiles need
COPY shared/, shared/ lives at repo root). This file excludes:
- VCS / IDE / agent configs (.git, .claude, .cursor, .codex, .agents, ...)
- docs & wiki (rebuilt from sources, not needed in any image)
- build artifacts (**/node_modules, **/dist, **/target, **/coverage, ...)
- local secrets (.env*, except .env.example)
- tooling/infra (infrastructure, tools, scripts) and standalone image
  contexts (init-db, docker/sandbox)
- deploy orchestration (docker-compose*.yml, ecosystem.config.cjs)

Verified: critical build paths (console/management/shared/backend-spring +
their package.json/pnpm-lock.yaml/mvnw/src/public) remain visible to the
context.

Fixes #103

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 41a57ce537

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread .dockerignore
Comment on lines +41 to +42
.env
.env.*

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Exclude nested dotenv files from Docker context

When a developer builds the console or management images from a checkout containing console/.env.local, console/.env.production.local, or similar app-local dotenv files, these patterns only cover dotenv files at the root of the build context; the Docker docs note that a bare glob such as *.md applies only right under the context directory. Since the frontend Dockerfiles use COPY console ./console / COPY management ./management before pnpm build, those local env files can still be sent to the daemon, stored in build cache, or influence the Vite bundle. Use recursive patterns such as **/.env and **/.env.* with explicit example-file exceptions.

Useful? React with 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix: 新增 .dockerignore 收紧 build context(性能 + 敏感文件入镜像防护)

1 participant