aboutsummaryrefslogtreecommitdiffstats
path: root/Dockerfile
blob: 258d7f80e6b2e6f347c6299bb38113d8e593f401 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# Use the Debian base image
FROM debian:stable-slim

# Set environment variables to prevent interactive prompts during apt operations
ENV DEBIAN_FRONTEND=noninteractive

# Install necessary packages:
# git: for cloning and updating the repository
# libmojolicious-perl, libdbi-perl, libfile-slurp-perl, libdbd-sqlite3-perl: Perl modules required by KISSmo Perl
# ca-certificates: essential for SSL certificate verification during git clone
# cron: for scheduling periodic updates and restarts
RUN apt update && \
    apt install -y --no-install-recommends \
    git \
    libmojolicious-perl \
    libdbi-perl \
    libfile-slurp-perl \
    libdbd-sqlite3-perl \
    ca-certificates \
    cron && \
    # Ensure CA certificates are up-to-date
    update-ca-certificates && \
    # Clean up apt cache to reduce image size
    rm -rf /var/lib/apt/lists/*

# Clone the KISSmo Perl repository into the /app directory
RUN git clone https://git.hax.al/KISSmoPerl/ /app

# Set the working directory for subsequent commands
WORKDIR /app

# Create the SQLite database file and the 'pastes' directory
# These are required by the KISSmo Perl application for data storage
RUN touch pastes.db && mkdir pastes

# Copy the update script into the container and make it executable
# This script will handle git pull and restarting the perl application
COPY update_kissmo.sh /usr/local/bin/update_kissmo.sh
RUN chmod +x /usr/local/bin/update_kissmo.sh

# Add the cron job to run the update script
# The job is scheduled to run at midnight (00:00) on the 1st and 21st day of every month.
# Output from the script will be logged to /var/log/cron.log
RUN (crontab -l 2>/dev/null; echo "0 0 1,21 * * /usr/local/bin/update_kissmo.sh >> /var/log/cron.log 2>&1") | crontab -

# Copy the entrypoint script and make it executable
COPY entrypoint.sh /usr/local/bin/entrypoint.sh
RUN chmod +x /usr/local/bin/entrypoint.sh

# Expose port 7878, which is the port KISSmo Perl listens on
EXPOSE 7878

# Use the exec form for CMD, pointing to the entrypoint script
CMD ["/usr/local/bin/entrypoint.sh"]