rust Dockerfile

Dockerfile:

ARG BUILD_DIR=/rust/build

FROM  rust as build
ARG BUILD_DIR
WORKDIR ${BUILD_DIR}
COPY src ./src
COPY Rocket.toml .
COPY Cargo.lock .
COPY Cargo.toml .
RUN cargo build -r

FROM debian as deploy
ARG BUILD_DIR
WORKDIR /etc/rust
RUN mkdir config
COPY --from=build ${BUILD_DIR}/target/release/web .
ENV ROCKET_ADDRESS=0.0.0.0
ENV ROCKET_CONFIG=/etc/rust/config/Rocket.toml
CMD ["./web"]

启动命令:

docker run -v /config:/etc/rust/config -p 8000:8000 web:1.0

 

posted @ 2023-06-12 17:19  风的低吟  阅读(91)  评论(0编辑  收藏  举报