Skip to content

Dockerfile: optimize layers#10103

Open
marcofranssen wants to merge 1 commit intofluent:masterfrom
marcofranssen:optimize-dockerfile
Open

Dockerfile: optimize layers#10103
marcofranssen wants to merge 1 commit intofluent:masterfrom
marcofranssen:optimize-dockerfile

Conversation

@marcofranssen
Copy link
Copy Markdown

@marcofranssen marcofranssen commented Mar 19, 2025


Enter [N/A] in the box, if an item is not applicable to your change.

Testing
Before we can approve your change; please submit the following in a comment:

  • [N/A] Example configuration file for the change
  • [N/A] Debug log output from testing the change
  • [N/A] Attached Valgrind output that shows no leaks or memory corruption was found

If this is a change to packaging of containers or native binaries then please confirm it works for all targets.

  • [N/A] Run local packaging test showing all targets (including any new ones) build.
  • [N/A] Set ok-package-test label to test for all targets (requires maintainer to do).

Documentation

  • [N/A] Documentation required for this feature

Backporting

  • [N/A] Backport to latest stable release.

Fluent Bit is licensed under Apache 2.0, by submitting this pull request I understand that this code will be released under the terms of that license.

Summary by CodeRabbit

  • Chores
    • Optimized container build to reduce intermediate layers, yielding faster builds and smaller images.
    • Ensured runtime libraries are present in the production image for reliable operation.
    • Exposed service on port 2020 and moved default startup to the production image for improved accessibility.
    • Reordered debug image build without changing its runtime behavior.

Comment thread dockerfiles/Dockerfile
FROM gcr.io/distroless/cc-debian12 AS production
ARG RELEASE_VERSION
ENV FLUENT_BIT_VERSION=${RELEASE_VERSION}
EXPOSE 2020
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Moved up, as this is not likely to change, meaning the layer doesn't have to be rebuild,pushed,pulled.

@marcofranssen
Copy link
Copy Markdown
Author

Rebased on top of master branch and fixed following small mistake.

UndefinedVar: Usage of undefined variable '$RELEASE_VERSION'
More info: https://docs.docker.com/go/dockerfile/rule/undefined-var/

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Sep 7, 2025

This PR is stale because it has been open 45 days with no activity. Remove stale label or comment or this will be closed in 10 days.

@marcofranssen
Copy link
Copy Markdown
Author

marcofranssen commented Nov 4, 2025

I rebased the PR on latest main. Can someone please have a look at this one?

@patrick-stephens what is holding back from getting this one merged?

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Nov 4, 2025

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 2a0afdea-68f3-4bf7-a27b-f136a1f803fd

📥 Commits

Reviewing files that changed from the base of the PR and between e39e92e and 58db9c9.

📒 Files selected for processing (1)
  • dockerfiles/Dockerfile
🚧 Files skipped from review as they are similar to previous changes (1)
  • dockerfiles/Dockerfile

📝 Walkthrough

Walkthrough

Refactored dockerfiles/Dockerfile to consolidate build ARG/ENV blocks, chain build/install steps to reduce layers, reorder multi-stage stages (debug/production), add EXPOSE 2020 to production, and ensure libraries/certificates are copied from the deb-extractor stage into production.

Changes

Cohort / File(s) Summary
Docker build optimization
dockerfiles/Dockerfile
Consolidated FLB_NIGHTLY_BUILD/FLB_CHUNK_TRACE and WAMR_BUILD_TARGET/EXTRA_CMAKE_FLAGS ARG/ENV declarations; moved DEBIAN_FRONTEND into builder env; chained make and install into single RUN to reduce layers; reordered debug stage and relocated its CMD; added EXPOSE 2020 and moved ENTRYPOINT/default CMD into production; added COPY --from=deb-extractor /dpkg / after certs to ensure libs present.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Suggested labels

ci/integration-docker-ok

Suggested reviewers

  • niedbalski
  • celalettin1286
  • patrick-stephens

Poem

🐰 Layers trimmed and args entwined,
One build stream now sleek and kind,
Ports exposed and copies made,
Debug hops earlier in the glade,
I nibble changes — neat and spry! 🥕

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'Dockerfile: optimize layers' directly and accurately summarizes the main change—reducing build layers in the Dockerfile through various optimizations.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

@github-actions github-actions Bot removed the Stale label Nov 17, 2025
@github-actions
Copy link
Copy Markdown
Contributor

This PR is stale because it has been open 45 days with no activity. Remove stale label or comment or this will be closed in 10 days.

@github-actions github-actions Bot added the Stale label Feb 19, 2026
Squashed some layers to reduce the amount of layers in the image. Also rearranged some layers to reduce the amount of layers that have to be rebuild.

If one layer changes all layers after have to be updated. By moving the ones least likely to change first this means less layers have to be rebuild, pushed and pulled on new releases.

Signed-off-by: Marco Franssen <marco.franssen@gmail.com>
@marcofranssen
Copy link
Copy Markdown
Author

Took another turn rebasing it and resolving the conflicts.

@github-actions github-actions Bot removed the Stale label Apr 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants