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

# Install dependencies
RUN apt-get update && apt-get install -y \
    vim \
    cron \
    tzdata \
    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 calibre-cron /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


# Create a directory for custom cron jobs (optional)
RUN mkdir -p /etc/cron.d

# Set the working directory
WORKDIR /calibre

# Copy the entrypoint script into the container
COPY entrypoint.sh /entrypoint.sh

# Make the entrypoint script executable
RUN chmod +x /entrypoint.sh

# Set the entrypoint to the script
ENTRYPOINT ["/entrypoint.sh"]
