chore: Add Dockerfile

A Dockerfile has been added (along with .dockerignore) to
build a lightweight image of `rathole`. Image is being built
using `rust-musl-builder` and `scratch` is used for runtime.

Signed-off-by: Orhun Parmaksız <orhunparmaksiz@gmail.com>
This commit is contained in:
Orhun Parmaksız 2022-01-06 14:32:20 +03:00 committed by Yujia Qiao
parent 08a2f1a73a
commit 63b8b78ee8
2 changed files with 24 additions and 0 deletions

12
.dockerignore Normal file
View File

@ -0,0 +1,12 @@
# Directories
/.git/
/.github/
/target/
/examples/
/docs/
/benches/
# Files
.gitignore
*.md
LICENSE

12
Dockerfile Normal file
View File

@ -0,0 +1,12 @@
FROM ekidd/rust-musl-builder:latest as builder
WORKDIR /home/rust/src
COPY . .
RUN cargo build --locked --release
RUN mkdir -p build-out/
RUN cp target/x86_64-unknown-linux-musl/release/rathole build-out/
FROM scratch
WORKDIR /app
COPY --from=builder /home/rust/src/build-out/rathole .
USER 1000:1000
ENTRYPOINT ["./rathole"]