]> Repositorios git - scryer-prolog.git/commitdiff
New Dockerfile based on Fredrik Park's blog post - compilation fails with linker...
authorpanasenco <[email protected]>
Sat, 16 May 2020 23:30:47 +0000 (16:30 -0700)
committerpanasenco <[email protected]>
Mon, 18 May 2020 03:50:34 +0000 (20:50 -0700)
Dockerfile

index e16818376981886bb081051fdfcee0473c67bfba..bdaa9b5833afc4a063b19aede5fbe2f4c343ae0c 100755 (executable)
@@ -1,9 +1,33 @@
-FROM rust:slim\r
+# Based on https://blog.sedrik.se/posts/my-docker-setup-for-rust/\r
+FROM ekidd/rust-musl-builder as builder\r
 \r
-WORKDIR ~/scryer-prolog\r
+WORKDIR /home/rust/\r
+\r
+# Install external dependencies\r
+RUN sudo apt-get update\r
+RUN sudo apt-get -y install m4\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
+COPY Cargo.toml .\r
+COPY Cargo.lock .\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
 COPY . .\r
+RUN sudo touch src/main.rs\r
+RUN sudo touch build.rs\r
+\r
+RUN cargo build --release\r
 \r
-RUN cargo --version\r
-RUN cargo install --path .\r
+# Size optimization\r
+# RUN strip target/x86_64-unknown-linux-musl/release/scryer-prolog\r
 \r
-CMD ["scryer-prolog"]\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