1
0
Fork 0
docker
Bo Jeanes 2022-09-12 09:42:14 +10:00
parent c4fb085931
commit 0ce38aea97
1 changed files with 9 additions and 4 deletions

View File

@ -13,7 +13,10 @@ RUN USER=rust cargo new /home/rust/tokio_modbus-winets
RUN USER=rust cargo new /home/rust/modbus-mqtt RUN USER=rust cargo new /home/rust/modbus-mqtt
WORKDIR /home/rust/modbus-mqtt WORKDIR /home/rust/modbus-mqtt
ADD --chown=rust:rust Cargo.lock modbus-mqtt/Cargo.toml ./ ADD --chown=rust:rust Cargo.lock modbus-mqtt/Cargo.toml ./
RUN cargo build --release RUN mkdir -p /home/rust/modbus-mqtt/target/release
RUN --mount=type=cache,target=/home/rust/modbus-mqtt/target,sharing=locked \
--mount-type=cache,target=/usr/local/cargo/registry,sharing=locked \
cargo build --release
# # Delete files & directories which shouldn't exist for the workspace # # Delete files & directories which shouldn't exist for the workspace
# RUN rm -rf src # RUN rm -rf src
@ -22,7 +25,9 @@ RUN cargo build --release
ADD --chown=rust:rust . ./ ADD --chown=rust:rust . ./
# Build our application. # Build our application.
RUN cargo build --release RUN --mount=type=cache,target=/home/rust/modbus-mqtt/target,sharing=locked \
--mount-type=cache,target=/usr/local/cargo/registry,sharing=locked \
cargo build --release --offline && mv target/release/modbus-mqtt ./bin
# Now, we need to build our _real_ Docker container, copying in `bump-api`. # Now, we need to build our _real_ Docker container, copying in `bump-api`.
FROM debian:bullseye-slim FROM debian:bullseye-slim
@ -34,8 +39,8 @@ RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \
libudev1 libudev1
COPY --from=builder \ COPY --from=builder \
/home/rust/modbus-mqtt/target/release/modbus-mqtt \ /home/rust/modbus-mqtt/bin \
/usr/local/bin/ /usr/local/bin/modbus-mqtt
ENV RUST_LOG=warn,modbus_mqtt=info ENV RUST_LOG=warn,modbus_mqtt=info