FROM python:3.12

RUN sed -i 's@deb.debian.org@ftp.kaist.ac.kr@g' /etc/apt/sources.list.d/debian.sources

# Setup Crontab

WORKDIR /code
COPY crontab /code/crontab
COPY requirements.txt /code/requirements.txt
COPY app /code/app

RUN apt update && apt -y install cron

COPY crontab /etc/cron.d/crontab
RUN chmod 0644 /etc/cron.d/crontab
RUN echo "" >> /etc/cron.d/crontab  # Ensure newline at end of file
RUN /usr/bin/crontab /etc/cron.d/crontab

# Setup Python Environment
WORKDIR /code
RUN pip config set global.break-system-packages true
RUN pip install -r requirements.txt

RUN rm -rf /etc/localtime
RUN ln -sf /usr/share/zoneinfo/Asia/Seoul /etc/localtime

CMD ["cron", "-f"]