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