From 6d193dd8aec2675a3727927ad498a0c169c262e6 Mon Sep 17 00:00:00 2001 From: Bo Jeanes Date: Sun, 11 Sep 2022 18:31:50 +1000 Subject: [PATCH] Add Dockerfile --- .dockerignore | 2 ++ Dockerfile | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+) create mode 100644 .dockerignore create mode 100644 Dockerfile diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..3d3202d --- /dev/null +++ b/.dockerignore @@ -0,0 +1,2 @@ +Dockerfile +**/README.md \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..b14a550 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,34 @@ +# -*- mode: dockerfile -*- + +FROM rust:1.63-alpine AS builder + +RUN apk add --no-cache musl-dev + +# 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`. +FROM alpine:latest +RUN apk --no-cache add ca-certificates + +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"]