Skip to content

Commit

Permalink
Try to workaround docker/buildx#395
Browse files Browse the repository at this point in the history
  • Loading branch information
bjeanes committed Sep 11, 2022
1 parent c4fb085 commit 0ce38ae
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,10 @@ RUN USER=rust cargo new /home/rust/tokio_modbus-winets
RUN USER=rust cargo new /home/rust/modbus-mqtt
WORKDIR /home/rust/modbus-mqtt
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
# RUN rm -rf src
Expand All @@ -22,7 +25,9 @@ RUN cargo build --release
ADD --chown=rust:rust . ./

# 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`.
FROM debian:bullseye-slim
Expand All @@ -34,8 +39,8 @@ RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \
libudev1

COPY --from=builder \
/home/rust/modbus-mqtt/target/release/modbus-mqtt \
/usr/local/bin/
/home/rust/modbus-mqtt/bin \
/usr/local/bin/modbus-mqtt

ENV RUST_LOG=warn,modbus_mqtt=info

Expand Down

0 comments on commit 0ce38ae

Please sign in to comment.