Skip to content

Commit

Permalink
Updated dockerfile
Browse files Browse the repository at this point in the history
  • Loading branch information
ha-enthus1ast committed Dec 12, 2023
1 parent dc4ee31 commit 8a140bc
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 9 deletions.
9 changes: 2 additions & 7 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
FROM python:3.11 as base

ENV HEALTHCHECK_INTERVAL=5m \
HEALTHCHECK_TIMEOUT=5s \
SETTINGS_DIR=/config \
ENV SETTINGS_DIR=/config \
SETTINGS_FILE=settings.yaml \
WORKDIR=/app

Expand Down Expand Up @@ -40,9 +38,6 @@ FROM base as final

RUN adduser plejd bluetooth

COPY ./config/$SETTINGS_FILE $SETTINGS_DIR/$SETTINGS_FILE
RUN chown plejd:plejd "$SETTINGS_DIR"

ENV PYTHONPATH="$WORKDIR/.venv/lib/python3.11/site-packages:${PYTHONPATH}"

# Copy the built virtualenv deps from the builder stage
Expand All @@ -54,7 +49,7 @@ RUN ./.venv/bin/pip install "$WORKDIR"/*.whl

# Healthcheck
COPY healthcheck.py $WORKDIR/healthcheck.py
HEALTHCHECK --interval=5m --timeout=1s \
HEALTHCHECK --interval=1m --timeout=1s \
CMD python $WORKDIR/healthcheck.py --config $SETTINGS_DIR/$SETTINGS_FILE || exit 1

# Set the entrypoint
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ Configuration of the application. See example configuration [here](#example).
|------------------------------------------|--------------------------------------------------------|-------------|
| `health_check` (Optional) | Enable health check | True |
| `health_check_interval` (Optional) | Interval in seconds between writing health check files | 60.0 |
| `health_check_dir` (Optional) | Directory to store health check files | "/config" |
| `health_check_dir` (Optional) | Directory to store health check files | "~/.plejd/" |
| `health_check_bt_file` (Optional) | File name for Bluetooth health check | "bluetooth" |
| `health_check_mqtt_file` (Optional) | File name for MQTT health check | "mqtt" |
| `health_check_heartbeat_file` (Optional) | File name for heartbeat file | "heartbeat" |
Expand Down
3 changes: 2 additions & 1 deletion plejd_mqtt_ha/mdl/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
"""


import os
from typing import Optional

from pydantic import BaseModel, validator
Expand Down Expand Up @@ -99,7 +100,7 @@ class PlejdSettings(BaseModel):
"""Enable health check"""
health_check_interval: float = 60.0
"""Interval in seconds between writing health check files"""
health_check_dir: str = "/config/" # TODO: Does not belong here
health_check_dir: str = os.path.expanduser("~/.plejd/")
"""Directory to store health check files"""
health_check_bt_file: str = "bluetooth"
"""File name for bluetooth health check"""
Expand Down

0 comments on commit 8a140bc

Please sign in to comment.