FROM python:3.13-slim
COPY --from=ghcr.io/astral-sh/uv:latest /uv /uvx /bin/

WORKDIR /opt/tisbackup

COPY entrypoint.sh /entrypoint.sh
COPY . /opt/tisbackup

ENV DEBIAN_FRONTEND=noninteractive
ENV UV_PROJECT_ENVIRONMENT=/usr/local
ENV UV_PYTHON_DOWNLOADS=never

RUN apt-get update && apt-get upgrade -y \
   && apt-get install --no-install-recommends -y rsync ssh cron \
   && rm -rf /var/lib/apt/lists/* \
   #&& /usr/local/bin/python3.13 -m pip install --no-cache-dir -r requirements.txt \
   && uv sync --locked --no-dev --no-install-project \
   && rm -f /bin/uv /bin/uvx \
   && mkdir -p /var/spool/cron/crontabs \
   && echo '59 03 * * * root /bin/bash /opt/tisbackup/backup.sh' > /etc/crontab \
   && echo '' >> /etc/crontab \
   && crontab /etc/crontab

EXPOSE 8080

ENTRYPOINT ["/entrypoint.sh"]
CMD ["/usr/local/bin/python3.13","/opt/tisbackup/tisbackup_gui.py"]
