implement docker remote and local cron job
This commit is contained in:
18
Dockerfile
18
Dockerfile
@@ -1,6 +1,10 @@
|
||||
# Use Ubuntu 20.04 as the base image
|
||||
FROM ubuntu:20.04
|
||||
|
||||
# Set environment variables to avoid interactive prompts
|
||||
ENV DEBIAN_FRONTEND=noninteractive
|
||||
ENV TZ=America/Chicago
|
||||
|
||||
# Install dependencies
|
||||
RUN apt-get update && apt-get install -y \
|
||||
sqlite3 \
|
||||
@@ -10,11 +14,12 @@ RUN apt-get update && apt-get install -y \
|
||||
gzip \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
ARG CACHE_BUST=1
|
||||
|
||||
# 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
|
||||
@@ -23,7 +28,6 @@ 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
|
||||
@@ -35,5 +39,11 @@ 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"]
|
||||
# Copy the entrypoint script
|
||||
COPY entrypoint.sh /entrypoint.sh
|
||||
|
||||
# Make the entrypoint script executable
|
||||
RUN chmod +x /entrypoint.sh
|
||||
|
||||
# Use the entrypoint script to start the container
|
||||
CMD ["/entrypoint.sh"]
|
||||
|
||||
Reference in New Issue
Block a user