FROM python:3.12-slim

WORKDIR /opt/tisbackup

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

RUN apt update \ 
   && apt install --no-install-recommends -y rsync ssh cron \
   && rm -rf /var/lib/apt/lists/*

RUN /usr/local/bin/python3.12 -m pip install --no-cache-dir -r requirements.txt

RUN 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.12","/opt/tisbackup/tisbackup_gui.py"]

