40 lines
895 B
Docker
40 lines
895 B
Docker
# Use Ubuntu 20.04 as the base image
|
|
FROM ubuntu:20.04
|
|
|
|
# Install dependencies
|
|
RUN apt-get update && apt-get install -y \
|
|
sqlite3 \
|
|
awscli \
|
|
cron \
|
|
tar \
|
|
gzip \
|
|
&& rm -rf /var/lib/apt/lists/*
|
|
|
|
# Create necessary directories
|
|
RUN mkdir -p /jobs/data/sqlite
|
|
RUN mkdir -p /var/tmp
|
|
|
|
# Copy the backup script into the container
|
|
COPY backup_sqlite.sh /usr/local/bin/backup_script.sh
|
|
|
|
# Make the script executable
|
|
RUN chmod +x /usr/local/bin/backup_script.sh
|
|
|
|
# Create the cron log file
|
|
RUN touch /var/log/cron.log
|
|
|
|
# Copy the cron job file into the cron.d directory
|
|
COPY backup_cron /etc/cron.d/backup_cron
|
|
|
|
# Set permissions for the cron job file
|
|
RUN chmod 0644 /etc/cron.d/backup_cron
|
|
|
|
# Apply the cron job
|
|
RUN crontab /etc/cron.d/backup_cron
|
|
|
|
# Expose the cron log file as a volume
|
|
VOLUME /var/log
|
|
|
|
# Start cron in the foreground when the container starts
|
|
CMD ["cron", "-f"]
|