FROM debian:latest

RUN apt update
RUN apt install -y python3-pip python3-venv pipx curl locales
RUN pipx install lektor
RUN mkdir -p /opt/lektor/project && mkdir -p /opt/lektor/output
RUN sed -i '/de_DE.UTF-8/s/^# //g' /etc/locale.gen && locale-gen

RUN python3 -m venv /opt/venv

RUN . /opt/venv/bin/activate && pip install ics requests bs4

COPY entrypoint.sh /opt/entrypoint.sh
RUN chmod +x /opt/entrypoint.sh

WORKDIR /opt/lektor/project

ENV PATH="$PATH:/root/.local/bin"
ENV CALENDAR_URL="https://backoffice.pc-stammertal.ch/remote.php/dav/public-calendars/RqLX5wj25aY6cpnP?export"

ENTRYPOINT ["/opt/entrypoint.sh"]

CMD /root/.local/bin/lektor --project /opt/lektor/project server --host 0.0.0.0