Skip to content

[#3078] Kept 'auth.json' out of the container build context and image. - #3084

Open
AlexSkrypnyk wants to merge 4 commits into
mainfrom
feature/dockerignore-auth
Open

[#3078] Kept 'auth.json' out of the container build context and image.#3084
AlexSkrypnyk wants to merge 4 commits into
mainfrom
feature/dockerignore-auth

Conversation

@AlexSkrypnyk

@AlexSkrypnyk AlexSkrypnyk commented Sep 3, 2026

Copy link
Copy Markdown
Member

Closes #3078

Summary

.dockerignore did not exclude auth*, and .docker/cli.dockerfile copied it explicitly, so a project with a local auth.json baked its Composer package token into the built image through two paths: the explicit COPY ... auth* /app/ and the later COPY . /app. The build does not need the file: credentials for the Composer install come from COMPOSER_AUTH, assembled inside the RUN from the package_token build secret or the PACKAGE_TOKEN build arg. The file is now excluded from the build context and dropped from the copy, so it can no longer reach the image, and a test asserts that it does not.

Changes

  • Added auth* to .dockerignore under a new credentials group, placed to follow the header's deny-list ordering (VCS internals, then secrets).
  • Removed auth* from the COPY composer.json composer.* patches.lock.* .env* /app/ instruction in .docker/cli.dockerfile.
  • Updated the str_replace() needle in .vortex/tests/phpunit/Traits/SutTrait.php that anchors the test-only tooling COPY injection to this instruction, so the injection keeps matching.
  • Extended testDockerComposePackageToken() in .vortex/tests/phpunit/Functional/DockerComposeWorkflowTest.php to write an auth.json into the build context and assert that the built image does not contain /app/auth.json.
  • Regenerated installer fixtures via ahoy update-snapshots: the baseline .dockerignore and cli.dockerfile carry the change, and the per-scenario diff fixtures shift their hunk offsets accordingly.

Adding auth.json to the template's .gitignore is a possible follow-up not included here.

Test coverage

testDockerComposePackageToken() already covered the credential path itself: it requires drevops/test-private-package (a private repository), asserts that the image build fails without PACKAGE_TOKEN, and asserts that it succeeds with it. Because the system under test is a freshly installed template that carries no auth.json, that pair of builds already demonstrated that a private package resolves during the build from the package_token build secret alone.

What was not covered is the exclusion this change introduces. The test now writes an auth.json into the build context before both builds and asserts that the file is absent from the resulting image. Its token is deliberately invalid, which leaves both existing build outcomes unchanged: the no-token build still fails, and the token build still succeeds because Composer re-applies COMPOSER_AUTH over any project-level auth.json. The only condition the new assertion can fail on is auth* no longer being excluded from the build context.

That isolation was confirmed by removing the .dockerignore entry and re-running the test: both builds behaved exactly as before and only the new assertion failed.

Before / After

Before
┌──────────────────────┐  COPY ... auth* /app/  ┌──────────────────────┐
│ Build context        │ ──────────────────────▶│ cli image            │
│ (auth.json included) │  COPY . /app           │ /app/auth.json       │
│                      │ ──────────────────────▶│ (token baked in)     │
└──────────────────────┘                        └──────────────────────┘

After
┌──────────────────────┐  COPY ... .env* /app/  ┌──────────────────────┐
│ Build context        │ ──────────────────────▶│ cli image            │
│ (auth* excluded by   │  COPY . /app           │ no auth.json         │
│  .dockerignore)      │ ──────────────────────▶│                      │
└──────────────────────┘                        └──────────────────────┘

Both: --mount=type=secret,id=package_token ─▶ COMPOSER_AUTH ─▶ composer install
Test guard

Before                                    After
  build without token  ─▶ fails             plant auth.json (invalid token)
  build with token     ─▶ succeeds            build without token  ─▶ fails      (unchanged)
  image contents       ─▶ unchecked           build with token     ─▶ succeeds   (unchanged)
                                              /app/auth.json       ─▶ absent     (new)

@coderabbitai

coderabbitai Bot commented Sep 3, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: ASSERTIVE

Plan: Team

Run ID: f095be1c-5758-47e0-b1a5-845c843526ae

📥 Commits

Reviewing files that changed from the base of the PR and between 07d8658 and f7f7afa.

⛔ Files ignored due to path filters (32)
  • .vortex/installer/tests/Fixtures/handler_process/_baseline/.docker/cli.dockerfile is excluded by !.vortex/installer/tests/Fixtures/**
  • .vortex/installer/tests/Fixtures/handler_process/_baseline/.dockerignore is excluded by !.vortex/installer/tests/Fixtures/**
  • .vortex/installer/tests/Fixtures/handler_process/ciprovider_circleci/.dockerignore is excluded by !.vortex/installer/tests/Fixtures/**
  • .vortex/installer/tests/Fixtures/handler_process/code_coverage_provider_codecov_circleci/.dockerignore is excluded by !.vortex/installer/tests/Fixtures/**
  • .vortex/installer/tests/Fixtures/handler_process/deploy_types_all_circleci/.dockerignore is excluded by !.vortex/installer/tests/Fixtures/**
  • .vortex/installer/tests/Fixtures/handler_process/deploy_types_none_circleci/.dockerignore is excluded by !.vortex/installer/tests/Fixtures/**
  • .vortex/installer/tests/Fixtures/handler_process/deps_updates_provider_ci_circleci/.dockerignore is excluded by !.vortex/installer/tests/Fixtures/**
  • .vortex/installer/tests/Fixtures/handler_process/hosting_acquia/.dockerignore is excluded by !.vortex/installer/tests/Fixtures/**
  • .vortex/installer/tests/Fixtures/handler_process/hosting_project_name___acquia/.dockerignore is excluded by !.vortex/installer/tests/Fixtures/**
  • .vortex/installer/tests/Fixtures/handler_process/migration_disabled_circleci/.dockerignore is excluded by !.vortex/installer/tests/Fixtures/**
  • .vortex/installer/tests/Fixtures/handler_process/migration_enabled_circleci/.dockerignore is excluded by !.vortex/installer/tests/Fixtures/**
  • .vortex/installer/tests/Fixtures/handler_process/timezone_circleci/.dockerignore is excluded by !.vortex/installer/tests/Fixtures/**
  • .vortex/installer/tests/Fixtures/handler_process/tools_groups_no_be_lint_circleci/.dockerignore is excluded by !.vortex/installer/tests/Fixtures/**
  • .vortex/installer/tests/Fixtures/handler_process/tools_groups_no_be_tests/.dockerignore is excluded by !.vortex/installer/tests/Fixtures/**
  • .vortex/installer/tests/Fixtures/handler_process/tools_groups_no_be_tests_circleci/.dockerignore is excluded by !.vortex/installer/tests/Fixtures/**
  • .vortex/installer/tests/Fixtures/handler_process/tools_groups_no_fe_lint_circleci/.dockerignore is excluded by !.vortex/installer/tests/Fixtures/**
  • .vortex/installer/tests/Fixtures/handler_process/tools_groups_no_fe_lint_no_theme_circleci/.dockerignore is excluded by !.vortex/installer/tests/Fixtures/**
  • .vortex/installer/tests/Fixtures/handler_process/tools_no_behat_circleci/.dockerignore is excluded by !.vortex/installer/tests/Fixtures/**
  • .vortex/installer/tests/Fixtures/handler_process/tools_no_dclint_circleci/.dockerignore is excluded by !.vortex/installer/tests/Fixtures/**
  • .vortex/installer/tests/Fixtures/handler_process/tools_no_docker_linters_circleci/.dockerignore is excluded by !.vortex/installer/tests/Fixtures/**
  • .vortex/installer/tests/Fixtures/handler_process/tools_no_eslint_circleci/.dockerignore is excluded by !.vortex/installer/tests/Fixtures/**
  • .vortex/installer/tests/Fixtures/handler_process/tools_no_hadolint_circleci/.dockerignore is excluded by !.vortex/installer/tests/Fixtures/**
  • .vortex/installer/tests/Fixtures/handler_process/tools_no_jest_circleci/.dockerignore is excluded by !.vortex/installer/tests/Fixtures/**
  • .vortex/installer/tests/Fixtures/handler_process/tools_no_phpcs_circleci/.dockerignore is excluded by !.vortex/installer/tests/Fixtures/**
  • .vortex/installer/tests/Fixtures/handler_process/tools_no_phpstan_circleci/.dockerignore is excluded by !.vortex/installer/tests/Fixtures/**
  • .vortex/installer/tests/Fixtures/handler_process/tools_no_phpunit/.dockerignore is excluded by !.vortex/installer/tests/Fixtures/**
  • .vortex/installer/tests/Fixtures/handler_process/tools_no_phpunit_circleci/.dockerignore is excluded by !.vortex/installer/tests/Fixtures/**
  • .vortex/installer/tests/Fixtures/handler_process/tools_no_rector_circleci/.dockerignore is excluded by !.vortex/installer/tests/Fixtures/**
  • .vortex/installer/tests/Fixtures/handler_process/tools_no_stylelint_circleci/.dockerignore is excluded by !.vortex/installer/tests/Fixtures/**
  • .vortex/installer/tests/Fixtures/handler_process/tools_no_twig/.dockerignore is excluded by !.vortex/installer/tests/Fixtures/**
  • .vortex/installer/tests/Fixtures/handler_process/tools_no_twig_circleci/.dockerignore is excluded by !.vortex/installer/tests/Fixtures/**
  • .vortex/installer/tests/Fixtures/handler_process/tools_none/.dockerignore is excluded by !.vortex/installer/tests/Fixtures/**
📒 Files selected for processing (3)
  • .docker/cli.dockerfile
  • .dockerignore
  • .vortex/tests/phpunit/Traits/SutTrait.php

Included review availability: 6 reviews are currently available. Your included PR review attempts over the past 7 days set your current allowance at 8 reviews per hour.


Walkthrough

The Docker build now excludes auth* files from its build context and Composer input copy. PHPUnit test Dockerfile injection now matches the updated COPY directive.

Changes

Docker credential exclusion

Layer / File(s) Summary
Exclude auth files from Docker inputs
.dockerignore, .docker/cli.dockerfile, .vortex/tests/phpunit/Traits/SutTrait.php
.dockerignore excludes auth* paths. The Dockerfile removes auth* from the Composer input copy. Test injection targets the updated directive.

Estimated code review effort: 2 (Simple) | ~5 minutes

Merge Risk: ⚪ Minimal · up to f7f7a

Docker builds no longer include local auth files in the build context or image while Composer authentication remains available through configured secret or token inputs. The change is ready to merge.

Poem

A rabbit checks the Docker door,
No secret files pass through anymore.
Composer finds its token right,
The tests follow the copy line bright.
Safe builds hop into the night.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Linked Issues check ✅ Passed The changes satisfy issue #3078 by adding auth* to .dockerignore, removing auth* from the Dockerfile COPY instruction, and preserving Composer authentication behavior. SutTrait.php updates the related…
Out of Scope Changes check ✅ Passed All reviewable changes support the linked issue by preventing credential files from entering the Docker build context or image and by updating related test tooling.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 1 functions across 1 files. (2 skipped: 2 …
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly describes the main change: preventing auth.json and related authentication files from entering the Docker build context and image.
Full details: Linked Issues check

Explanation

The changes satisfy issue #3078 by adding auth* to .dockerignore, removing auth* from the Dockerfile COPY instruction, and preserving Composer authentication behavior. SutTrait.php updates the related test injection anchor.

Full details: Docstring Coverage

Explanation

Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 1 functions across 1 files. (2 skipped: 2 unsupported.)

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/dockerignore-auth

Comment @coderabbitai help to get the list of available commands.

@github-actions

This comment has been minimized.

@AlexSkrypnyk

This comment has been minimized.

2 similar comments
@AlexSkrypnyk

This comment has been minimized.

@AlexSkrypnyk

This comment has been minimized.

@codecov

codecov Bot commented Sep 3, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 87.00%. Comparing base (9f7de2a) to head (95320e6).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3084      +/-   ##
==========================================
- Coverage   87.28%   87.00%   -0.28%     
==========================================
  Files          99      100       +1     
  Lines        4679     4925     +246     
  Branches       49        3      -46     
==========================================
+ Hits         4084     4285     +201     
- Misses        595      640      +45     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@github-actions

github-actions Bot commented Sep 3, 2026

Copy link
Copy Markdown

📖 Documentation preview for this pull request has been deployed to Netlify:

https://6a992b632a7ef500e6925781--vortex-docs.netlify.app

This preview is rebuilt on every commit and is not the production documentation site.

@github-actions

This comment has been minimized.

@AlexSkrypnyk

This comment has been minimized.

2 similar comments
@AlexSkrypnyk

This comment has been minimized.

@AlexSkrypnyk

This comment has been minimized.

@AlexSkrypnyk AlexSkrypnyk added the Needs review Pull request needs a review from assigned developers label Sep 3, 2026
@AlexSkrypnyk
AlexSkrypnyk force-pushed the feature/dockerignore-auth branch from d53cfa1 to 95320e6 Compare September 3, 2026 07:56
@github-actions

github-actions Bot commented Sep 3, 2026

Copy link
Copy Markdown

Code coverage (threshold: 90%)

  Classes: 100.00% (1/1)
  Methods: 100.00% (2/2)
  Lines:   98.58% (209/212)
Per-class coverage
Drupal\ys_demo\Plugin\Block\CounterBlock
  Methods: 100.00% ( 2/ 2)   Lines: 100.00% ( 10/ 10)

@AlexSkrypnyk

This comment has been minimized.

2 similar comments
@AlexSkrypnyk

Copy link
Copy Markdown
Member Author

Code coverage (threshold: 90%)

  Classes: 100.00% (1/1)
  Methods: 100.00% (2/2)
  Lines:   98.58% (209/212)
Per-class coverage
Drupal\ys_demo\Plugin\Block\CounterBlock
  Methods: 100.00% ( 2/ 2)   Lines: 100.00% ( 10/ 10)

@AlexSkrypnyk

Copy link
Copy Markdown
Member Author

Code coverage (threshold: 90%)

  Classes: 100.00% (1/1)
  Methods: 100.00% (2/2)
  Lines:   98.58% (209/212)
Per-class coverage
Drupal\ys_demo\Plugin\Block\CounterBlock
  Methods: 100.00% ( 2/ 2)   Lines: 100.00% ( 10/ 10)

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

Labels

Needs review Pull request needs a review from assigned developers

Projects

Status: BACKLOG

Development

Successfully merging this pull request may close these issues.

Keep 'auth.json' out of the container build context and image

1 participant