Skip to content

Commit

Permalink
Reduce Docker image sizes with multi-stage builds (#8)
Browse files Browse the repository at this point in the history
* Reduce Docker image sizes with multi-stage builds
  • Loading branch information
chicoferreira authored Jun 22, 2024
1 parent e791c9f commit a085df6
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 13 deletions.
7 changes: 0 additions & 7 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,6 @@ services:
network_mode: host
env_file:
- .env
mqtt-topic-remapper:
build: ./mqtt-topic-remapper
container_name: mqtt-topic-remapper
restart: unless-stopped
network_mode: host
env_file:
- .env

volumes:
homekit-mqtt-bridge:
12 changes: 9 additions & 3 deletions homekit-mqtt-bridge/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,12 +1,18 @@
FROM rust:1.72
FROM rust:1.72 as builder

COPY ./src ./homekit-mqtt-bridge/src
COPY ./Cargo.toml ./homekit-mqtt-bridge/Cargo.toml

WORKDIR ./homekit-mqtt-bridge

RUN apt-get update && apt-get install -y libssl-dev && apt-get install -y cmake
RUN apt-get update && apt-get install -y cmake

RUN cargo build --release

CMD ["./target/release/homekit-mqtt-bridge"]
FROM debian:bookworm-slim

RUN apt-get update && apt-get install -y openssl

COPY --from=builder /homekit-mqtt-bridge/target/release/homekit-mqtt-bridge /usr/local/bin/homekit-mqtt-bridge

CMD ["/usr/local/bin/homekit-mqtt-bridge"]
12 changes: 9 additions & 3 deletions yeelight-controller/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,12 +1,18 @@
FROM rust:1.72
FROM rust:1.72 as builder

COPY ./src ./yeelight-controller/src
COPY ./Cargo.toml ./yeelight-controller/Cargo.toml

WORKDIR ./yeelight-controller

RUN apt-get update && apt-get install -y libssl-dev && apt-get install -y cmake
RUN apt-get update && apt-get install -y cmake

RUN cargo build --release

CMD ["./target/release/yeelight-controller"]
FROM debian:bookworm-slim

RUN apt-get update && apt-get install -y openssl

COPY --from=builder /yeelight-controller/target/release/yeelight-controller /usr/local/bin/yeelight-controller

CMD ["/usr/local/bin/yeelight-controller"]

0 comments on commit a085df6

Please sign in to comment.