M Cargo.lock => Cargo.lock +6 -6
@@ 4,9 4,9 @@ version = 3
[[package]]
name = "anyhow"
-version = "1.0.53"
+version = "1.0.56"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "94a45b455c14666b85fc40a019e8ab9eb75e3a124e05494f5397122bc9eb06e0"
+checksum = "4361135be9122e0870de935d7c439aef945b9f9ddd4199a553b5270b49c82a27"
[[package]]
name = "build_const"
@@ 47,9 47,9 @@ dependencies = [
[[package]]
name = "getrandom"
-version = "0.2.4"
+version = "0.2.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "418d37c8b1d42553c93648be529cb70f920d3baf8ef469b74b9638df426e0b4c"
+checksum = "d39cd93900197114fa1fcb7ae84ca742095eed9442088988ae74fa744e930e77"
dependencies = [
"cfg-if",
"libc",
@@ 77,9 77,9 @@ dependencies = [
[[package]]
name = "libc"
-version = "0.2.118"
+version = "0.2.119"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "06e509672465a0504304aa87f9f176f2b2b716ed8fb105ebe5c02dc6dce96a94"
+checksum = "1bf2e165bb3457c8e098ea76f3e3bc9db55f87aa90d52d0e6be741470916aaa4"
[[package]]
name = "md5"
M Dockerfile => Dockerfile +15 -0
@@ 1,8 1,23 @@
# Builds an image containing the iplookup binary and little else.
+
+# Builder image, with initial project for Cargo.* deps to build in
+
FROM docker.io/library/rust:slim
+RUN cargo install cargo-build-deps \
+ && cd / \
+ && cargo new --bin iplookup
+
+# Build dependencies on their own as separate step to improve cached builds
+# (only copy Cargo.* to avoid source changes breaking this cache)
+COPY Cargo.toml Cargo.lock /iplookup
+RUN cd /iplookup && cargo build-deps --release
+
COPY . /iplookup
RUN cd /iplookup && cargo build --all-targets --release
+# Release image: copy executable from builder
+# Debian version needs to match builder image to avoid linker issues.
+
FROM debian:bullseye-slim
COPY --from=0 /iplookup/target/release/iplookup /iplookup
RUN chmod +x /iplookup