FROM python:3.11-slim WORKDIR /app # Install PostgreSQL client (for pg_dump and psql) and cron RUN apt-get update && apt-get install -y \ postgresql-client \ cron \ && rm -rf /var/lib/apt/lists/* # Install Python dependencies COPY requirements.txt . RUN pip install --no-cache-dir -r requirements.txt # Copy application COPY . . # Make scripts executable RUN chmod +x backup.py restore.py # Setup cron COPY crontab /etc/cron.d/backup-cron RUN chmod 0644 /etc/cron.d/backup-cron RUN crontab /etc/cron.d/backup-cron # Create log file RUN touch /var/log/cron.log # Start cron in foreground and tail logs CMD ["sh", "-c", "printenv > /etc/environment && cron && tail -f /var/log/cron.log"]