2022-09-11 18:31:50 +10:00
|
|
|
# -*- mode: dockerfile -*-
|
|
|
|
|
2022-09-11 18:43:55 +10:00
|
|
|
FROM rust:1.63 AS builder
|
2022-09-11 18:31:50 +10:00
|
|
|
|
2022-09-11 18:43:55 +10:00
|
|
|
RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \
|
|
|
|
--mount=type=cache,target=/var/lib/apt,sharing=locked \
|
|
|
|
apt update && apt-get --no-install-recommends install -y \
|
|
|
|
libudev-dev
|
2022-09-11 18:31:50 +10:00
|
|
|
|
|
|
|
# Build a cacheable layer with project dependencies
|
|
|
|
RUN USER=rust cargo new /home/rust/sungrow-winets
|
|
|
|
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
|
|
|
|
|
|
|
|
# # Delete files & directories which shouldn't exist for the workspace
|
|
|
|
# RUN rm -rf src
|
|
|
|
|
|
|
|
# Add our source code.
|
|
|
|
ADD --chown=rust:rust . ./
|
|
|
|
|
|
|
|
# Build our application.
|
|
|
|
RUN cargo build --release
|
|
|
|
|
|
|
|
# Now, we need to build our _real_ Docker container, copying in `bump-api`.
|
2022-09-11 18:43:55 +10:00
|
|
|
FROM debian:bullseye-slim
|
|
|
|
|
|
|
|
RUN rm -f /etc/apt/apt.conf.d/docker-clean; echo 'Binary::apt::APT::Keep-Downloaded-Packages "true";' > /etc/apt/apt.conf.d/keep-cache
|
|
|
|
RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \
|
|
|
|
--mount=type=cache,target=/var/lib/apt,sharing=locked \
|
|
|
|
apt update && apt-get --no-install-recommends install -y \
|
|
|
|
libudev1
|
2022-09-11 18:31:50 +10:00
|
|
|
|
|
|
|
COPY --from=builder \
|
|
|
|
/home/rust/modbus-mqtt/target/release/modbus-mqtt \
|
|
|
|
/usr/local/bin/
|
|
|
|
|
|
|
|
ENV RUST_LOG=warn,modbus_mqtt=info
|
|
|
|
|
|
|
|
ENTRYPOINT ["/usr/local/bin/modbus-mqtt"]
|