FROM python:3.12-slim

# Pinned commit of the Turing Smart Screen library (we only need library/ and the fonts).
ARG LCD_COMMIT=2b33ab4f00a096916dd6a1174441a53a7ec33b03

WORKDIR /app

COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt

ADD https://github.com/mathoudebine/turing-smart-screen-python/archive/${LCD_COMMIT}.tar.gz /tmp/lcd.tar.gz
RUN mkdir -p /opt/lcd \
 && tar -xzf /tmp/lcd.tar.gz -C /opt/lcd --strip-components=1 \
      --wildcards '*/library' '*/res/fonts' \
 && rm /tmp/lcd.tar.gz

ENV LCD_LIB_PATH=/opt/lcd \
    PYTHONUNBUFFERED=1 \
    TZ=Europe/Prague

COPY render.py clock.py ./
CMD ["python", "clock.py"]
