Merge pull request #12 from szabodanika/add-docker

Docker support
This commit is contained in:
Dániel Szabó 2022-05-09 22:27:02 +01:00 committed by GitHub
commit 25b1b649d8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 27 additions and 1 deletions

26
Dockerfile Normal file
View file

@ -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"]

View file

@ -376,7 +376,7 @@ async fn main() -> std::io::Result<()> {
HttpAuthentication::basic(auth_validator), 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) .workers(args.threads as usize)
.run() .run()
.await .await