-
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: Update Dockerfile for genmon service
- Loading branch information
1 parent
b7e49c8
commit 7488665
Showing
1 changed file
with
18 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,34 @@ | ||
# Use a specific tag for a stable and predictable base image | ||
# Use a specific tag for a stable and predictable base image. | ||
FROM python:3.8-slim | ||
# This line specifies the base image for the Docker container. Here, it uses 'python:3.8-slim', which is a minimal version of a Python 3.8 image. This is useful for keeping the image size small while having Python pre-installed. | ||
# Base image python:3.8-slim is chosen for its minimal size while still providing Python 3.8. | ||
|
||
# Install required packages in one layer to reduce image size | ||
# Install essential packages in one layer to reduce the image size. | ||
RUN apt update && apt upgrade -y && \ | ||
DEBIAN_FRONTEND="noninteractive" TZ="America/Chicago" apt install -y --no-install-recommends \ | ||
git sudo cron net-tools nano && \ | ||
rm -rf /var/lib/apt/lists/* | ||
# This command updates and upgrades the system packages, installs essential tools (sudo, cron, net-tools, nano) without additional recommended packages to keep the image size down, and sets the timezone. It then cleans up the apt cache by removing '/var/lib/apt/lists/*' to further reduce the image size. | ||
# Update and upgrade packages, install necessary tools (git, sudo, cron, net-tools, nano) for the application. | ||
# Non-interactive mode is used to avoid hanging during build due to user prompts. | ||
# Clean up after install reduces image layers and size. | ||
|
||
# Expose multiple ports in a single line | ||
# Expose ports for SSH, HTTPS, and a application port to get to the genmon application. | ||
EXPOSE 22 443 8000 | ||
|
||
# Use WORKDIR to change directory | ||
# Set the working directory for any subsequent instructions. | ||
WORKDIR /git | ||
# Sets the working directory for any RUN, CMD, ENTRYPOINT, COPY, and ADD instructions that follow in the Dockerfile. If the directory does not exist, it will be created automatically. In this case, '/git' is set as the working directory. | ||
# '/git' directory will hold all our application files. | ||
|
||
# Clone the repository in a single RUN command to reduce layers | ||
# Clone the repository and prepare it for use. | ||
RUN git clone http://github.com/jgyates/genmon.git && \ | ||
chmod 775 /git/genmon/startgenmon.sh /git/genmon/genmonmaint.sh | ||
# This command clones a Git repository into the container and changes the permissions of specific scripts to ensure they are executable. Cloning and modifying permissions in one RUN statement reduces the number of layers created. | ||
chmod 775 /git/genmon/startgenmon.sh /git/genmon/genmonmaint.sh && \ | ||
rm -rf /git/genmon/.git | ||
# Clone the genmon repository, modify script permissions to make them executable, and remove the .git directory to conserve space. | ||
|
||
# Use absolute paths and combine commands for initialization | ||
# Initialize the application and configure it. | ||
RUN /git/genmon/genmonmaint.sh -i -n && \ | ||
sed -i 's/use_serial_tcp = False/use_serial_tcp = True/g' /etc/genmon/genmon.conf | ||
# This RUN command performs two actions: it runs a script for initial setup with flags '-i -n' and modifies the 'genmon.conf' configuration file to change a setting. Using absolute paths ensures that the commands are executed in the correct directory regardless of the current WORKDIR. | ||
# Run initial setup scripts and modify the configuration to enable TCP for serial communications. | ||
|
||
# Use CMD to define the default command to run when starting the container | ||
CMD ["/bin/bash", "-c", "/git/genmon/startgenmon.sh start && tail -F /var/log/startup.log"] | ||
# This CMD instruction specifies the default command to run when the container starts. It starts a script and then follows the log file, allowing the logs to be read directly from the container's standard output. | ||
# Define the default command to run within the container. | ||
CMD ["/bin/bash", "-c", "touch /var/log/startup.log && /git/genmon/startgenmon.sh start && tail -F /var/log/startup.log"] | ||
# Ensure the startup log exists, start the genmon application, and follow the startup log for debugging and monitoring. |