# Use the official Ubuntu as the base image
FROM ubuntu:latest

# Install dependencies
RUN apt-get update && apt-get install -y \
    cron \
    calibre \
    && rm -rf /var/lib/apt/lists/*

# Create a directory for Calibre library
RUN mkdir -p /calibre/library

# Copy your cron job file into the container
COPY crontab /etc/cron.d/calibre-cron

# Give execution rights to the cron job
RUN chmod 0644 /etc/cron.d/calibre-cron

# Apply the cron job
RUN crontab /etc/cron.d/calibre-cron

# Create the log file (optional, for debugging)
RUN touch /var/log/calibre-cron.log

# Set the working directory
WORKDIR /calibre

# Start cron in the foreground
CMD ["cron", "-f"]
