diff --git a/Dockerfile b/Dockerfile index f99a0df..36b10bf 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,28 @@ -FROM ubuntu:latest -LABEL authors="YE" +FROM rust:1.80-slim AS builder -ENTRYPOINT ["top", "-b"] \ No newline at end of file +# Dummy app +RUN USER=root cargo new --bin app +WORKDIR /app + +# Cargo build and src cleaup +COPY ./Cargo.toml ./Cargo.toml +COPY ./Cargo.lock ./Cargo.lock +RUN cargo build --release +RUN rm src/*.rs + +# Copy src files +COPY ./src ./src +RUN rm ./target/release/deps/app* +RUN cargo build --release + + +FROM debian:bookworm-slim + +# Install necessary runtime libraries +RUN apt-get update && apt-get install -y libssl-dev ca-certificates && rm -rf /var/lib/apt/lists/* + +# Copy the binary from the builder stage +COPY --from=builder /app/target/release/app /usr/local/bin/app + +# Set execution permissions and run +CMD ["app"] \ No newline at end of file