chore: docker build config
This commit is contained in:
30
Dockerfile
30
Dockerfile
@@ -1,4 +1,28 @@
|
|||||||
FROM ubuntu:latest
|
FROM rust:1.80-slim AS builder
|
||||||
LABEL authors="YE"
|
|
||||||
|
|
||||||
ENTRYPOINT ["top", "-b"]
|
# 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"]
|
||||||
Reference in New Issue
Block a user