FROM python:3.10-slim

ENV PYTHONDONTWRITEBYTECODE 1
ENV PYTHONUNBUFFERED 1

COPY ../service_app_banks/mailserver.requirements.txt .

RUN pip install --upgrade pip
RUN pip install --no-cache-dir --upgrade -r mailserver.requirements.txt

COPY ../service_app_banks ./service_app_banks
COPY ../api_library ./service_app_banks/api_library
COPY ../api_services ./service_app_banks/api_services
COPY ../databases ./service_app_banks/databases
COPY ../api_configs ./service_app_banks/api_configs
COPY ../api_objects ./service_app_banks/api_objects
COPY ../api_validations ./service_app_banks/api_validations
#COPY ../service_app_banks/crontab_list /service_app_banks/crontab_to_write

RUN apt-get update && apt-get install -y cron

# 11:00 Istanbul Time (UTC+3) system time is 08:00 UTC
RUN echo "0 8 * * * /usr/local/bin/python /service_app_banks/app_mail_sender.py >> /var/log/cron.log 2>&1" > /tmp/crontab_list && crontab /tmp/crontab_list
RUN echo "*/15 * * * * /usr/local/bin/python /service_app_banks/isbank/main_single_thread.py >> /var/log/cron.log 2>&1" >> /tmp/crontab_list && crontab /tmp/crontab_list
#RUN echo /service_app_banks/crontab_to_write > /tmp/crontab_list
#RUN crontab /tmp/crontab_list

RUN touch /var/log/cron.log

CMD cron && tail -f /var/log/cron.log

#RUN chmod 0644 /etc/cron.d/app_mail_sender_cron
#RUN crontab /etc/cron.d/send_email_cron
#CMD ["python", "-m", "app_mail_sender"]
