-# Based on https://blog.sedrik.se/posts/my-docker-setup-for-rust/\r
-FROM ekidd/rust-musl-builder as builder\r
+# Based on https://hub.docker.com/_/rust?tab=description and https://hub.docker.com/_/rust?tab=description\r
\r
-WORKDIR /home/rust/\r
+# The first container is for build purposes only.\r
+FROM rust as builder\r
\r
-# Install external dependencies\r
-RUN sudo apt-get update\r
-RUN sudo apt-get -y install m4\r
+WORKDIR /usr/src/scryer-prolog\r
\r
-# Avoid having to install/build all dependencies by copying\r
-# the Cargo files and making a dummy src/main.rs and build.rs\r
+# Using a dummy build.rs and src/main.rs with your Cargo.toml lets Docker cache your Rust dependencies and not rebuild\r
+# them every time.\r
COPY Cargo.toml .\r
COPY Cargo.lock .\r
+RUN mkdir -p src\r
RUN echo "fn main() {}" > src/main.rs\r
RUN echo "fn main() {}" > build.rs\r
RUN cargo build --release\r
\r
# We need to touch our real main.rs and build.rs files or else\r
-# docker will use the cached one.\r
+# docker will use the cached ones.\r
COPY . .\r
-RUN sudo touch src/main.rs\r
-RUN sudo touch build.rs\r
+RUN touch src/main.rs\r
+RUN touch build.rs\r
\r
RUN cargo build --release\r
\r
-# Size optimization\r
-# RUN strip target/x86_64-unknown-linux-musl/release/scryer-prolog\r
+RUN ls ./target/release\r
\r
-# Start building the final image\r
-FROM scratch\r
-WORKDIR /home/rust/\r
-COPY --from=builder /home/rust/target/x86_64-unknown-linux-musl/release/scryer-prolog .\r
-ENTRYPOINT ["./scryer-prolog"]\r
+# Finally, copy the scryer-prolog executable to a slimmer container.\r
+FROM debian:buster-slim\r
+COPY --from=builder /usr/src/scryer-prolog/target/release/scryer-prolog /usr/local/bin/scryer-prolog\r
+CMD ["scryer-prolog"]\r