FROM debian:latest

# Install required packages
RUN apt-get update && apt-get install -y \
    cron \
    curl \
    tar \
    && rm -rf /var/lib/apt/lists/*

# Timezone
RUN apt update && apt install tzdata -y
ENV TZ="America/New_York"

# Create log directory
RUN mkdir -p /var/log && chmod 777 /var/log

# Copy the backup script into the container
COPY backup_script.sh /usr/local/bin/backup_script.sh

# Make the script executable
RUN chmod +x /usr/local/bin/backup_script.sh

# Add the cron job
RUN (crontab -l ; echo "0 0 * * * /usr/local/bin/backup_script.sh") | crontab -

# Copy the entrypoint script into the container
COPY entrypoint.sh /usr/local/bin/entrypoint.sh

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

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

