fix: update Dockerfile and .dockerignore for SBT 2 stage path#31
Conversation
|
Warning Review limit reached
Next review available in: 35 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the 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. 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. Comment |
There was a problem hiding this comment.
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.
| target/ | ||
| project/target/ | ||
| project/project/ | ||
| !target/out/ |
There was a problem hiding this comment.
There are two issues with adding !target/out/ here:
- Ineffectiveness: In
.dockerignore, once a parent directory (liketarget/on line 3) is excluded, Docker will not traverse into it to evaluate negation patterns. Therefore,!target/out/has no effect as written. - 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.
| 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 |
There was a problem hiding this comment.
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/
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.
8a1ee3a to
eb958a1
Compare
SBT 2 changed the output path for sbt-native-packager's stage task from target/universal/stage to target/out/jvm///universal/stage.
Fixes GitHub Actions build failure due to missing stage directory after migrating from SBT 1 to SBT 2.