From 64f5757298e9780d9af6e6e651b15fe0c292864c Mon Sep 17 00:00:00 2001 From: Nilstrieb <48135649+Nilstrieb@users.noreply.github.com> Date: Thu, 31 Aug 2023 20:58:24 +0200 Subject: [PATCH] docker --- .dockerignore | 1 + Containerfile | 28 ++++++++++++++++++++++++++++ 2 files changed, 29 insertions(+) create mode 100644 .dockerignore create mode 100644 Containerfile diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..c41cc9e --- /dev/null +++ b/.dockerignore @@ -0,0 +1 @@ +/target \ No newline at end of file diff --git a/Containerfile b/Containerfile new file mode 100644 index 0000000..a88dc34 --- /dev/null +++ b/Containerfile @@ -0,0 +1,28 @@ +FROM docker.io/library/rust:1.72 as build + +RUN rustup target add x86_64-unknown-linux-musl + +RUN apt-get update +RUN apt-get install musl-tools -y + +WORKDIR /app +COPY Cargo.toml Cargo.lock rust-toolchain.toml ./ +RUN mkdir src +RUN echo "fn main() {}" > src/main.rs + +RUN cargo build --release --target x86_64-unknown-linux-musl + +COPY . . + +# now rebuild with the proper main +RUN touch src/main.rs +RUN cargo build --release --target x86_64-unknown-linux-musl + +### RUN +FROM gcr.io/distroless/static-debian12 + +WORKDIR /app + +COPY --from=build /app/target/release/x86_64-unknown-linux-musl/uptime uptime + +CMD ["/app/uptime"]