From e82e36f51e3a61869b7b4937e78009afa5fc1a67 Mon Sep 17 00:00:00 2001 From: panasenco Date: Fri, 22 May 2020 13:35:14 -0700 Subject: [PATCH 1/3] Revert "Revert "Created and Tested Dockerfile"" This reverts commit e00d864199549c179a4403fba910b234646cdba5. --- .dockerignore | 6 ++++++ Dockerfile | 30 ++++++++++++++++++++++++++++++ README.md | 22 ++++++++++++++++++++++ 3 files changed, 58 insertions(+) create mode 100755 .dockerignore create mode 100755 Dockerfile diff --git a/.dockerignore b/.dockerignore new file mode 100755 index 00000000..050103c6 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,6 @@ +target +Dockerfile +README.md +.git +.gitignore +.gitmodules diff --git a/Dockerfile b/Dockerfile new file mode 100755 index 00000000..3b2c3a05 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,30 @@ +# Based on https://hub.docker.com/_/rust?tab=description and https://hub.docker.com/_/rust?tab=description + +# The first container is for build purposes only. +FROM rust as builder + +WORKDIR /usr/src/scryer-prolog + +# Using a dummy build.rs and src/main.rs with your Cargo.toml lets Docker cache your Rust dependencies and not rebuild +# them every time. +COPY Cargo.toml . +COPY Cargo.lock . +RUN mkdir -p src +RUN echo "fn main() {}" > src/main.rs +RUN echo "fn main() {}" > build.rs +RUN cargo build --release + +# We need to touch our real main.rs and build.rs files or else +# docker will use the cached ones. +COPY . . +RUN touch src/main.rs +RUN touch build.rs + +RUN cargo build --release + +RUN ls ./target/release + +# Finally, copy the scryer-prolog executable to a slimmer container. +FROM debian:buster-slim +COPY --from=builder /usr/src/scryer-prolog/target/release/scryer-prolog /usr/local/bin/scryer-prolog +CMD ["scryer-prolog"] diff --git a/README.md b/README.md index 2a477a28..623f7e6e 100644 --- a/README.md +++ b/README.md @@ -93,6 +93,8 @@ strings. ## Installing Scryer Prolog +### Native Install (Unix Only) + First, install the latest stable version of [Rust](https://www.rust-lang.org/en-US/install.html) using your preferred method. Scryer tends to use features from newer Rust @@ -126,6 +128,26 @@ $> cargo run [--release] The optional `--release` flag will perform various optimizations, producing a faster executable. +### Docker Install (All Platforms) + +To automatically download, install, and run Scryer Prolog via Docker, +simply run: +``` +$> docker run -it mthom/scryer-prolog +``` + +To be able to load your program files, bind mount your programs folder +as a Docker volume: + +``` +$> docker run -v /home/user/prolog:/mnt -it mthom/scryer-prolog +?- consult('mnt/program.pl'). +true. +``` + +[Docker](https://hub.docker.com/editions/community/docker-ce-desktop-windows) +is currently the only way to run scryer-prolog on Windows. + ## Tutorial Prolog files are loaded by specifying them as arguments on the command From db56bb92f08e4f10083ffda13c92390a96633a95 Mon Sep 17 00:00:00 2001 From: panasenco Date: Fri, 22 May 2020 13:57:10 -0700 Subject: [PATCH 2/3] Fixed link in Dockerfile documentation. Updated README with working Docker link. Made general improvements to the Docker section of the README now that I'm not in a sleep-deprived zombie state. --- Dockerfile | 2 +- README.md | 26 +++++++++++++++++--------- 2 files changed, 18 insertions(+), 10 deletions(-) diff --git a/Dockerfile b/Dockerfile index 3b2c3a05..4ae378a5 100755 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -# Based on https://hub.docker.com/_/rust?tab=description and https://hub.docker.com/_/rust?tab=description +# Based on https://hub.docker.com/_/rust?tab=description and https://blog.sedrik.se/posts/my-docker-setup-for-rust/ # The first container is for build purposes only. FROM rust as builder diff --git a/README.md b/README.md index 623f7e6e..cc81f416 100644 --- a/README.md +++ b/README.md @@ -130,23 +130,31 @@ producing a faster executable. ### Docker Install (All Platforms) -To automatically download, install, and run Scryer Prolog via Docker, -simply run: +First, install [Docker](https://docs.docker.com/get-docker/) on Linux, +Windows, or Mac. + +Once Docker is installed, you can automatically download, install, and +run Scryer Prolog in a single command: ``` -$> docker run -it mthom/scryer-prolog +$> docker run -it mjt128/scryer-prolog ``` -To be able to load your program files, bind mount your programs folder -as a Docker volume: +To consult your Prolog files, bind mount your programs folder as a +[Docker volume](https://docs.docker.com/storage/volumes/): ``` -$> docker run -v /home/user/prolog:/mnt -it mthom/scryer-prolog -?- consult('mnt/program.pl'). +$> docker run -v /home/user/prolog:/mnt -it mjt128/scryer-prolog +?- consult('/mnt/program.pl'). true. ``` -[Docker](https://hub.docker.com/editions/community/docker-ce-desktop-windows) -is currently the only way to run scryer-prolog on Windows. +This works on Windows too: + +``` +$> docker run -v C:\Users\user\Documents\prolog:/mnt -it mjt128/scryer-prolog +?- consult('/mnt/program.pl'). +true. +``` ## Tutorial From dadf1b6ff93ffd3d58c06015f8da0212b33f443d Mon Sep 17 00:00:00 2001 From: panasenco Date: Fri, 22 May 2020 14:01:10 -0700 Subject: [PATCH 3/3] Phrasing --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index cc81f416..fcae6824 100644 --- a/README.md +++ b/README.md @@ -133,8 +133,8 @@ producing a faster executable. First, install [Docker](https://docs.docker.com/get-docker/) on Linux, Windows, or Mac. -Once Docker is installed, you can automatically download, install, and -run Scryer Prolog in a single command: +Once Docker is installed, you can download and run Scryer Prolog with a single +command: ``` $> docker run -it mjt128/scryer-prolog ```