Nest the two library packages under a single import namespace so they can ship as one distribution: protocol/ -> smartthings_local/protocol/ ocf/ -> smartthings_local/ocf/ (git mv, history preserved) - Rewrite all imports protocol.* -> smartthings_local.protocol.*, ocf.* -> smartthings_local.ocf.* across the ocf modules, mqtt_demo/ (bridge, descriptor, samples), and tests. - Add pyproject.toml: dist name `smartthings-local`, hatch-vcs versioning from v* tags, wheel ships only smartthings_local/. - Add .github/workflows/publish.yml: build + PyPI Trusted Publishing on v* tags (OIDC, no stored token). - Force-include protocol/ocf_root_ca.pem via [tool.hatch.build] artifacts: it is tracked but matches .gitignore's *.pem, so hatchling's VCS file selection would drop it — and dtls_session.py loads it at runtime. - Update mqtt_demo Dockerfile COPY and deploy.sh tar allowlist to the single smartthings_local/ package. - .gitignore: build artifacts (_version.py, dist/, *.egg-info/). Validated: pytest tests/ (11 passed), python -m build produces sdist + wheel with the pem bundled, fresh pip install resolves all nested imports with the pem readable from site-packages.
34 lines
1.1 KiB
Docker
34 lines
1.1 KiB
Docker
FROM python:3.11-slim
|
|
|
|
WORKDIR /app
|
|
|
|
# Python deps first so layer cache survives code changes
|
|
COPY mqtt_demo/requirements.txt .
|
|
RUN pip install --no-cache-dir -r requirements.txt
|
|
|
|
# Application code — build context is the repo root (see
|
|
# docker-compose.yml's `context: ..`) since mqtt_demo/ depends on the
|
|
# smartthings_local library package that lives alongside it.
|
|
COPY smartthings_local/ ./smartthings_local/
|
|
COPY mqtt_demo/ ./mqtt_demo/
|
|
|
|
# /config holds the ab0b0ac4 client cert + key. Mount from the host so
|
|
# secrets aren't baked into the image.
|
|
RUN mkdir -p /config
|
|
|
|
# Unbuffered stdout so docker logs is live
|
|
ENV PYTHONUNBUFFERED=1
|
|
|
|
# Defaults — override in .env or `docker run -e …`. Per-appliance
|
|
# keys (APPLIANCE_COUNT, APPLIANCE_<n>_*) have no universal default
|
|
# and must be set in .env.
|
|
ENV CERT_PATH=/config/ab0b0ac4_fullchain.pem \
|
|
KEY_PATH=/config/ab0b0ac4.key \
|
|
HA_DISCOVERY_PREFIX=homeassistant \
|
|
HEALTH_INTERVAL_S=60 \
|
|
HEARTBEAT_INTERVAL_S=600
|
|
|
|
# No port — bridge is outbound-only (DTLS UDP to appliance, MQTT to broker).
|
|
|
|
CMD ["python", "-m", "mqtt_demo"]
|