FROM mysql:8.0.41-bookworm # Install cron and other required tools RUN apt-get update && apt-get install -y \ mysql-client \ cron \ openssl \ zip \ rsync \ unzip \ && rm -rf /var/lib/apt/lists/* # Create necessary directories RUN mkdir -p /opt/backups /opt/backups/tmp /var/log/backup /etc/cron.d # Copy scripts COPY backup.sh /usr/local/bin/backup.sh COPY create_admin.sh /usr/local/bin/create_admin.sh COPY entrypoint.sh /entrypoint.sh # Make scripts executable RUN chmod +x /usr/local/bin/backup.sh \ && chmod +x /usr/local/bin/create_admin.sh \ && chmod +x /entrypoint.sh # Setup cron jobs RUN echo "0 * * * * root /usr/local/bin/backup.sh --hourly >> /var/log/backup/hourly.log 2>&1" > /etc/cron.d/backup-cron && \ echo "0 0 * * * root /usr/local/bin/backup.sh --daily >> /var/log/backup/daily.log 2>&1" >> /etc/cron.d/backup-cron && \ echo "0 0 * * 0 root /usr/local/bin/backup.sh --weekly >> /var/log/backup/weekly.log 2>&1" >> /etc/cron.d/backup-cron && \ chmod 0644 /etc/cron.d/backup-cron EXPOSE 3306 # Use our custom entrypoint ENTRYPOINT ["/entrypoint.sh"]