Dockerfile 1.4 KB

123456789101112131415161718192021222324252627282930313233343536
  1. # sm121 HA add-on image — the launcher as a 24/7 Home Assistant add-on
  2. # (specs/tech-architecture/ha-addon-recipe-repos.md).
  3. #
  4. # Multi-stage: the launcher is COMPILED IN-CONTAINER (stage 1) so the
  5. # binary always matches the container's architecture (no cross-toolchain
  6. # on the host). Build context = the repo root (trimmed by .dockerignore
  7. # to src/ + locales/ + host-scripts/ + the cargo manifest).
  8. #
  9. # make addon-image
  10. # scripts/smoke-addon.sh # entrypoint + file:// repo + curl /api/state
  11. # --- stage 1: compile ----------------------------------------------------------
  12. # (matches the repo toolchain — edition 2024 + let-chains need rust ≥ 1.88)
  13. FROM rust:1.98-bookworm AS build
  14. WORKDIR /src
  15. COPY Cargo.toml Cargo.lock ./
  16. COPY src/ src/
  17. COPY locales/ locales/
  18. COPY host-scripts/ host-scripts/
  19. RUN cargo build --release
  20. # --- stage 2: the add-on -------------------------------------------------------
  21. FROM debian:bookworm-slim
  22. # git (recipe-repo sync) + jq (env → config generation) + ca-certs (https)
  23. RUN apt-get update \
  24. && apt-get install -y --no-install-recommends git ca-certificates jq \
  25. && rm -rf /var/lib/apt/lists/*
  26. COPY --from=build /src/target/release/sm121 /usr/local/bin/sm121
  27. COPY docker-images/sm121-addon/entrypoint.sh /entrypoint.sh
  28. RUN chmod 755 /usr/local/bin/sm121 /entrypoint.sh
  29. ENV SM121_WEB_PORT=3100
  30. EXPOSE 3100
  31. ENTRYPOINT ["/entrypoint.sh"]