-
Notifications
You must be signed in to change notification settings - Fork 1
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
Changes from 1 commit
88cfb62
4f11a7d
4f8f23f
d1eb5b7
2c0f07a
05d01b0
19f5e48
d3753f2
0bc5f0d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -13,18 +13,16 @@ | |||||||||||||||||
# Builder | ||||||||||||||||||
# --------------------------------------------------------------------------- | ||||||||||||||||||
|
||||||||||||||||||
# Pinning Rust version for now because of this issue: | ||||||||||||||||||
# | ||||||||||||||||||
# - https://github.com/rust-lang/rust/issues/95926 | ||||||||||||||||||
FROM rust:1-bookworm AS builder | ||||||||||||||||||
# Use ubuntu:noble as the base image | ||||||||||||||||||
FROM ubuntu:noble AS builder | ||||||||||||||||||
Comment on lines
+16
to
+17
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Consider using a stable Ubuntu LTS base image Switching the base image to 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
Suggested change
|
||||||||||||||||||
|
||||||||||||||||||
# Build dependencies first. | ||||||||||||||||||
# | ||||||||||||||||||
# Install dependencies for compilation of C code (e.g., rocksdb). | ||||||||||||||||||
# Install Rust toolchain and dependencies for compilation of C code (e.g., rocksdb) | ||||||||||||||||||
RUN apt-get update && \ | ||||||||||||||||||
apt-get install -y clang | ||||||||||||||||||
# Add the needed Cargo components. | ||||||||||||||||||
RUN 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 && \ | ||||||||||||||||||
. $HOME/.cargo/env && \ | ||||||||||||||||||
rustup component add rustfmt | ||||||||||||||||||
Comment on lines
+21
to
+24
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 📝 Committable suggestion
Suggested change
|
||||||||||||||||||
|
||||||||||||||||||
# Install build dependency `protoc`. | ||||||||||||||||||
COPY utils/install-protoc.sh /tmp | ||||||||||||||||||
RUN PREFIX=/usr/local bash /tmp/install-protoc.sh | ||||||||||||||||||
|
@@ -49,18 +47,20 @@ COPY protos /usr/src/varfish-server-worker/protos/ | |||||||||||||||||
# COPY utils/alpine-linker-script.sh /usr/src/varfish-server-worker/utils/ | ||||||||||||||||||
# RUN chmod a+rx /usr/src/varfish-server-worker/utils/alpine-linker-script.sh | ||||||||||||||||||
# COPY .cargo /usr/src/varfish-server-worker/.cargo/ | ||||||||||||||||||
## Touch main.rs to prevent cached release build. | ||||||||||||||||||
|
||||||||||||||||||
# Touch main.rs to prevent cached release build. | ||||||||||||||||||
RUN touch /usr/src/varfish-server-worker/src/main.rs | ||||||||||||||||||
# This is the actual application build. | ||||||||||||||||||
RUN cargo build --release | ||||||||||||||||||
|
||||||||||||||||||
# Build the application | ||||||||||||||||||
RUN /root/.cargo/bin/cargo build --release | ||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 Apply this diff to simplify the build command: -RUN /root/.cargo/bin/cargo build --release
+RUN cargo build --release 📝 Committable suggestion
Suggested change
|
||||||||||||||||||
|
||||||||||||||||||
# --------------------------------------------------------------------------- | ||||||||||||||||||
# Runtime | ||||||||||||||||||
# --------------------------------------------------------------------------- | ||||||||||||||||||
|
||||||||||||||||||
FROM debian:bookworm-slim AS runtime | ||||||||||||||||||
FROM ubuntu:noble AS runtime | ||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Align runtime base image with a stable release Using Apply this diff to update the runtime base image: -FROM ubuntu:noble AS runtime
+FROM ubuntu:22.04 AS runtime 📝 Committable suggestion
Suggested change
|
||||||||||||||||||
|
||||||||||||||||||
# Install dependencies (and cleanup afterwards) | ||||||||||||||||||
# Install dependencies (and cleanup afterward) | ||||||||||||||||||
RUN apt-get update && \ | ||||||||||||||||||
apt-get install -y libsqlite3-0 && \ | ||||||||||||||||||
apt-get clean autoclean && \ | ||||||||||||||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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:
🧰 Tools
🪛 LanguageTool