39 lines
1.6 KiB
Docker
39 lines
1.6 KiB
Docker
# eg4-battery daemon — containerized.
|
|
#
|
|
# Build: docker build -t eg4-battery .
|
|
# Run: see docker-compose.yml for device passthrough + config mount
|
|
#
|
|
# Design notes:
|
|
# - Same Python source (bin/eg4-battery) used in both systemd and Docker
|
|
# deployments. PEP-723 inline deps are ignored when run with `python` directly,
|
|
# so they're harmless. Container deps come from requirements.txt.
|
|
# - Config is mounted at /config/eg4-battery.yaml (read-only). MQTT
|
|
# credentials can be overridden via env vars (see env-override block in
|
|
# bin/eg4-battery's main()), making them suitable for Docker secrets or
|
|
# HA-addon options translation.
|
|
# - Logs go to stdout (Python logging defaults work — `docker logs` captures).
|
|
|
|
FROM python:3.11-slim AS base
|
|
|
|
# pyserial wants the native serial-port permissions to "just work" inside
|
|
# the container; we hand the device through via docker-compose `devices:`.
|
|
# No extra system packages needed.
|
|
|
|
WORKDIR /app
|
|
|
|
# --- Python deps --------------------------------------------------------
|
|
COPY requirements.txt .
|
|
RUN pip install --no-cache-dir -r requirements.txt
|
|
|
|
# --- daemon source ------------------------------------------------------
|
|
COPY bin/eg4-battery /app/eg4-battery
|
|
RUN chmod +x /app/eg4-battery
|
|
|
|
# --- runtime ------------------------------------------------------------
|
|
# Config volume mount expected at /config (read-only); see compose file.
|
|
VOLUME ["/config"]
|
|
|
|
# Run as the daemon's main entrypoint. We exec via `python` so the PEP-723
|
|
# shebang isn't invoked (uv isn't in this image).
|
|
ENTRYPOINT ["python", "/app/eg4-battery", "-C", "/config/eg4-battery.yaml"]
|