-
Notifications
You must be signed in to change notification settings - Fork 36
Make cargo-chef effective for CI builds #763
Changes from all commits
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 |
---|---|---|
|
@@ -5,15 +5,17 @@ RUN apt update \ | |
build-essential tcl protobuf-compiler file \ | ||
libssl-dev pkg-config git\ | ||
&& apt clean \ | ||
&& cargo install cargo-chef | ||
&& rm -rf /var/lib/apt/lists/* | ||
|
||
# We need to install and set as default the toolchain specified in rust-toolchain.toml | ||
# Otherwise cargo-chef will build dependencies using wrong toolchain | ||
# This also prevents planner and builder steps from installing the toolchain over and over again | ||
COPY rust-toolchain.toml rust-toolchain.toml | ||
RUN cat rust-toolchain.toml | grep "channel" | awk '{print $3}' | sed 's/\"//g' > toolchain.txt \ | ||
&& rustup update $(cat toolchain.txt) \ | ||
&& rustup default $(cat toolchain.txt) \ | ||
&& rm toolchain.txt rust-toolchain.toml | ||
&& rm toolchain.txt rust-toolchain.toml \ | ||
&& cargo install cargo-chef | ||
|
||
FROM chef AS planner | ||
COPY . . | ||
|
@@ -27,14 +29,19 @@ RUN cargo build -p sqld --release | |
|
||
# runtime | ||
FROM debian:bullseye-slim | ||
COPY --from=builder /target/release/sqld /bin/sqld | ||
|
||
EXPOSE 5001 8080 | ||
VOLUME [ "/var/lib/sqld" ] | ||
|
||
RUN groupadd --system --gid 666 sqld | ||
RUN adduser --system --home /var/lib/sqld --uid 666 --gid 666 sqld | ||
RUN apt-get update && apt-get install -y ca-certificates | ||
COPY docker-entrypoint.sh /usr/local/bin | ||
ENTRYPOINT ["/usr/local/bin/docker-entrypoint.sh"] | ||
VOLUME [ "/var/lib/sqld" ] | ||
WORKDIR /var/lib/sqld | ||
USER sqld | ||
EXPOSE 5001 8080 | ||
|
||
COPY docker-entrypoint.sh /usr/local/bin | ||
|
||
COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ca-certificates.crt | ||
Comment on lines
+41
to
+43
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. It seems that reverse order would be better since docker-entrypoint.sh probably changes more often than ca-certificates. Also don't you need to add 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.
That is true, but the entrypoint changes pretty rarely, and when that happens we'll only save a layer that weights the size of Let me know if you still want me to reorder.
We don't have to because our Rust base image already does it. 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. Thanks for the explanation about the rust base image containing ca-certificates. |
||
COPY --from=builder /target/release/sqld /bin/sqld | ||
|
||
ENTRYPOINT ["/usr/local/bin/docker-entrypoint.sh"] | ||
CMD ["/bin/sqld"] |
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.
This is actually a regression. If rust-toolchain.toml changes
cargo install cargo-chef
will be re-run. Previously it would be cached.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.
If the toolchain changes we'll have to rebuild everything anyway, the cost of running
cargo install cargo-chef
is marginal.I think the benefit of having all rust tools built by the same toolchain outweighs the downsides.
Let me know if you still want me to move it back.
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.
That's fine. Just don't name the commit "Optimize ... layers" when in fact you're de-optimizing it.
If you have named your intend of "cleaning up" the layers, I wouldn't add such comment at all.