From b0e44dd2589e925f48a2a1c6231333db5387c239 Mon Sep 17 00:00:00 2001 From: Mike Kinney Date: Tue, 14 Jan 2020 16:25:19 -0800 Subject: [PATCH 1/4] update doc to show working example --- rust/content.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/rust/content.md b/rust/content.md index a5643a866..455604c32 100644 --- a/rust/content.md +++ b/rust/content.md @@ -39,8 +39,8 @@ COPY . . RUN cargo install --path . FROM debian:buster-slim -RUN apt-get update && apt-get install -y libssl -COPY --from=builder /usr/src/myapp /usr/local/bin/myapp +RUN apt-get update && apt-get install -y libssl-dev +COPY --from=builder /usr/src/myapp/target/release/myapp /usr/local/bin/myapp CMD ["myapp"] ``` From 3a1628294a2e363d0978e42c4c859f852f41da64 Mon Sep 17 00:00:00 2001 From: Mike Kinney Date: Tue, 14 Jan 2020 19:45:11 -0800 Subject: [PATCH 2/4] change to generic library --- rust/content.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/rust/content.md b/rust/content.md index 455604c32..211ac8784 100644 --- a/rust/content.md +++ b/rust/content.md @@ -39,12 +39,12 @@ COPY . . RUN cargo install --path . FROM debian:buster-slim -RUN apt-get update && apt-get install -y libssl-dev +RUN apt-get update && apt-get install -y extra-runtime-dependencies COPY --from=builder /usr/src/myapp/target/release/myapp /usr/local/bin/myapp CMD ["myapp"] ``` -Note: Some shared libraries may need to be installed as shown in the installation of the libssl line above. +Note: Some shared libraries may need to be installed as shown in the installation of the `extra-runtime-dependencies` line above. This method will create an image that is less than 200mb. If you switch to using the Alpine-based rust image, you might be able to save another 60mb. From f983fe848118b3db3b1b0c732b1d4e469541a004 Mon Sep 17 00:00:00 2001 From: Mike Kinney Date: Wed, 15 Jan 2020 06:12:14 -0800 Subject: [PATCH 3/4] bump to 1.40; use variable for bin --- rust/content.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/rust/content.md b/rust/content.md index 211ac8784..a918aa07f 100644 --- a/rust/content.md +++ b/rust/content.md @@ -33,14 +33,14 @@ $ docker run -it --rm --name my-running-app my-rust-app This creates an image that has all of the rust tooling for the image, which is 1.8gb. If you just want the compiled application: ```dockerfile -FROM rust:1.39 as builder +FROM rust:1.40 as builder WORKDIR /usr/src/myapp COPY . . RUN cargo install --path . FROM debian:buster-slim RUN apt-get update && apt-get install -y extra-runtime-dependencies -COPY --from=builder /usr/src/myapp/target/release/myapp /usr/local/bin/myapp +COPY --from=builder $CARGO_HOME/bin/myapp /usr/local/bin/myapp CMD ["myapp"] ``` From 217ee9a9db3b1ecb1fa3863ebbafae711eb3d21a Mon Sep 17 00:00:00 2001 From: Mike Kinney Date: Wed, 15 Jan 2020 06:35:48 -0800 Subject: [PATCH 4/4] cannot use variable from other docker stage --- rust/content.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rust/content.md b/rust/content.md index a918aa07f..56bbd2fa3 100644 --- a/rust/content.md +++ b/rust/content.md @@ -40,7 +40,7 @@ RUN cargo install --path . FROM debian:buster-slim RUN apt-get update && apt-get install -y extra-runtime-dependencies -COPY --from=builder $CARGO_HOME/bin/myapp /usr/local/bin/myapp +COPY --from=builder /usr/local/cargo/bin/myapp /usr/local/bin/myapp CMD ["myapp"] ```