From 88e36d2e560dda21e9877f87b81c6e68ce13a9ef Mon Sep 17 00:00:00 2001 From: scodari Date: Sat, 11 Jan 2025 18:14:10 +0100 Subject: [PATCH] Implemented Dockerfile with related documentation --- Dockerfile | 14 ++++++++++++++ README.md | 26 ++++++++++++++++++++++++++ 2 files changed, 40 insertions(+) create mode 100644 Dockerfile diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..8c7e81b --- /dev/null +++ b/Dockerfile @@ -0,0 +1,14 @@ +# Use the Alpine-based Rust image as builder +FROM rust:alpine AS builder +RUN apk add --no-cache musl-dev gcc +WORKDIR /usr/src/paperback +COPY . . +RUN RUSTFLAGS="-C target-feature=-crt-static" cargo build --release + +FROM alpine:3 AS runner +RUN apk add --no-cache libgcc +COPY --from=builder /usr/src/paperback/target/release/paperback /usr/local/bin/ +RUN chmod +x /usr/local/bin/paperback + +WORKDIR /data +ENTRYPOINT ["paperback"] \ No newline at end of file diff --git a/README.md b/README.md index 906dc15..c3bcd1c 100644 --- a/README.md +++ b/README.md @@ -163,6 +163,32 @@ version of the documents. [rust]: https://www.rust-lang.org/ [cargo]: https://doc.rust-lang.org/cargo/ +#### Run in a Docker container +You can run `paperback` in a very lightweight Alpine based Docker container +(less than 20 MB). This is useful if don't want or you can't install the rust +build toolchain on your system. To run `paperback` in a Docker container, you +must first clone this repo or download the ZIP file of the code, then run the +following command: +```bash +docker build -t paperback . +``` +Then you can `cd` the directory where the files you need to backup are located +and run the following command: +```bash +docker run --rm -v ${PWD}:/data paperback backup -n THRESHOLD -k SHARDS INPUT_FILE +``` +all the commands runs exactly how described in the section above. This solution +will create a temporary docker container that will be deleted after the command +is executed. + +If you need to run multiple commands and you prefer an interactive terminal, you +can run the following command instead of the previous one: +```bash +docker run --rm -it -v ${PWD}:/data --entrypoint /bin/sh paperback +``` +then you can run all the `paperback` commands you need. When you finish, type +`exit` to close the terminal and destroy the container. + ### Paper Choices and Storage ### One of the most important things when considering using `paperback` is to keep