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..4ae378a5 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,30 @@ +# 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 + +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..fcae6824 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,34 @@ $> cargo run [--release] The optional `--release` flag will perform various optimizations, producing a faster executable. +### Docker Install (All Platforms) + +First, install [Docker](https://docs.docker.com/get-docker/) on Linux, +Windows, or Mac. + +Once Docker is installed, you can download and run Scryer Prolog with a single +command: +``` +$> docker run -it mjt128/scryer-prolog +``` + +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 mjt128/scryer-prolog +?- consult('/mnt/program.pl'). +true. +``` + +This works on Windows too: + +``` +$> docker run -v C:\Users\user\Documents\prolog:/mnt -it mjt128/scryer-prolog +?- consult('/mnt/program.pl'). +true. +``` + ## Tutorial Prolog files are loaded by specifying them as arguments on the command