Docker Library Bot 5 rokov pred
rodič
commit
c527715c54
1 zmenil súbory, kde vykonal 20 pridanie a 0 odobranie
  1. 20 0
      rust/README.md

+ 20 - 0
rust/README.md

@@ -79,6 +79,26 @@ $ docker build -t my-rust-app .
 $ 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
+WORKDIR /usr/src/myapp
+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
+CMD ["myapp"]
+```
+
+Note: Some shared libraries may need to be installed as shown in the installation of the libssl 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.
+
+See https://docs.docker.com/develop/develop-images/multistage-build/ for more information.
+
 ## Compile your app inside the Docker container
 
 There may be occasions where it is not appropriate to run your app inside a container. To compile, but not run your app inside the Docker instance, you can write something like: