Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: switch docker base image, use system rocksdb for faster compilation #487

Merged
merged 9 commits into from
Oct 22, 2024

Conversation

tedil
Copy link
Contributor

@tedil tedil commented Oct 8, 2024

Solves #486

Summary by CodeRabbit

  • New Features

    • Updated workflows to utilize Ubuntu 24.04 for improved compatibility and performance.
    • Added a new step in the cargo-release job to install necessary dependencies.
    • Introduced a new step to set up Python in the Protobuf workflow.
  • Bug Fixes

    • Enhanced the Dockerfile to streamline the build environment and ensure proper installation of dependencies.

Copy link
Contributor

coderabbitai bot commented Oct 8, 2024

Walkthrough

The changes in this pull request involve updating several workflow files to use ubuntu-24.04 as the operating system for job execution instead of ubuntu-latest. Notably, the .github/workflows/release-please.yml file has added a new step in the cargo-release job to install dependencies like librocksdb-dev. Additionally, the Dockerfile has been modified to use ubuntu:noble as the base image and includes updated installation commands to enhance the build environment.

Changes

File Change Summary
.github/workflows/automerge.yml Updated runs-on from ubuntu-latest to ubuntu-24.04 for the dependabot job.
.github/workflows/conventional-prs.yml Updated runs-on from ubuntu-latest to ubuntu-24.04 for the title-format job.
.github/workflows/docker-build.yml Updated runs-on from ubuntu-latest to ubuntu-24.04 for build and push jobs.
.github/workflows/release-please.yml Updated runs-on from ubuntu-latest to ubuntu-24.04 for multiple jobs; added a step to install dependencies in cargo-release.
.github/workflows/rust.yml Updated runs-on from ubuntu-latest to ubuntu-24.04 for Formatting, Linting, and Testing jobs; added a step to install dependencies in Linting.
.github/workflows/protobuf.yml Updated runs-on from ubuntu-latest to ubuntu-24.04 for Linting job; added a step to set up Python 3.12.
utils/docker/Dockerfile Changed base images to ubuntu:noble, updated installation commands for dependencies, and streamlined build commands.

Poem

In the fields of code, we leap with glee,
Ubuntu's embrace sets our projects free.
With dependencies gathered, our builds take flight,
A hop and a skip, we code through the night! 🐇🌙
Together we flourish, with each new dawn,
In the garden of software, our dreams carry on!


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 5

🧹 Outside diff range and nitpick comments (5)
.github/workflows/release-please.yml (2)

40-43: Approve with minor suggestions for improvement

The addition of this step to install librocksdb-dev aligns well with the PR objective of using system RocksDB for faster compilation. This should indeed help in reducing build times.

A couple of minor suggestions:

  1. The -y flag is unnecessary for apt-get update as it doesn't prompt for confirmation. You can simplify it to sudo apt-get update.
  2. Consider adding error handling or at least using set -e to ensure the workflow fails if the package installation encounters any issues.

Here's a slightly improved version:

- name: Install dependencies
  run: |
    set -e
    sudo apt-get update
    sudo apt-get install -y librocksdb-dev

40-43: Consider broader implications of this change

The addition of the RocksDB system package is a positive change that should improve build times. However, consider the following points for the broader project:

  1. Consistency: Are there other jobs or workflows in the project that could benefit from using the system RocksDB? It might be worth reviewing other CI/CD processes to ensure consistency.

  2. Documentation: Ensure that the README, contribution guidelines, or any relevant documentation is updated to reflect this change in the build process. This will help other contributors understand the new build requirements.

README.md (2)

365-372: LGTM: Clear instructions for installing rocksdb

The instructions for installing rocksdb using both Ubuntu's package manager and Conda are clear and accurate. This covers two common scenarios, making it easier for developers to set up their environment.

Consider adding a note about potential variations in package names or availability across different Ubuntu versions or other Linux distributions.


389-397: LGTM: Clear build and installation instructions

The instructions for building and installing the project are clear, concise, and use appropriate flags (--release for building and --path . for local installation).

Consider adding a brief explanation of what the --release flag does (e.g., "builds with optimizations") and why it's recommended for this project. This would be helpful for developers who are less familiar with Cargo.

utils/docker/Dockerfile (1)

Line range hint 63-67: Optimize layer caching and image size

Combine the cleanup commands into a single RUN statement to reduce the number of layers and optimize the image size. Also, consider using --no-install-recommends with apt-get install to prevent the installation of unnecessary packages.

Apply this diff to optimize the installation and cleanup steps:

 RUN apt-get update && \
-    apt-get install -y libsqlite3-0 && \
-    apt-get clean autoclean && \
-    apt-get autoremove --yes && \
+    apt-get install -y --no-install-recommends libsqlite3-0 && \
+    apt-get clean && \
     rm -rf /var/lib/{apt,dpkg,cache,log} /var/lib/apt/lists/*
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between c5a46ac and 88cfb62.

📒 Files selected for processing (3)
  • .github/workflows/release-please.yml (1 hunks)
  • README.md (1 hunks)
  • utils/docker/Dockerfile (2 hunks)
🧰 Additional context used
🪛 LanguageTool
README.md

[uncategorized] ~379-~379: “to” seems less likely than “do”.
Context: ..._DIR = "/usr/lib/" # same as above ``` to .cargo/config.toml or set the environ...

(AI_HYDRA_LEO_CP_TO_DO)

🔇 Additional comments (2)
README.md (2)

362-364: LGTM: Clear introduction to building from scratch

The new section title and introductory sentence effectively explain the purpose of the following instructions, which is to reduce compile times using pre-built versions of rocksdb.


362-397: Great addition to the README: Comprehensive build instructions

These new instructions for building the project from scratch are a valuable addition to the README. They align well with the PR objective of switching the Docker base image and using system rocksdb for faster compilation. The step-by-step guide covers dependency installation, configuration options, and build/installation process, making it easier for developers to set up their environment efficiently.

The instructions are well-structured, clear, and cover multiple scenarios (Ubuntu and Conda). This addition will significantly improve the developer experience and potentially reduce issues related to build setup.

🧰 Tools
🪛 LanguageTool

[uncategorized] ~379-~379: “to” seems less likely than “do”.
Context: ..._DIR = "/usr/lib/" # same as above ``` to .cargo/config.toml or set the environ...

(AI_HYDRA_LEO_CP_TO_DO)

Comment on lines +374 to +389
In either case, either add
```toml
[env]
ROCKSDB_LIB_DIR = "/usr/lib/" # in case of the system package manager, adjust the path accordingly for conda
SNAPPY_LIB_DIR = "/usr/lib/" # same as above
```
to `.cargo/config.toml` or set the environment variables `ROCKSDB_LIB_DIR` and `SNAPPY_LIB_DIR` to the appropriate paths:

```bash
export ROCKSDB_LIB_DIR=/usr/lib/
export SNAPPY_LIB_DIR=/usr/lib/
```

By default, the environment variables are defined in the `.cargo/config.toml` as described above, i.e. may need adjustments if not using the system package manager.

To build the project, run:
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

LGTM with a minor correction: Clear configuration instructions

The instructions for configuring the build environment using either .cargo/config.toml or environment variables are clear and provide flexibility for different setups. The note about default values in .cargo/config.toml is helpful for users to understand the existing configuration.

There's a minor typo in the comment on line 379. It should be "do" instead of "to". Please apply the following change:

-SNAPPY_LIB_DIR = "/usr/lib/"  # same as above
+SNAPPY_LIB_DIR = "/usr/lib/"  # do same as above

Committable suggestion was skipped due to low confidence.

🧰 Tools
🪛 LanguageTool

[uncategorized] ~379-~379: “to” seems less likely than “do”.
Context: ..._DIR = "/usr/lib/" # same as above ``` to .cargo/config.toml or set the environ...

(AI_HYDRA_LEO_CP_TO_DO)

RUN cargo build --release

# Build the application
RUN /root/.cargo/bin/cargo build --release
Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Simplify the Cargo build command

Avoid hardcoding the path to the Cargo binary. Since Rust's bin directory is added to the PATH, you can invoke cargo directly.

Apply this diff to simplify the build command:

-RUN /root/.cargo/bin/cargo build --release
+RUN cargo build --release
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
RUN /root/.cargo/bin/cargo build --release
RUN cargo build --release


# ---------------------------------------------------------------------------
# Runtime
# ---------------------------------------------------------------------------

FROM debian:bookworm-slim AS runtime
FROM ubuntu:noble AS runtime
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Align runtime base image with a stable release

Using ubuntu:noble as the runtime base image may lead to compatibility issues if noble is not an officially released or stable version. For consistency and reliability, consider using the same stable LTS version as in the builder stage.

Apply this diff to update the runtime base image:

-FROM ubuntu:noble AS runtime
+FROM ubuntu:22.04 AS runtime
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
FROM ubuntu:noble AS runtime
FROM ubuntu:22.04 AS runtime

Comment on lines +16 to +17
# Use ubuntu:noble as the base image
FROM ubuntu:noble AS builder
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Consider using a stable Ubuntu LTS base image

Switching the base image to ubuntu:noble might introduce instability if noble is not a long-term support (LTS) release or is still under development. For enhanced stability and support, consider using an LTS version like ubuntu:22.04.

Apply this diff to change the base image to an LTS version:

-FROM ubuntu:noble AS builder
+FROM ubuntu:22.04 AS builder
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
# Use ubuntu:noble as the base image
FROM ubuntu:noble AS builder
# Use ubuntu:22.04 as the base image
FROM ubuntu:22.04 AS builder

Comment on lines +21 to +24
apt-get install -y unzip wget curl build-essential clang librocksdb-dev libsqlite3-dev && \
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y && \
. $HOME/.cargo/env && \
rustup component add rustfmt
Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Ensure Rust and its environment are properly installed

Manually installing Rust using the curl script requires careful handling to set up the environment correctly. To ensure that Rust is available in subsequent commands without sourcing the environment every time, consider adding Rust to the PATH globally.

Apply this diff to update the Rust installation:

 RUN apt-get update && \
     apt-get install -y unzip wget curl build-essential clang librocksdb-dev libsqlite3-dev && \
     curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y && \
-    . $HOME/.cargo/env && \
+    echo 'source $HOME/.cargo/env' >> /root/.bashrc && \
     rustup component add rustfmt

This change adds the Rust environment to the .bashrc file, ensuring that it's loaded in all subsequent steps.

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
apt-get install -y unzip wget curl build-essential clang librocksdb-dev libsqlite3-dev && \
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y && \
. $HOME/.cargo/env && \
rustup component add rustfmt
apt-get install -y unzip wget curl build-essential clang librocksdb-dev libsqlite3-dev && \
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y && \
echo 'source $HOME/.cargo/env' >> /root/.bashrc && \
rustup component add rustfmt

Copy link

codecov bot commented Oct 8, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 73%. Comparing base (0bf9316) to head (0bc5f0d).
Report is 15 commits behind head on main.

Additional details and impacted files
@@          Coverage Diff           @@
##           main    #487     +/-   ##
======================================
- Coverage    74%     73%     -2%     
======================================
  Files        42      43      +1     
  Lines      7365   11648   +4283     
======================================
+ Hits       5470    8514   +3044     
- Misses     1895    3134   +1239     

see 43 files with indirect coverage changes

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🧹 Outside diff range and nitpick comments (2)
.github/workflows/rust.yml (2)

35-35: Approve changes with suggestions for improvement.

The update to Ubuntu 24.04 and the addition of dependency installation are good improvements. However, there are a couple of suggestions:

  1. Remove sudo from the apt commands as GitHub Actions runners already have root privileges.
  2. Consider using apt-get install -y --no-install-recommends to minimize the image size.

Here's a suggested improvement for the dependency installation step:

 - name: Install dependencies
   run: |
-    sudo apt-get update -y
-    sudo apt-get install -y librocksdb-dev libsnappy-dev libsqlite3-dev
+    apt-get update -y
+    apt-get install -y --no-install-recommends librocksdb-dev libsnappy-dev libsqlite3-dev
+    rm -rf /var/lib/apt/lists/*

This change removes sudo, adds --no-install-recommends, and cleans up apt lists to reduce the image size.

Also applies to: 40-43


Line range hint 1-94: Overall approval with suggestions for further improvements.

The changes to update all jobs to Ubuntu 24.04 and add explicit dependency installation for the Linting job are good improvements. They provide a more consistent and controlled CI environment. However, consider the following suggestions:

  1. Review if similar dependency installation steps are needed for the Formatting and Testing jobs. This would ensure all jobs have the necessary dependencies explicitly defined.
  2. Consider creating a composite action or using a setup-rust action that includes all necessary dependencies. This could help reduce duplication and simplify maintenance of the workflow file.

To implement these suggestions, you could:

  1. Add similar dependency installation steps to the Formatting and Testing jobs if needed.
  2. Create a composite action in your repository (e.g., .github/actions/setup-rust-env/action.yml) that includes all the common setup steps (installing Rust, protoc, and dependencies). Then use this action in each job.

Example of using a composite action:

- uses: ./.github/actions/setup-rust-env

This approach can significantly simplify your workflow file and make it easier to maintain consistent environments across jobs.

🧰 Tools
🪛 actionlint

46-46: the runner of "actions-rs/toolchain@v1" action is too old to run on GitHub Actions. update the action's version to fix this issue

(action)

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 88cfb62 and 4f11a7d.

📒 Files selected for processing (5)
  • .github/workflows/automerge.yml (1 hunks)
  • .github/workflows/conventional-prs.yml (1 hunks)
  • .github/workflows/docker-build.yml (1 hunks)
  • .github/workflows/release-please.yml (3 hunks)
  • .github/workflows/rust.yml (3 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • .github/workflows/release-please.yml
🧰 Additional context used
🔇 Additional comments (3)
.github/workflows/conventional-prs.yml (1)

12-12: Approved: Update to Ubuntu 24.04 for consistency and stability

The change from ubuntu-latest to ubuntu-24.04 aligns with the PR objectives and provides more stability to the CI/CD pipeline. This update ensures a consistent environment across different workflows and prevents unexpected changes when new Ubuntu versions are released.

To ensure compatibility, please verify that all tools and dependencies used in this workflow are compatible with Ubuntu 24.04. You can run the following script to check the workflow's execution:

If the conclusion is "success", it confirms that the workflow is compatible with Ubuntu 24.04.

.github/workflows/rust.yml (2)

64-64: Approve OS version update with a suggestion for testing.

The update to Ubuntu 24.04 for the Testing job is consistent with the other jobs, which is good. However, please ensure that all required dependencies for testing, including those used by cargo-tarpaulin, are available in Ubuntu 24.04.

To verify the availability of required packages for testing, you can run:

#!/bin/bash
# Description: Check if required packages for testing are available in Ubuntu 24.04

# Test: Check if cargo-tarpaulin dependencies are available
apt-cache search libssl-dev
apt-cache search pkg-config

# Test: Check if any Rust-related packages are available
apt-cache search rust-all

13-13: Approve OS version update with a suggestion.

Updating to a specific Ubuntu version (24.04) is a good practice for consistency. However, please ensure that all required dependencies for the Formatting job are available in Ubuntu 24.04.

To verify the availability of required packages, you can run:

.github/workflows/automerge.yml Show resolved Hide resolved
@@ -18,7 +18,7 @@ env:

jobs:
build-and-push-image:
runs-on: ubuntu-latest
runs-on: ubuntu-24.04
Copy link
Contributor

Choose a reason for hiding this comment

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

💡 Codebase verification

Update Required: protobuf.yml Still Uses ubuntu-latest

The script identified that .github/workflows/protobuf.yml is still configured to run on ubuntu-latest. To maintain consistent workflow environments, please update this file to use ubuntu-24.04 as well.

  • File to Update:
    • .github/workflows/protobuf.yml
🔗 Analysis chain

Approve the update to Ubuntu 24.04, but verify consistency across workflows

The change from ubuntu-latest to ubuntu-24.04 is in line with the PR objectives to switch the Docker base image. This update ensures a consistent and predictable environment for the workflow execution.

To ensure consistency across all workflow files, please run the following script:

If the script returns any results, consider updating those files to use ubuntu-24.04 as well for consistency.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check if all workflow files use ubuntu-24.04

# Test: Search for any occurrences of ubuntu-latest in workflow files
rg --type yaml 'runs-on:.*ubuntu-latest' .github/workflows

Length of output: 118

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Outside diff range and nitpick comments (1)
utils/docker/Dockerfile (1)

50-55: Approve touch command and simplify Cargo build

The touch command is a good practice to ensure fresh builds. However, the Cargo build command can be simplified.

Apply this diff to simplify the Cargo build command:

 # Touch main.rs to prevent cached release build.
 RUN touch /usr/src/varfish-server-worker/src/main.rs

 # Build the application
-RUN /root/.cargo/bin/cargo build --release
+RUN cargo build --release
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 4f11a7d and 19f5e48.

📒 Files selected for processing (3)
  • .github/workflows/protobuf.yml (1 hunks)
  • .github/workflows/rust.yml (4 hunks)
  • utils/docker/Dockerfile (3 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • .github/workflows/rust.yml
🧰 Additional context used
🔇 Additional comments (8)
.github/workflows/protobuf.yml (3)

13-13: Approve the update to Ubuntu 24.04

Updating the runner to use ubuntu-24.04 instead of ubuntu-latest is a good practice. It provides more consistency and predictability in the CI environment, which aligns with the PR's objective of updating the base image (although this is for GitHub Actions, not Docker).


Line range hint 1-30: Consistency with PR objectives

The changes in this file partially align with the PR objectives by updating the base environment (GitHub Actions runner) to a specific Ubuntu version. However, there are no changes related to RocksDB or Docker in this file. This is not necessarily an issue, as those changes might be in other files not provided for this review.

To ensure all objectives are met, please confirm that RocksDB and Docker-related changes are present in other files of this PR. You can use the following command to check for RocksDB-related changes:

#!/bin/bash
# Check for RocksDB-related changes in the PR
git diff origin/main...HEAD | grep -i rocksdb

18-21: Verify Python version requirement

The addition of a specific Python setup step is a good practice for ensuring a consistent environment. However, it's important to verify if Python 3.12 is necessary for this workflow, particularly for protolint-bin.

Could you confirm if Python 3.12 is required for protolint-bin or if there are any other dependencies in this workflow that specifically need this version? If not, consider using a slightly older but still well-supported version like 3.10 or 3.11 for better compatibility.

To verify the Python version requirement, you can run:

utils/docker/Dockerfile (5)

21-24: Approve additional packages and improve Rust installation

The addition of system packages, especially librocksdb-dev, aligns with the PR objective. However, the Rust installation process can be improved to ensure proper environment setup.

Apply this diff to update the Rust installation:

 RUN apt-get update && \
     apt-get install -y unzip wget curl build-essential clang librocksdb-dev libsqlite3-dev && \
     curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y && \
-    . $HOME/.cargo/env && \
+    echo 'source $HOME/.cargo/env' >> /root/.bashrc && \
     rustup component add rustfmt

This change adds the Rust environment to the .bashrc file, ensuring that it's loaded in all subsequent steps.


16-17: ⚠️ Potential issue

Consider using a stable Ubuntu LTS base image

While switching to Ubuntu aligns with the PR objective, using ubuntu:noble might introduce instability as it's not a long-term support (LTS) release. For enhanced stability and support, consider using an LTS version.

Apply this diff to change the base image to an LTS version:

-FROM ubuntu:noble AS builder
+FROM ubuntu:22.04 AS builder

35-35: 🛠️ Refactor suggestion

Simplify Cargo commands

Using explicit paths to the Cargo binary is unnecessary if the Rust environment is properly set up. Simplifying these commands will make the Dockerfile more maintainable.

Apply this diff to simplify the Cargo commands:

-RUN USER=root /root/.cargo/bin/cargo new varfish-server-worker
+RUN USER=root cargo new varfish-server-worker

-RUN /root/.cargo/bin/cargo build --release
+RUN cargo build --release

Also applies to: 41-41


61-61: ⚠️ Potential issue

Align runtime base image with a stable release

Using ubuntu:noble as the runtime base image may lead to compatibility issues if noble is not an officially released or stable version. For consistency and reliability, consider using the same stable LTS version as in the builder stage.

Apply this diff to update the runtime base image:

-FROM ubuntu:noble AS runtime
+FROM ubuntu:22.04 AS runtime

Line range hint 63-68: Approve cleanup steps and consider adding librocksdb

The cleanup steps after package installation are good practice for reducing the image size. The installation of libsqlite3-0 is appropriate for runtime.

Consider if librocksdb is needed in the runtime image. If it's used by the application, you may need to add it to the installation command.

To verify if librocksdb is needed, run the following script:

If the script returns any results, consider adding librocksdb-dev to the runtime dependencies.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 19f5e48 and d3753f2.

📒 Files selected for processing (1)
  • .github/workflows/rust.yml (4 hunks)
🧰 Additional context used
🪛 actionlint
.github/workflows/rust.yml

63-63: the runner of "actions-rs/clippy-check@v1" action is too old to run on GitHub Actions. update the action's version to fix this issue

(action)

🔇 Additional comments (9)
.github/workflows/rust.yml (9)

13-13: LGTM: Specific Ubuntu version improves reproducibility.

Updating to ubuntu-24.04 instead of using ubuntu-latest is a good practice. It ensures consistent behavior across different runs and improves reproducibility of the CI pipeline.


35-35: LGTM: Consistent use of Ubuntu 24.04.

This change maintains consistency with the Formatting job and aligns with the PR objective.


40-43: LGTM: System dependencies for RocksDB added.

Adding librocksdb-dev, libsnappy-dev, and libsqlite3-dev as system dependencies aligns with the PR objective of using system RocksDB for faster compilation.


57-60: LGTM: Caching librocksdb-sys for improved performance.

Caching the librocksdb-sys directory can significantly improve build times in subsequent runs.


66-66: LGTM: Comprehensive linting with --all-features.

Using --all-features ensures that all code paths are checked during linting, which can help catch potential issues early.


70-70: LGTM: Consistent use of Ubuntu 24.04 across jobs.

This change maintains consistency with the other jobs and aligns with the PR objective.


77-80: LGTM: Consistent system dependencies across jobs.

Adding the same system dependencies as in the Linting job ensures consistency and supports the use of system RocksDB.


93-97: LGTM: Updated caching strategy for improved performance.

The updated caching strategy with a specific key for coverage testing and including librocksdb-sys should improve build times in subsequent runs.


99-107: Verify the switch from cargo-tarpaulin to cargo-llvm-cov.

The change from cargo-tarpaulin to cargo-llvm-cov for code coverage is significant. While both tools are reputable, it's important to ensure this change aligns with the project's needs and doesn't negatively impact coverage reporting.

Please confirm:

  1. Was this change intentional and discussed with the team?
  2. Are there any specific advantages of cargo-llvm-cov over cargo-tarpaulin for this project?
  3. Will this change affect the coverage metrics or how they're interpreted in Codecov?

with:
cache-directories: |
~/.cargo/registry/src/**/librocksdb-sys-*

- name: Lint with clippy
uses: actions-rs/clippy-check@v1
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Update the actions-rs/clippy-check action version.

The static analysis tool has flagged that the runner for the "actions-rs/clippy-check@v1" action is too old to run on GitHub Actions. It's recommended to update the action's version to ensure compatibility and access to the latest features and bug fixes.

Consider updating the action version:

-      - name: Lint with clippy
-        uses: actions-rs/clippy-check@v1
+      - name: Lint with clippy
+        uses: actions-rs/clippy-check@v2

Please verify the latest version available for this action before applying the change.

Committable suggestion was skipped due to low confidence.

🧰 Tools
🪛 actionlint

63-63: the runner of "actions-rs/clippy-check@v1" action is too old to run on GitHub Actions. update the action's version to fix this issue

(action)

@holtgrewe
Copy link
Contributor

@tedil can this be merged?

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between d3753f2 and 0bc5f0d.

📒 Files selected for processing (1)
  • utils/docker/Dockerfile (3 hunks)
🧰 Additional context used

utils/docker/Dockerfile Show resolved Hide resolved
utils/docker/Dockerfile Show resolved Hide resolved
@tedil tedil merged commit 36ff04a into main Oct 22, 2024
9 of 10 checks passed
@tedil tedil deleted the use-system-rocksdb branch October 22, 2024 10:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants