1
0
Fork 0

Add Dockerfile

main
Bo Jeanes 2022-09-11 18:31:50 +10:00
parent 0080b88176
commit 6d193dd8ae
2 changed files with 36 additions and 0 deletions

2
.dockerignore 100644
View File

@ -0,0 +1,2 @@
Dockerfile
**/README.md

34
Dockerfile 100644
View File

@ -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"]