Skip to content

feat(dashmate): add optional GitHub token and fix cargo git cache race condition - #2912

Merged
QuantumExplorer merged 4 commits into
v3.0-devfrom
feat/token-in-dockerfile
Dec 19, 2025
Merged

QuantumExplorer merged 4 commits into
v3.0-devfrom
feat/token-in-dockerfile

Conversation

@pauldelucia

@pauldelucia pauldelucia commented Dec 18, 2025 •

Copy link
Copy Markdown
Member

Issue being fixed or feature implemented

  1. Local network builds can hit GitHub's anonymous API rate limit when fetching Rust dependencies
  2. Concurrent builds using the cargo git cache could experience race conditions

What was done?

  1. Add optional GITHUB_TOKEN build secret for authenticated GitHub requests (increases rate limit from 60 to 5000 req/hour)
  2. Fix cargo git cache race condition by changing sharing mode from shared to locked

How Has This Been Tested?

export GITHUB_TOKEN=ghp_your_token_here
yarn start

Breaking Changes

Checklist:

  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have added or updated relevant unit/integration/functional/e2e tests
  • I have added "!" to the title and described breaking changes in the corresponding section if my code contains any
  • I have made corresponding changes to the documentation if needed

For repository code-owners and collaborators only

  • I have assigned this pull request to a milestone

Summary by CodeRabbit

  • Chores
    • Added optional GitHub token support for Docker builds to allow authenticated fetches when provided.
    • Standardized cargo git cache mounting to locked sharing across build stages for consistent caching.
    • Preserved sccache usage and stats reporting with sequencing around credential cleanup.
    • Ensured temporary git authentication state is reset between build steps to avoid leakage.
    • Updated build compose configs to expose the new token support.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai

coderabbitai Bot commented Dec 18, 2025 •

Copy link
Copy Markdown
Contributor

Walkthrough

Adds optional GitHub token support to Docker builds via a build secret and conditional git URL substitution in the Dockerfile, standardizes cargo git cache mounts from sharing=shared to sharing=locked across build stages, and exposes the GITHUB_TOKEN secret in multiple docker-compose build files; sccache steps remain unchanged.

Changes

Cohort / File(s) Summary
Dockerfile updates
Dockerfile
Adds ARG GITHUB_TOKEN and secret mounts (--mount=type=secret,id=GITHUB_TOKEN) in several RUN steps; conditionally configures git to rewrite GitHub URLs to include the token when /run/secrets/GITHUB_TOKEN exists, then removes the gitconfig after use. Replaces multiple --mount=type=cache,sharing=shared,id=cargo_git with sharing=locked. Retains sccache usage and stats reporting around git config resets.
Compose: build secret for base
packages/dashmate/docker-compose.build.base.yml
Declares top-level secret GITHUB_TOKEN: { environment: GITHUB_TOKEN } and attaches GITHUB_TOKEN as a build secret to the _base service build. No other changes.
Compose: build secret for dashmate_helper
packages/dashmate/docker-compose.build.dashmate_helper.yml
Declares top-level secret GITHUB_TOKEN: { environment: GITHUB_TOKEN } and attaches GITHUB_TOKEN as a build secret to the dashmate_helper service build. No other changes.
Compose: build secret for drive_abci
packages/dashmate/docker-compose.build.drive_abci.yml
Declares top-level secret GITHUB_TOKEN: { environment: GITHUB_TOKEN } and attaches GITHUB_TOKEN as a build secret to the drive_abci service build. No other changes.
Compose: build secret for rs-dapi
packages/dashmate/docker-compose.build.rs-dapi.yml
Declares top-level secret GITHUB_TOKEN: { environment: GITHUB_TOKEN } and attaches GITHUB_TOKEN as a build secret to the rs_dapi service build. No other changes.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20–30 minutes

  • Inspect Dockerfile conditional git config (setup and teardown) for correctness and leakage risks.
  • Confirm /run/secrets/GITHUB_TOKEN checks and secret mount usage are applied in all relevant RUN steps.
  • Verify sharing=locked for cargo git caches is appropriate for the build pipeline and concurrent builds.
  • Validate docker-compose secret declarations and that service build blocks reference the secret correctly.

Poem

🐇 I nibble tokens in the build-time light,
Quietly swap URLs so fetches take flight.
Caches locked tight, sccache sings on the run,
Layers stitched neat when the build is done.
🥕✨

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes both main changes: adding optional GitHub token authentication and fixing cargo git cache race condition via cache sharing mode.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feat/token-in-dockerfile

📜 Recent review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 55230fb and 8060a23.

📒 Files selected for processing (1)
  • Dockerfile (10 hunks)
🧰 Additional context used
🧠 Learnings (18)
📓 Common learnings
Learnt from: lklimek
Repo: dashpay/platform PR: 2318
File: .github/workflows/tests-build-image.yml:45-45
Timestamp: 2024-11-13T10:31:30.891Z
Learning: In the dashpay/platform repository, changes to `.github/workflows/tests-build-image.yml` that switch the Docker image platform from `linux/arm64` to `linux/amd64` for testing purposes are acceptable when required to run on GitHub-hosted runners. ARM64 testing is covered on the testnet.
Learnt from: shumkov
Repo: dashpay/platform PR: 2184
File: .github/workflows/prebuild-devcontainers.yml:0-0
Timestamp: 2024-10-09T00:22:57.778Z
Learning: In this repository, using a personal access token is necessary for GitHub Actions workflows to push to the GitHub Container Registry because `GITHUB_TOKEN` lacks the required permissions.
Learnt from: shumkov
Repo: dashpay/platform PR: 2184
File: .github/workflows/prebuild-devcontainers.yml:0-0
Timestamp: 2024-09-29T01:40:54.588Z
Learning: In this repository, using a personal access token is necessary for GitHub Actions workflows to push to the GitHub Container Registry because `GITHUB_TOKEN` lacks the required permissions.
Learnt from: lklimek
Repo: dashpay/platform PR: 2318
File: Dockerfile:0-0
Timestamp: 2024-11-13T10:32:02.981Z
Learning: In the Dockerfile's sccache configuration script, the team relies on sccache to validate required arguments, so explicit error handling for missing variables is unnecessary.
Learnt from: lklimek
Repo: dashpay/platform PR: 2344
File: .github/workflows/tests-rs-package.yml:30-37
Timestamp: 2024-11-25T12:59:18.673Z
Learning: The `sccache` action exists in the repository at `./.github/actions/sccache`.
Learnt from: lklimek
Repo: dashpay/platform PR: 2318
File: Dockerfile:160-198
Timestamp: 2024-11-13T10:31:31.084Z
Learning: In the `Dockerfile` for the rs-drive-abci project, when configuring sccache, we do not need to add validation checks for configuration variables, as sccache performs validation at runtime.
📚 Learning: 2024-11-25T13:09:41.979Z
Learnt from: lklimek
Repo: dashpay/platform PR: 2344
File: Dockerfile:198-207
Timestamp: 2024-11-25T13:09:41.979Z
Learning: In the `Dockerfile`, credentials are managed by Docker secret mounts (e.g., `--mount=type=secret,id=AWS`), so there's no need to add cleanup steps to wipe credentials after use.

Applied to files:

  • Dockerfile
📚 Learning: 2024-11-13T12:30:16.951Z
Learnt from: shumkov
Repo: dashpay/platform PR: 2321
File: Dockerfile:1-1
Timestamp: 2024-11-13T12:30:16.951Z
Learning: In Dockerfiles, specifying `# syntax = docker/dockerfile:1` ensures that the Dockerfile uses the latest `1.x` syntax, which supports advanced features like `RUN --mount` commands with cache mounting.

Applied to files:

  • Dockerfile
📚 Learning: 2024-11-13T10:31:31.084Z
Learnt from: lklimek
Repo: dashpay/platform PR: 2318
File: Dockerfile:160-198
Timestamp: 2024-11-13T10:31:31.084Z
Learning: In the `Dockerfile` for the rs-drive-abci project, when configuring sccache, we do not need to add validation checks for configuration variables, as sccache performs validation at runtime.

Applied to files:

  • Dockerfile
📚 Learning: 2024-10-09T00:22:57.778Z
Learnt from: shumkov
Repo: dashpay/platform PR: 2184
File: .github/workflows/prebuild-devcontainers.yml:0-0
Timestamp: 2024-10-09T00:22:57.778Z
Learning: In this repository, using a personal access token is necessary for GitHub Actions workflows to push to the GitHub Container Registry because `GITHUB_TOKEN` lacks the required permissions.

Applied to files:

  • Dockerfile
📚 Learning: 2024-11-25T12:59:11.416Z
Learnt from: lklimek
Repo: dashpay/platform PR: 2344
File: .github/workflows/release-docker-image.yml:66-70
Timestamp: 2024-11-25T12:59:11.416Z
Learning: In the CI workflows (e.g., `.github/workflows/release-docker-image.yml` and `tests-build-image.yml`), we do not add validation steps for cache configuration variables. We rely on the build process to quickly reveal any misconfigurations.

Applied to files:

  • Dockerfile
📚 Learning: 2024-11-13T10:32:02.981Z
Learnt from: lklimek
Repo: dashpay/platform PR: 2318
File: Dockerfile:0-0
Timestamp: 2024-11-13T10:32:02.981Z
Learning: In the Dockerfile's sccache configuration script, the team relies on sccache to validate required arguments, so explicit error handling for missing variables is unnecessary.

Applied to files:

  • Dockerfile
📚 Learning: 2024-12-16T08:59:40.337Z
Learnt from: lklimek
Repo: dashpay/platform PR: 2374
File: Dockerfile:117-118
Timestamp: 2024-12-16T08:59:40.337Z
Learning: In our Dockerfiles, using `ONBUILD ARG CARGO_BUILD_PROFILE=dev` works correctly, and `CARGO_BUILD_PROFILE` is recognized in subsequent stages.

Applied to files:

  • Dockerfile
📚 Learning: 2024-11-03T10:39:11.242Z
Learnt from: shumkov
Repo: dashpay/platform PR: 2305
File: packages/rs-drive-abci/src/abci/handler/finalize_block.rs:81-0
Timestamp: 2024-11-03T10:39:11.242Z
Learning: In `packages/rs-drive-abci/src/abci/handler/finalize_block.rs`, the use of `.expect("commit transaction")` after `app.commit_transaction(platform_version)` is intentional due to the provided comment explaining its necessity. Do not flag this usage in future reviews.

Applied to files:

  • Dockerfile
📚 Learning: 2024-11-25T12:59:13.055Z
Learnt from: lklimek
Repo: dashpay/platform PR: 2344
File: Dockerfile:55-58
Timestamp: 2024-11-25T12:59:13.055Z
Learning: In Dockerfile multi-stage builds, variables defined within `RUN` instructions are not available in `FROM` commands in subsequent stages.

Applied to files:

  • Dockerfile
📚 Learning: 2024-11-25T12:59:18.673Z
Learnt from: lklimek
Repo: dashpay/platform PR: 2344
File: .github/workflows/tests-rs-package.yml:30-37
Timestamp: 2024-11-25T12:59:18.673Z
Learning: The `sccache` action exists in the repository at `./.github/actions/sccache`.

Applied to files:

  • Dockerfile
📚 Learning: 2024-11-25T12:59:11.765Z
Learnt from: lklimek
Repo: dashpay/platform PR: 2344
File: Dockerfile:188-189
Timestamp: 2024-11-25T12:59:11.765Z
Learning: In the `Dockerfile`, when using `echo` with single quotes to write to a file, variable expansion and command substitution do not occur during the build process. Therefore, commands like `echo 'export VAR="$(cat /run/secrets/FILE)"' >> /root/env` do not expose secrets in image layers, as the substitution happens only when the file is sourced at runtime.

Applied to files:

  • Dockerfile
📚 Learning: 2024-12-05T09:29:38.918Z
Learnt from: shumkov
Repo: dashpay/platform PR: 2375
File: packages/rs-drive-abci/Cargo.toml:61-63
Timestamp: 2024-12-05T09:29:38.918Z
Learning: In the `drive-abci` package, avoid adding unused dependencies like `hashbrown` to `Cargo.toml`. The team relies on CI to detect dependency version issues.

Applied to files:

  • Dockerfile
📚 Learning: 2025-11-25T13:10:47.943Z
Learnt from: CR
Repo: dashpay/platform PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-11-25T13:10:47.943Z
Learning: Applies to **/*.rs : Follow rustfmt defaults and keep code clippy-clean for Rust modules

Applied to files:

  • Dockerfile
📚 Learning: 2025-11-25T13:10:23.481Z
Learnt from: CR
Repo: dashpay/platform PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-11-25T13:10:23.481Z
Learning: Applies to **/*.rs : Rust code must pass `cargo clippy --workspace` linter checks

Applied to files:

  • Dockerfile
📚 Learning: 2025-11-25T13:10:23.481Z
Learnt from: CR
Repo: dashpay/platform PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-11-25T13:10:23.481Z
Learning: Run Rust tests for packages using `cargo test -p <package_name>` and all Rust tests with `cargo test --workspace`

Applied to files:

  • Dockerfile
📚 Learning: 2024-10-17T08:52:54.300Z
Learnt from: shumkov
Repo: dashpay/platform PR: 2248
File: packages/rs-drive-abci/src/main.rs:106-111
Timestamp: 2024-10-17T08:52:54.300Z
Learning: In this project, the environment variable `CARGO_PKG_RUST_VERSION` is defined and can be used safely with the `env!` macro.

Applied to files:

  • Dockerfile
📚 Learning: 2025-11-25T13:10:23.481Z
Learnt from: CR
Repo: dashpay/platform PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-11-25T13:10:23.481Z
Learning: Applies to **/*.rs : Rust code must be formatted using `cargo fmt --all`

Applied to files:

  • Dockerfile
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (5)
  • GitHub Check: Build Docker images (Dashmate helper, dashmate-helper, dashmate-helper) / Build Dashmate helper image
  • GitHub Check: Build Docker images (RS-DAPI, rs-dapi, rs-dapi) / Build RS-DAPI image
  • GitHub Check: Build Docker images (Drive, drive, drive-abci) / Build Drive image
  • GitHub Check: Build JS packages / Build JS
  • GitHub Check: Rust crates security audit
🔇 Additional comments (3)
Dockerfile (3)

174-177: Clear documentation of the optional GITHUB_TOKEN secret.

The documentation accurately describes the purpose and benefit of the GITHUB_TOKEN secret, making it easy for users to understand when to use it.


436-440: LGTM: Secure implementation of optional GITHUB_TOKEN authentication.

The implementation correctly addresses previous security concerns:

  • Uses Docker secrets (not ARG) to prevent token exposure in image history
  • Conditionally applies git config only when the secret is present, making it truly optional
  • Cleans up .gitconfig after use to prevent leakage between stages
  • Token is scoped only to build stages and never reaches final images

The simplified cleanup approach (rm -f ~/.gitconfig) is effective and less error-prone than trying to unset specific git config sections.

Also applies to: 554-557, 566-567, 780-784, 794-795

Also applies to: 456-457


434-434: Correct fix: sharing=locked prevents cargo git cache corruption.

Changing the cargo git cache from sharing=shared to sharing=locked is the right approach. Cargo's git database requires exclusive access to prevent concurrent write corruption. The tradeoff is that git operations will be serialized across parallel builds (potentially increasing CI queue times), but this is necessary for correctness.

Note that registry caches correctly remain sharing=shared since they don't have the same corruption risk.

Also applies to: 512-512, 552-552, 615-615, 778-778, 848-848


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 2

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
Dockerfile (1)

15-48: Document the new GITHUB_TOKEN build argument.

The file header comprehensively documents other build arguments (lines 15-39), but the newly added GITHUB_TOKEN parameter is not documented.

🔎 Add documentation for GITHUB_TOKEN
 # The following build arguments can be provided using --build-arg:
 # - CARGO_BUILD_PROFILE - set to `release` to build final binary, without debugging information
 # - NODE_ENV - node.js environment name to use to build the library
+# - GITHUB_TOKEN - optional GitHub personal access token to increase API rate limits from 60 to 5000 req/hour
+#   during dependency resolution. WARNING: token will be visible in image history if not properly managed.
 # - ALPINE_VERSION - use different version of Alpine base image; requires also rust:apline...
 #   image to be available
📜 Review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 6fd1e1e and f06fec5.

📒 Files selected for processing (5)
  • Dockerfile (7 hunks)
  • packages/dashmate/docker-compose.build.base.yml (1 hunks)
  • packages/dashmate/docker-compose.build.dashmate_helper.yml (1 hunks)
  • packages/dashmate/docker-compose.build.drive_abci.yml (1 hunks)
  • packages/dashmate/docker-compose.build.rs-dapi.yml (1 hunks)
🧰 Additional context used
🧠 Learnings (12)
📓 Common learnings
Learnt from: lklimek
Repo: dashpay/platform PR: 2318
File: .github/workflows/tests-build-image.yml:45-45
Timestamp: 2024-11-13T10:31:30.891Z
Learning: In the dashpay/platform repository, changes to `.github/workflows/tests-build-image.yml` that switch the Docker image platform from `linux/arm64` to `linux/amd64` for testing purposes are acceptable when required to run on GitHub-hosted runners. ARM64 testing is covered on the testnet.
Learnt from: shumkov
Repo: dashpay/platform PR: 2184
File: .github/workflows/prebuild-devcontainers.yml:0-0
Timestamp: 2024-10-09T00:22:57.778Z
Learning: In this repository, using a personal access token is necessary for GitHub Actions workflows to push to the GitHub Container Registry because `GITHUB_TOKEN` lacks the required permissions.
Learnt from: shumkov
Repo: dashpay/platform PR: 2184
File: .github/workflows/prebuild-devcontainers.yml:0-0
Timestamp: 2024-09-29T01:40:54.588Z
Learning: In this repository, using a personal access token is necessary for GitHub Actions workflows to push to the GitHub Container Registry because `GITHUB_TOKEN` lacks the required permissions.
Learnt from: lklimek
Repo: dashpay/platform PR: 2374
File: Dockerfile:117-118
Timestamp: 2024-12-16T08:59:40.337Z
Learning: In our Dockerfiles, using `ONBUILD ARG CARGO_BUILD_PROFILE=dev` works correctly, and `CARGO_BUILD_PROFILE` is recognized in subsequent stages.
📚 Learning: 2025-10-15T14:45:30.856Z
Learnt from: lklimek
Repo: dashpay/platform PR: 2716
File: packages/dashmate/src/test/constants/services.js:4-4
Timestamp: 2025-10-15T14:45:30.856Z
Learning: In the dashmate codebase (packages/dashmate), during the DAPI Rust migration (rs-dapi), the old service keys `dapi_api` and `dapi_core_streams` are intentionally kept in `generateEnvsFactory.js` for backward compatibility even though the test constants in `src/test/constants/services.js` have been updated to use `rs_dapi`. These deprecated keys will be removed in a future PR after the transition is complete.

Applied to files:

  • packages/dashmate/docker-compose.build.rs-dapi.yml
📚 Learning: 2024-10-09T00:22:57.778Z
Learnt from: shumkov
Repo: dashpay/platform PR: 2184
File: .github/workflows/prebuild-devcontainers.yml:0-0
Timestamp: 2024-10-09T00:22:57.778Z
Learning: In this repository, using a personal access token is necessary for GitHub Actions workflows to push to the GitHub Container Registry because `GITHUB_TOKEN` lacks the required permissions.

Applied to files:

  • packages/dashmate/docker-compose.build.rs-dapi.yml
  • packages/dashmate/docker-compose.build.base.yml
  • Dockerfile
  • packages/dashmate/docker-compose.build.drive_abci.yml
  • packages/dashmate/docker-compose.build.dashmate_helper.yml
📚 Learning: 2024-11-13T10:31:31.084Z
Learnt from: lklimek
Repo: dashpay/platform PR: 2318
File: Dockerfile:160-198
Timestamp: 2024-11-13T10:31:31.084Z
Learning: In the `Dockerfile` for the rs-drive-abci project, when configuring sccache, we do not need to add validation checks for configuration variables, as sccache performs validation at runtime.

Applied to files:

  • packages/dashmate/docker-compose.build.rs-dapi.yml
  • packages/dashmate/docker-compose.build.base.yml
  • Dockerfile
  • packages/dashmate/docker-compose.build.drive_abci.yml
📚 Learning: 2024-11-13T10:32:02.981Z
Learnt from: lklimek
Repo: dashpay/platform PR: 2318
File: Dockerfile:0-0
Timestamp: 2024-11-13T10:32:02.981Z
Learning: In the Dockerfile's sccache configuration script, the team relies on sccache to validate required arguments, so explicit error handling for missing variables is unnecessary.

Applied to files:

  • packages/dashmate/docker-compose.build.base.yml
  • packages/dashmate/docker-compose.build.drive_abci.yml
  • packages/dashmate/docker-compose.build.dashmate_helper.yml
📚 Learning: 2024-11-13T12:30:16.951Z
Learnt from: shumkov
Repo: dashpay/platform PR: 2321
File: Dockerfile:1-1
Timestamp: 2024-11-13T12:30:16.951Z
Learning: In Dockerfiles, specifying `# syntax = docker/dockerfile:1` ensures that the Dockerfile uses the latest `1.x` syntax, which supports advanced features like `RUN --mount` commands with cache mounting.

Applied to files:

  • Dockerfile
📚 Learning: 2024-12-16T08:59:40.337Z
Learnt from: lklimek
Repo: dashpay/platform PR: 2374
File: Dockerfile:117-118
Timestamp: 2024-12-16T08:59:40.337Z
Learning: In our Dockerfiles, using `ONBUILD ARG CARGO_BUILD_PROFILE=dev` works correctly, and `CARGO_BUILD_PROFILE` is recognized in subsequent stages.

Applied to files:

  • Dockerfile
📚 Learning: 2024-11-25T13:09:41.979Z
Learnt from: lklimek
Repo: dashpay/platform PR: 2344
File: Dockerfile:198-207
Timestamp: 2024-11-25T13:09:41.979Z
Learning: In the `Dockerfile`, credentials are managed by Docker secret mounts (e.g., `--mount=type=secret,id=AWS`), so there's no need to add cleanup steps to wipe credentials after use.

Applied to files:

  • Dockerfile
📚 Learning: 2024-11-25T12:59:13.055Z
Learnt from: lklimek
Repo: dashpay/platform PR: 2344
File: Dockerfile:55-58
Timestamp: 2024-11-25T12:59:13.055Z
Learning: In Dockerfile multi-stage builds, variables defined within `RUN` instructions are not available in `FROM` commands in subsequent stages.

Applied to files:

  • Dockerfile
📚 Learning: 2024-11-25T12:59:11.765Z
Learnt from: lklimek
Repo: dashpay/platform PR: 2344
File: Dockerfile:188-189
Timestamp: 2024-11-25T12:59:11.765Z
Learning: In the `Dockerfile`, when using `echo` with single quotes to write to a file, variable expansion and command substitution do not occur during the build process. Therefore, commands like `echo 'export VAR="$(cat /run/secrets/FILE)"' >> /root/env` do not expose secrets in image layers, as the substitution happens only when the file is sourced at runtime.

Applied to files:

  • Dockerfile
📚 Learning: 2024-12-05T09:29:38.918Z
Learnt from: shumkov
Repo: dashpay/platform PR: 2375
File: packages/rs-drive-abci/Cargo.toml:61-63
Timestamp: 2024-12-05T09:29:38.918Z
Learning: In the `drive-abci` package, avoid adding unused dependencies like `hashbrown` to `Cargo.toml`. The team relies on CI to detect dependency version issues.

Applied to files:

  • Dockerfile
📚 Learning: 2024-10-17T08:52:54.300Z
Learnt from: shumkov
Repo: dashpay/platform PR: 2248
File: packages/rs-drive-abci/src/main.rs:106-111
Timestamp: 2024-10-17T08:52:54.300Z
Learning: In this project, the environment variable `CARGO_PKG_RUST_VERSION` is defined and can be used safely with the `env!` macro.

Applied to files:

  • Dockerfile
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (5)
  • GitHub Check: Build Docker images (Drive, drive, drive-abci) / Build Drive image
  • GitHub Check: Build Docker images (RS-DAPI, rs-dapi, rs-dapi) / Build RS-DAPI image
  • GitHub Check: Build Docker images (Dashmate helper, dashmate-helper, dashmate-helper) / Build Dashmate helper image
  • GitHub Check: Build JS packages / Build JS
  • GitHub Check: Rust crates security audit
🔇 Additional comments (4)
packages/dashmate/docker-compose.build.base.yml (1)

10-10: LGTM! Correctly propagates the optional GITHUB_TOKEN.

The GITHUB_TOKEN build argument is properly passed through from the environment. Docker Compose will substitute an empty string if the environment variable is not set, which aligns with the optional nature of this feature in the Dockerfile.

packages/dashmate/docker-compose.build.rs-dapi.yml (1)

10-10: LGTM! Consistent with other service configurations.

The GITHUB_TOKEN build argument is correctly added to the rs_dapi service, maintaining consistency with the base service and other build configurations.

packages/dashmate/docker-compose.build.drive_abci.yml (1)

10-10: LGTM! Properly configured.

The GITHUB_TOKEN build argument follows the same pattern as other services.

packages/dashmate/docker-compose.build.dashmate_helper.yml (1)

10-10: LGTM! Completes the consistent pattern.

The GITHUB_TOKEN build argument is correctly added to the dashmate_helper service, completing the consistent implementation across all build configurations.

Comment thread Dockerfile Resolved
Comment thread Dockerfile Resolved
@pauldelucia pauldelucia changed the title feat: optional github token in dockerfile for local network build feat(build): add optional GitHub token and fix cargo git cache race condition Dec 19, 2025
@pauldelucia pauldelucia changed the title feat(build): add optional GitHub token and fix cargo git cache race condition feat(dashmate): add optional GitHub token and fix cargo git cache race condition Dec 19, 2025

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

♻️ Duplicate comments (2)
Dockerfile (2)

555-557: Same git config cleanup bug exists in build-js stage.

The git config unset command uses the wrong key and won't actually remove the URL rewrite rule. Apply the same fix as recommended for the build-drive-abci stage (lines 434-457).

Also applies to: 566-567


782-784: Same git config cleanup bug exists in build-rs-dapi stage.

The git config unset command uses the wrong key and won't actually remove the URL rewrite rule. Apply the same fix as recommended for the build-drive-abci stage (lines 434-457).

Also applies to: 794-795

📜 Review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between f06fec5 and 55230fb.

📒 Files selected for processing (5)
  • Dockerfile (10 hunks)
  • packages/dashmate/docker-compose.build.base.yml (1 hunks)
  • packages/dashmate/docker-compose.build.dashmate_helper.yml (1 hunks)
  • packages/dashmate/docker-compose.build.drive_abci.yml (1 hunks)
  • packages/dashmate/docker-compose.build.rs-dapi.yml (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (3)
  • packages/dashmate/docker-compose.build.dashmate_helper.yml
  • packages/dashmate/docker-compose.build.drive_abci.yml
  • packages/dashmate/docker-compose.build.base.yml
🧰 Additional context used
🧠 Learnings (19)
📓 Common learnings
Learnt from: lklimek
Repo: dashpay/platform PR: 2318
File: .github/workflows/tests-build-image.yml:45-45
Timestamp: 2024-11-13T10:31:30.891Z
Learning: In the dashpay/platform repository, changes to `.github/workflows/tests-build-image.yml` that switch the Docker image platform from `linux/arm64` to `linux/amd64` for testing purposes are acceptable when required to run on GitHub-hosted runners. ARM64 testing is covered on the testnet.
Learnt from: shumkov
Repo: dashpay/platform PR: 2184
File: .github/workflows/prebuild-devcontainers.yml:0-0
Timestamp: 2024-10-09T00:22:57.778Z
Learning: In this repository, using a personal access token is necessary for GitHub Actions workflows to push to the GitHub Container Registry because `GITHUB_TOKEN` lacks the required permissions.
Learnt from: shumkov
Repo: dashpay/platform PR: 2184
File: .github/workflows/prebuild-devcontainers.yml:0-0
Timestamp: 2024-09-29T01:40:54.588Z
Learning: In this repository, using a personal access token is necessary for GitHub Actions workflows to push to the GitHub Container Registry because `GITHUB_TOKEN` lacks the required permissions.
Learnt from: lklimek
Repo: dashpay/platform PR: 2344
File: .github/workflows/tests-rs-package.yml:30-37
Timestamp: 2024-11-25T12:59:18.673Z
Learning: The `sccache` action exists in the repository at `./.github/actions/sccache`.
Learnt from: lklimek
Repo: dashpay/platform PR: 2318
File: Dockerfile:0-0
Timestamp: 2024-11-13T10:32:02.981Z
Learning: In the Dockerfile's sccache configuration script, the team relies on sccache to validate required arguments, so explicit error handling for missing variables is unnecessary.
Learnt from: lklimek
Repo: dashpay/platform PR: 2318
File: Dockerfile:160-198
Timestamp: 2024-11-13T10:31:31.084Z
Learning: In the `Dockerfile` for the rs-drive-abci project, when configuring sccache, we do not need to add validation checks for configuration variables, as sccache performs validation at runtime.
Learnt from: lklimek
Repo: dashpay/platform PR: 2344
File: .github/workflows/release-docker-image.yml:66-70
Timestamp: 2024-11-25T12:59:11.416Z
Learning: In the CI workflows (e.g., `.github/workflows/release-docker-image.yml` and `tests-build-image.yml`), we do not add validation steps for cache configuration variables. We rely on the build process to quickly reveal any misconfigurations.
📚 Learning: 2024-11-25T13:09:41.979Z
Learnt from: lklimek
Repo: dashpay/platform PR: 2344
File: Dockerfile:198-207
Timestamp: 2024-11-25T13:09:41.979Z
Learning: In the `Dockerfile`, credentials are managed by Docker secret mounts (e.g., `--mount=type=secret,id=AWS`), so there's no need to add cleanup steps to wipe credentials after use.

Applied to files:

  • Dockerfile
  • packages/dashmate/docker-compose.build.rs-dapi.yml
📚 Learning: 2024-11-13T12:30:16.951Z
Learnt from: shumkov
Repo: dashpay/platform PR: 2321
File: Dockerfile:1-1
Timestamp: 2024-11-13T12:30:16.951Z
Learning: In Dockerfiles, specifying `# syntax = docker/dockerfile:1` ensures that the Dockerfile uses the latest `1.x` syntax, which supports advanced features like `RUN --mount` commands with cache mounting.

Applied to files:

  • Dockerfile
📚 Learning: 2024-11-13T10:31:31.084Z
Learnt from: lklimek
Repo: dashpay/platform PR: 2318
File: Dockerfile:160-198
Timestamp: 2024-11-13T10:31:31.084Z
Learning: In the `Dockerfile` for the rs-drive-abci project, when configuring sccache, we do not need to add validation checks for configuration variables, as sccache performs validation at runtime.

Applied to files:

  • Dockerfile
  • packages/dashmate/docker-compose.build.rs-dapi.yml
📚 Learning: 2024-10-09T00:22:57.778Z
Learnt from: shumkov
Repo: dashpay/platform PR: 2184
File: .github/workflows/prebuild-devcontainers.yml:0-0
Timestamp: 2024-10-09T00:22:57.778Z
Learning: In this repository, using a personal access token is necessary for GitHub Actions workflows to push to the GitHub Container Registry because `GITHUB_TOKEN` lacks the required permissions.

Applied to files:

  • Dockerfile
  • packages/dashmate/docker-compose.build.rs-dapi.yml
📚 Learning: 2024-11-13T10:32:02.981Z
Learnt from: lklimek
Repo: dashpay/platform PR: 2318
File: Dockerfile:0-0
Timestamp: 2024-11-13T10:32:02.981Z
Learning: In the Dockerfile's sccache configuration script, the team relies on sccache to validate required arguments, so explicit error handling for missing variables is unnecessary.

Applied to files:

  • Dockerfile
  • packages/dashmate/docker-compose.build.rs-dapi.yml
📚 Learning: 2024-11-25T12:59:11.416Z
Learnt from: lklimek
Repo: dashpay/platform PR: 2344
File: .github/workflows/release-docker-image.yml:66-70
Timestamp: 2024-11-25T12:59:11.416Z
Learning: In the CI workflows (e.g., `.github/workflows/release-docker-image.yml` and `tests-build-image.yml`), we do not add validation steps for cache configuration variables. We rely on the build process to quickly reveal any misconfigurations.

Applied to files:

  • Dockerfile
  • packages/dashmate/docker-compose.build.rs-dapi.yml
📚 Learning: 2024-12-16T08:59:40.337Z
Learnt from: lklimek
Repo: dashpay/platform PR: 2374
File: Dockerfile:117-118
Timestamp: 2024-12-16T08:59:40.337Z
Learning: In our Dockerfiles, using `ONBUILD ARG CARGO_BUILD_PROFILE=dev` works correctly, and `CARGO_BUILD_PROFILE` is recognized in subsequent stages.

Applied to files:

  • Dockerfile
📚 Learning: 2024-11-03T10:39:11.242Z
Learnt from: shumkov
Repo: dashpay/platform PR: 2305
File: packages/rs-drive-abci/src/abci/handler/finalize_block.rs:81-0
Timestamp: 2024-11-03T10:39:11.242Z
Learning: In `packages/rs-drive-abci/src/abci/handler/finalize_block.rs`, the use of `.expect("commit transaction")` after `app.commit_transaction(platform_version)` is intentional due to the provided comment explaining its necessity. Do not flag this usage in future reviews.

Applied to files:

  • Dockerfile
📚 Learning: 2024-11-25T12:59:13.055Z
Learnt from: lklimek
Repo: dashpay/platform PR: 2344
File: Dockerfile:55-58
Timestamp: 2024-11-25T12:59:13.055Z
Learning: In Dockerfile multi-stage builds, variables defined within `RUN` instructions are not available in `FROM` commands in subsequent stages.

Applied to files:

  • Dockerfile
📚 Learning: 2024-11-25T12:59:18.673Z
Learnt from: lklimek
Repo: dashpay/platform PR: 2344
File: .github/workflows/tests-rs-package.yml:30-37
Timestamp: 2024-11-25T12:59:18.673Z
Learning: The `sccache` action exists in the repository at `./.github/actions/sccache`.

Applied to files:

  • Dockerfile
  • packages/dashmate/docker-compose.build.rs-dapi.yml
📚 Learning: 2024-11-25T12:59:11.765Z
Learnt from: lklimek
Repo: dashpay/platform PR: 2344
File: Dockerfile:188-189
Timestamp: 2024-11-25T12:59:11.765Z
Learning: In the `Dockerfile`, when using `echo` with single quotes to write to a file, variable expansion and command substitution do not occur during the build process. Therefore, commands like `echo 'export VAR="$(cat /run/secrets/FILE)"' >> /root/env` do not expose secrets in image layers, as the substitution happens only when the file is sourced at runtime.

Applied to files:

  • Dockerfile
📚 Learning: 2024-12-05T09:29:38.918Z
Learnt from: shumkov
Repo: dashpay/platform PR: 2375
File: packages/rs-drive-abci/Cargo.toml:61-63
Timestamp: 2024-12-05T09:29:38.918Z
Learning: In the `drive-abci` package, avoid adding unused dependencies like `hashbrown` to `Cargo.toml`. The team relies on CI to detect dependency version issues.

Applied to files:

  • Dockerfile
📚 Learning: 2025-11-25T13:10:23.481Z
Learnt from: CR
Repo: dashpay/platform PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-11-25T13:10:23.481Z
Learning: Run Rust tests for packages using `cargo test -p <package_name>` and all Rust tests with `cargo test --workspace`

Applied to files:

  • Dockerfile
📚 Learning: 2025-11-25T13:10:47.943Z
Learnt from: CR
Repo: dashpay/platform PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-11-25T13:10:47.943Z
Learning: Applies to **/*.rs : Follow rustfmt defaults and keep code clippy-clean for Rust modules

Applied to files:

  • Dockerfile
📚 Learning: 2025-11-25T13:10:23.481Z
Learnt from: CR
Repo: dashpay/platform PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-11-25T13:10:23.481Z
Learning: Applies to **/*.rs : Rust code must pass `cargo clippy --workspace` linter checks

Applied to files:

  • Dockerfile
📚 Learning: 2024-10-17T08:52:54.300Z
Learnt from: shumkov
Repo: dashpay/platform PR: 2248
File: packages/rs-drive-abci/src/main.rs:106-111
Timestamp: 2024-10-17T08:52:54.300Z
Learning: In this project, the environment variable `CARGO_PKG_RUST_VERSION` is defined and can be used safely with the `env!` macro.

Applied to files:

  • Dockerfile
📚 Learning: 2025-11-25T13:10:23.481Z
Learnt from: CR
Repo: dashpay/platform PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-11-25T13:10:23.481Z
Learning: Applies to **/*.rs : Rust code must be formatted using `cargo fmt --all`

Applied to files:

  • Dockerfile
📚 Learning: 2025-10-15T14:45:30.856Z
Learnt from: lklimek
Repo: dashpay/platform PR: 2716
File: packages/dashmate/src/test/constants/services.js:4-4
Timestamp: 2025-10-15T14:45:30.856Z
Learning: In the dashmate codebase (packages/dashmate), during the DAPI Rust migration (rs-dapi), the old service keys `dapi_api` and `dapi_core_streams` are intentionally kept in `generateEnvsFactory.js` for backward compatibility even though the test constants in `src/test/constants/services.js` have been updated to use `rs_dapi`. These deprecated keys will be removed in a future PR after the transition is complete.

Applied to files:

  • packages/dashmate/docker-compose.build.rs-dapi.yml
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (5)
  • GitHub Check: Build Docker images (Dashmate helper, dashmate-helper, dashmate-helper) / Build Dashmate helper image
  • GitHub Check: Build Docker images (Drive, drive, drive-abci) / Build Drive image
  • GitHub Check: Build Docker images (RS-DAPI, rs-dapi, rs-dapi) / Build RS-DAPI image
  • GitHub Check: Build JS packages / Build JS
  • GitHub Check: Rust crates security audit
🔇 Additional comments (4)
packages/dashmate/docker-compose.build.rs-dapi.yml (1)

18-19: LGTM! Secret configuration is correct.

The build secret configuration properly exposes the optional GITHUB_TOKEN to the Docker build process. The top-level secrets declaration correctly maps the environment variable, enabling authenticated GitHub requests during builds to increase API rate limits from 60 to 5000 requests/hour.

Also applies to: 26-28

Dockerfile (3)

174-177: Good documentation of the optional GITHUB_TOKEN secret.

The comment clearly documents the purpose and optional nature of the GITHUB_TOKEN secret for increasing API rate limits during local builds.


434-434: Cargo git cache sharing=locked changes are correct.

Changing the cargo git cache from sharing=shared to sharing=locked prevents concurrent write corruption of Cargo's git database during parallel builds. This is a correctness fix separate from the GitHub token authentication feature. The registry caches appropriately remain sharing=shared.

Note: The tradeoff is serialized git access which may increase queueing in CI matrix builds, but this prevents corrupted git cache state.

Based on learnings: This aligns with Rust best practices where cargo's git cache requires exclusive access.

Also applies to: 512-512, 552-552, 615-615, 778-778, 848-848


436-436: Good use of Docker secrets for GITHUB_TOKEN.

Using --mount=type=secret,id=GITHUB_TOKEN instead of build ARGs properly prevents the token from appearing in image history or intermediate layers. The conditional usage pattern (checking if the secret file exists) is appropriate for an optional token.

Based on learnings: In the Dockerfile, credentials are managed by Docker secret mounts, addressing the security concerns from previous reviews.

Also applies to: 554-554, 780-780

Comment thread Dockerfile Resolved

@lklimek lklimek left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM, tested locally and works :)

@QuantumExplorer
QuantumExplorer merged commit 02ba330 into v3.0-dev Dec 19, 2025
@QuantumExplorer
QuantumExplorer deleted the feat/token-in-dockerfile branch December 19, 2025 14:01
@thephez thephez added this to the v3.0 milestone Dec 22, 2025
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.

4 participants