FROM python:3.12

# Setup System
RUN sed -i 's@deb.debian.org@ftp.kaist.ac.kr@g' /etc/apt/sources.list.d/debian.sources
RUN pip install --upgrade pip
RUN apt update -y && apt upgrade -y && apt install -y cron

# Setup Crontab
WORKDIR /code
COPY crontab /code/crontab
COPY requirements.txt /code/requirements.txt
COPY app /code/app

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"]