feat: add multi-stage production Dockerfile#20
Conversation
Add Dockerfile.release for minimal production images. Uses multi-stage build: compile in full builder, copy only binary + runtime shared libs into clean Debian image. Defaults to Release build type. Also fix missing VM_HOST env var in dbz-twin RAC docker-compose.yaml, broken since 7696dfc.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughAdds Changes
Sequence Diagram(s)mermaid CI->>Builder: build with ARGs (WITHORACLE, WITHKAFKA, WITHPROTOBUF, WITHPROMETHEUS, UIDOLR/GIDOLR...) Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
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: 1
🧹 Nitpick comments (3)
Dockerfile.release (3)
50-54: Consider adding--no-install-recommendsfor faster builds.While this builder stage is discarded, using
--no-install-recommendswould reduce build time and layer size during the build process.♻️ Proposed fix
RUN set -eu && \ apt-get update && \ - apt-get -y install file gcc g++ libaio1t64 libasan8 libubsan1 libtool libz-dev make patch unzip wget cmake git curl && \ + apt-get -y install --no-install-recommends file gcc g++ libaio1t64 libasan8 libubsan1 libtool libz-dev make patch unzip wget cmake git curl && \ ln -s libaio.so.1t64 /usr/lib/x86_64-linux-gnu/libaio.so.1🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@Dockerfile.release` around lines 50 - 54, The apt-get install command in the RUN step that installs system packages should use the --no-install-recommends flag to avoid pulling unnecessary recommended packages and speed up builds; update the RUN command that calls apt-get -y install (the line installing file gcc g++ libaio1t64 libasan8 libubsan1 libtool libz-dev make patch unzip wget cmake git curl and the ln -s step) to include --no-install-recommends (and optionally follow with apt-get clean && rm -rf /var/lib/apt/lists/* in the same RUN to reduce image layer size).
93-94: Consider parallel builds for faster compilation.The protobuf
makeruns single-threaded while prometheus (line 121) uses--parallel 4. Usingmake -j$(nproc)would speed up builds significantly.♻️ Proposed fix for protobuf
./configure --prefix=/opt/protobuf && \ - make && \ + make -j$(nproc) && \ make install ; \Same applies to librdkafka at lines 106-107.
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@Dockerfile.release` around lines 93 - 94, Replace the single-threaded build invocations for protobuf and librdkafka by running make with parallelism; specifically update the occurrences of "make && \ make install ; \" (the protobuf build block) and the librdkafka "make && make install" invocations to use "make -j$(nproc)" (or another parallel flag) so compilation uses all available CPUs and matches the existing prometheus "--parallel 4" approach.
56-82: Future consideration: consolidate duplicated build logic with Dockerfile.dev.The RapidJSON and Oracle Instant Client build steps are nearly identical to
Dockerfile.dev(context snippets show ~100% duplication). Consider extracting shared build scripts or using a common builder base image to reduce maintenance burden.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@Dockerfile.release` around lines 56 - 82, The RapidJSON and Oracle Instant Client RUN blocks duplicate logic from Dockerfile.dev; extract those steps into shared artifacts and replace the inline blocks with simple invocations: either move the RapidJSON and Oracle install commands (the RUN sequences using RAPIDJSON_VERSION, the rapidjson patch step, and the COMPILEORACLE/ORACLE_MAJOR/ORACLE_MINOR instantclient logic) into reusable shell scripts (e.g., scripts/install_rapidjson.sh and scripts/install_oracle.sh) and call them from both Dockerfiles, or create a common builder/base image that performs those installs and then FROM that image in both Dockerfile.release and Dockerfile.dev; ensure ARGs (RAPIDJSON_VERSION, COMPILEORACLE, ORACLE_MAJOR, ORACLE_MINOR) are preserved and the rapidjson patch step is kept when RAPIDJSON_VERSION == "1.1.0".
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@Dockerfile.release`:
- Line 222: The Dockerfile unconditionally sets USER user1:oracle which fails
when GIDOLR == GIDORA because the oracle group isn't created; either make the
USER fallback to user1 (no group) when the oracle group wasn't created or ensure
the oracle group is always created when creating user1. Locate the USER
user1:oracle statement and change the logic so it checks whether the oracle
group was actually created (based on the GIDOLR vs GIDORA condition) and only
uses user1:oracle when the group exists, otherwise use just user1; alternatively
modify the earlier group-creation branch (the code that handles GIDOLR/GIDORA)
to always create the oracle group so USER user1:oracle is safe.
---
Nitpick comments:
In `@Dockerfile.release`:
- Around line 50-54: The apt-get install command in the RUN step that installs
system packages should use the --no-install-recommends flag to avoid pulling
unnecessary recommended packages and speed up builds; update the RUN command
that calls apt-get -y install (the line installing file gcc g++ libaio1t64
libasan8 libubsan1 libtool libz-dev make patch unzip wget cmake git curl and the
ln -s step) to include --no-install-recommends (and optionally follow with
apt-get clean && rm -rf /var/lib/apt/lists/* in the same RUN to reduce image
layer size).
- Around line 93-94: Replace the single-threaded build invocations for protobuf
and librdkafka by running make with parallelism; specifically update the
occurrences of "make && \ make install ; \" (the protobuf build block) and the
librdkafka "make && make install" invocations to use "make -j$(nproc)" (or
another parallel flag) so compilation uses all available CPUs and matches the
existing prometheus "--parallel 4" approach.
- Around line 56-82: The RapidJSON and Oracle Instant Client RUN blocks
duplicate logic from Dockerfile.dev; extract those steps into shared artifacts
and replace the inline blocks with simple invocations: either move the RapidJSON
and Oracle install commands (the RUN sequences using RAPIDJSON_VERSION, the
rapidjson patch step, and the COMPILEORACLE/ORACLE_MAJOR/ORACLE_MINOR
instantclient logic) into reusable shell scripts (e.g.,
scripts/install_rapidjson.sh and scripts/install_oracle.sh) and call them from
both Dockerfiles, or create a common builder/base image that performs those
installs and then FROM that image in both Dockerfile.release and Dockerfile.dev;
ensure ARGs (RAPIDJSON_VERSION, COMPILEORACLE, ORACLE_MAJOR, ORACLE_MINOR) are
preserved and the rapidjson patch step is kept when RAPIDJSON_VERSION ==
"1.1.0".
🪄 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: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: e8d2a558-5705-460d-8706-a114e0cf0dfb
📒 Files selected for processing (2)
Dockerfile.releasetests/dbz-twin/rac/docker-compose.yaml
- Fix USER directive: use 'user1' instead of 'user1:oracle' since the oracle group is not created when GIDOLR == GIDORA - Add --no-install-recommends to builder apt-get
Summary
Dockerfile.releasefor minimal production images using multi-stage buildBUILD_TYPE=ReleaseVM_HOSTenv var intests/dbz-twin/rac/docker-compose.yaml(broken since 7696dfc)Test plan
docker buildx build -f Dockerfile.releasewith all modules enabled--versionprints correct build info (Release, all modules)docker save/podman load(339 MB compressed)Summary by CodeRabbit