From 2983a01bc6c3f575433781d3f80a04da5ccb47c9 Mon Sep 17 00:00:00 2001 From: Daniel Szabo Date: Mon, 9 May 2022 22:23:51 +0100 Subject: [PATCH] Docker support Added Dockerfile and changed address bind from 127.0.0.1 to 0.0.0.0 --- Dockerfile | 26 ++++++++++++++++++++++++++ src/main.rs | 2 +- 2 files changed, 27 insertions(+), 1 deletion(-) create mode 100644 Dockerfile diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..28be727 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,26 @@ +# latest rust will be used to build the binary +FROM rust:latest as builder + +# the temporary directory where we build +WORKDIR /usr/src/microbin + +# copy sources to /usr/src/microbin on the temporary container +COPY . . + +# run release build +RUN cargo build --release + +# create final container using slim version of debian +FROM debian:buster-slim + +# microbin will be in /usr/local/bin/microbin/ +WORKDIR /usr/local/bin + +# copy built exacutable +COPY --from=builder /usr/src/microbin/target/release/microbin /usr/local/bin/microbin + +# copy /static folder containing the stylesheets +COPY --from=builder /usr/src/microbin/static /usr/local/bin/static + +# run the binary +CMD ["microbin"] \ No newline at end of file diff --git a/src/main.rs b/src/main.rs index 07139af..b804b2d 100644 --- a/src/main.rs +++ b/src/main.rs @@ -376,7 +376,7 @@ async fn main() -> std::io::Result<()> { HttpAuthentication::basic(auth_validator), )) }) - .bind(format!("127.0.0.1:{}", args.port.to_string()))? + .bind(format!("0.0.0.0:{}", args.port.to_string()))? .workers(args.threads as usize) .run() .await