Skip to content

fix: update Dockerfile and .dockerignore for SBT 2 stage path#31

Merged
rabestro merged 1 commit into
mainfrom
bug/sbt2-stage-path
Jul 7, 2026
Merged

fix: update Dockerfile and .dockerignore for SBT 2 stage path#31
rabestro merged 1 commit into
mainfrom
bug/sbt2-stage-path

Conversation

@rabestro

@rabestro rabestro commented Jul 7, 2026

Copy link
Copy Markdown
Owner

SBT 2 changed the output path for sbt-native-packager's stage task from target/universal/stage to target/out/jvm///universal/stage.

  • Use dynamic path lookup in Dockerfile to find the stage directory
  • Update .dockerignore to ignore target/ broadly and re-include target/out/

Fixes GitHub Actions build failure due to missing stage directory after migrating from SBT 1 to SBT 2.

@coderabbitai

coderabbitai Bot commented Jul 7, 2026

Copy link
Copy Markdown

Warning

Review limit reached

@rabestro, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 35 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 056eace8-d68a-47c1-ae0e-de4d18dc4b41

📥 Commits

Reviewing files that changed from the base of the PR and between 305e2f6 and eb958a1.

📒 Files selected for processing (1)
  • Dockerfile

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.

@github-actions github-actions Bot added bug Something is not working infrastructure Docker and deployment configurations labels Jul 7, 2026

@gemini-code-assist gemini-code-assist 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.

Code Review

This pull request modifies the Docker build configuration by un-ignoring the target/out/ directory in .dockerignore and creating a symbolic link to the staged build directory in the Dockerfile. The review feedback correctly points out that the .dockerignore change is ineffective because the parent target/ directory is already excluded, and it advises against using a fragile find and ln -s combination in the Dockerfile, recommending a more robust cp command instead.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment thread .dockerignore Outdated
target/
project/target/
project/project/
!target/out/

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

high

There are two issues with adding !target/out/ here:

  1. Ineffectiveness: In .dockerignore, once a parent directory (like target/ on line 3) is excluded, Docker will not traverse into it to evaluate negation patterns. Therefore, !target/out/ has no effect as written.
  2. Conceptual/Performance Issue: As noted in the comments on lines 1-2, this multi-stage build compiles from scratch inside the container. Uploading the host's target/out/ directory to the Docker daemon is unnecessary, increases the build context size, slows down the build, and can invalidate Docker's build cache.

Since the Dockerfile runs sbt stage to compile and stage the application from scratch, we should keep target/ completely ignored and remove this negation line.

Comment thread Dockerfile Outdated
Comment on lines +23 to +26
GITHUB_TOKEN=$(cat /run/secrets/github_token) sbt stage && \
mkdir -p /build/target/universal && \
STAGE_DIR="$(find /build/target/out -type d -path '*/universal/stage')" && \
ln -s "$STAGE_DIR" /build/target/universal/stage

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

Using find with a shell variable and ln -s can be fragile. If find returns multiple paths (e.g., if multiple Scala versions or subprojects are built) or no paths at all, the ln -s command will fail.

Additionally, using symbolic links across multi-stage Docker builds can sometimes lead to issues during COPY --from if the symlink is not resolved correctly.

A more robust and simpler approach is to use standard shell wildcard expansion to copy the directory directly.

    GITHUB_TOKEN=$(cat /run/secrets/github_token) sbt stage && \
    mkdir -p /build/target/universal && \
    cp -a /build/target/out/jvm/*/*/universal/stage /build/target/universal/

@rabestro rabestro self-assigned this Jul 7, 2026
SBT 2 changed the output path for sbt-native-packager's stage task from
target/universal/stage to target/out/jvm/<scala-version>/<project>/universal/stage.

- Use cp -a to copy the stage directory from the new SBT 2 path to the expected location
- Keep .dockerignore clean by ignoring target/ entirely

Fixes GitHub Actions build failure due to missing stage directory after migrating from SBT 1 to SBT 2.
@rabestro rabestro force-pushed the bug/sbt2-stage-path branch from 8a1ee3a to eb958a1 Compare July 7, 2026 21:18
@rabestro rabestro merged commit 0456504 into main Jul 7, 2026
3 checks passed
@rabestro rabestro deleted the bug/sbt2-stage-path branch July 7, 2026 21:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something is not working infrastructure Docker and deployment configurations

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant