diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 000000000..5c5187748 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,12 @@ +# A whitelist of files that should be included into docker +# Put an exclaimation mark before everything to include + +# Ignore everything +* + +# Allow the source code folders +!/pumpkin*/ + +# Dependencies +!Cargo.lock +!Cargo.toml diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 000000000..69631ab81 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,13 @@ +FROM rust:1-alpine3.19 AS builder +ENV RUSTFLAGS="-C target-feature=-crt-static -C target-cpu=native" +RUN apk add --no-cache musl-dev +WORKDIR /pumpkin +COPY . /pumpkin +RUN cargo build --release +RUN strip target/release/pumpkin + +FROM alpine:3.19 +WORKDIR /pumpkin +RUN apk add --no-cache libgcc +COPY --from=builder /pumpkin/target/release/pumpkin /pumpkin/pumpkin +ENTRYPOINT ["/pumpkin/pumpkin"] diff --git a/README.md b/README.md index b0c341e70..32f57450d 100644 --- a/README.md +++ b/README.md @@ -96,6 +96,21 @@ Then run: RUSTFLAGS="-C target-cpu=native" cargo run --release ``` +### Docker + +Experimental Docker support is available. +The image is currently not published anywhere, but you can use the following command to build it: + +```shell +docker build . -t pumpkin +``` + +To run it use the following command: + +```shell +docker run --rm -v "./world:/pumpkin/world" pumpkin +``` + ## Contributions Contributions are welcome! See [CONTRIBUTING.md](CONTRIBUTING.md) diff --git a/pumpkin/src/main.rs b/pumpkin/src/main.rs index 42ecb4423..316b2374e 100644 --- a/pumpkin/src/main.rs +++ b/pumpkin/src/main.rs @@ -107,6 +107,7 @@ fn main() -> io::Result<()> { stdin .read_line(&mut out) .expect("Failed to read console line"); + if !out.is_empty() { handle_command(&mut commands::CommandSender::Console, &out); }