wag-services-and-backend-la.../BankServices/RoutineEmailService/Dockerfile

43 lines
1.5 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
ADD /BankServices/RoutineEmailService /
ADD /ApiLayers/AllConfigs/Email /ApiLayers/AllConfigs/Email
ADD /Configs /Configs
ADD /Schemas /Schemas
ADD /Commons /Commons
ADD /BankServices/ServiceDepends/template_accounts.html /templates/template_accounts.html
ADD /Services/MongoService /Services/MongoService
ADD /Services/PostgresService /Services/PostgresService
ADD /Services/EmailService /Services/EmailService
# 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