35 lines
1.2 KiB
Docker
35 lines
1.2 KiB
Docker
FROM python:3.12-slim
|
|
|
|
WORKDIR /
|
|
|
|
# Install system dependencies and Poetry
|
|
RUN apt-get update && apt-get install -y --no-install-recommends gcc && rm -rf /var/lib/apt/lists/* && pip install --no-cache-dir poetry
|
|
|
|
# Copy Poetry configuration
|
|
COPY /BankServices/RoutineEmailService/pyproject.toml ./pyproject.toml
|
|
|
|
# Configure Poetry and install dependencies with optimizations
|
|
RUN poetry config virtualenvs.create false && poetry install --no-interaction --no-ansi --no-root --only main && pip cache purge && rm -rf ~/.cache/pypoetry
|
|
|
|
# Install cron for scheduling tasks
|
|
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 /app.py >> /var/log/cron.log 2>&1" > /tmp/crontab_list && crontab /tmp/crontab_list
|
|
|
|
# Copy application code
|
|
COPY /BankServices/RoutineEmailService /
|
|
|
|
COPY /Schemas /Schemas
|
|
COPY /Controllers /Controllers
|
|
COPY /BankServices/ServiceDepends /
|
|
|
|
# Set Python path to include app directory
|
|
ENV PYTHONPATH=/ PYTHONUNBUFFERED=1 PYTHONDONTWRITEBYTECODE=1
|
|
|
|
# Create log file to grab cron logs
|
|
RUN touch /var/log/cron.log
|
|
|
|
# Run cron setup and tail the log file for user to monitor logs
|
|
CMD cron && tail -f /var/log/cron.log
|