chore: speed up docker build - #3387
Conversation
WalkthroughChangesDocker release build
Sequence Diagram(s)sequenceDiagram
participant ReleaseWorkflow
participant Dockerfile
participant Generator
participant GoBuild
ReleaseWorkflow->>Dockerfile: Pass VERSION
Dockerfile->>Generator: Generate OIDC assets, manifests, and UI
Dockerfile->>GoBuild: Pass TARGETOS, TARGETARCH, and VERSION
GoBuild-->>Dockerfile: Produce target-platform binary
Possibly related PRs
Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
✨ Simplify code
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.
Actionable comments posted: 2
🧹 Nitpick comments (1)
Dockerfile (1)
1-1: 🔒 Security & Privacy | 🔵 Trivial | ⚡ Quick winUpdate the Docker Go builder image.
Dockerfileusesgolang:1.26.1-bookworm, while Go 1.26.5 includes security fixes and patch availability. The builder runsmake manifests, so update its pinned digest to the current patched image; the generator stage is not copied into the runtime image.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@Dockerfile` at line 1, Update the generator stage’s Go builder image from golang:1.26.1-bookworm to golang:1.26.5-bookworm and replace its pinned digest with the current digest for that exact image tag. Keep the existing BUILDPLATFORM usage and generator stage structure unchanged.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@Dockerfile`:
- Line 1: Update the final runtime stage of the Dockerfile to create or use a
non-root user, change /app ownership to that user before switching, and add a
USER directive for runtime execution. Keep any go-offline step before the user
switch if it writes files, and leave the generator stage unchanged.
- Around line 17-18: Preserve the Makefile’s VERSION_TAG fallback by keeping the
Dockerfile VERSION build argument undefined, or update the docker target to pass
--build-arg VERSION="$(VERSION_TAG)" during the build. Align the Docker image’s
version with the tag used by the docker target without introducing a conflicting
Dockerfile default.
---
Nitpick comments:
In `@Dockerfile`:
- Line 1: Update the generator stage’s Go builder image from
golang:1.26.1-bookworm to golang:1.26.5-bookworm and replace its pinned digest
with the current digest for that exact image tag. Keep the existing
BUILDPLATFORM usage and generator stage structure unchanged.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 2ceb8e96-1bce-4904-90ee-4ff8c7a96859
📒 Files selected for processing (3)
.github/workflows/release.ymlDockerfileMakefile
| @@ -1,7 +1,6 @@ | |||
| FROM golang:1.26.1-bookworm@sha256:ab3d6955bbc813a0f3fdf220c1d817dd89c0b3f283777db8ece4a32fe7858edd AS builder | |||
| FROM --platform=$BUILDPLATFORM golang:1.26.1-bookworm@sha256:ab3d6955bbc813a0f3fdf220c1d817dd89c0b3f283777db8ece4a32fe7858edd AS generator | |||
There was a problem hiding this comment.
🔒 Security & Privacy | 🟠 Major | ⚡ Quick win
Run the final image as a non-root user.
Trivy DS-0002 reports that this Dockerfile produces a root user. Add a non-root USER in the final runtime stage. Set /app ownership before switching users. Keep go-offline before the switch if it writes files.
🧰 Tools
🪛 Trivy (0.72.0)
[error] 1-1: Image user should not be 'root'
Specify at least 1 USER command in Dockerfile with non-root user as argument
Rule: DS-0002
(IaC/Dockerfile)
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@Dockerfile` at line 1, Update the final runtime stage of the Dockerfile to
create or use a non-root user, change /app ownership to that user before
switching, and add a USER directive for runtime execution. Keep any go-offline
step before the user switch if it writes files, and leave the generator stage
unchanged.
Source: Linters/SAST tools
Summary by CodeRabbit