From dc2d7568c984ea2271ef90caec041b69972bd2c3 Mon Sep 17 00:00:00 2001 From: Christopher Date: Thu, 9 May 2024 12:17:51 -0500 Subject: [PATCH] chore: Update genmon service Docker image to version 0.0.3 --- genmon/Dockerfile | 48 +++++++++++++++++++++++---------------- genmon/VERSION | 2 +- genmon/docker-compose.yml | 2 +- genmon/entrypoint.sh | 13 +++++++++++ 4 files changed, 44 insertions(+), 21 deletions(-) create mode 100644 genmon/entrypoint.sh diff --git a/genmon/Dockerfile b/genmon/Dockerfile index 8da0d8f..8f218fa 100644 --- a/genmon/Dockerfile +++ b/genmon/Dockerfile @@ -2,33 +2,43 @@ FROM python:3.8-slim # Base image python:3.8-slim is chosen for its minimal size while still providing Python 3.8. +# Set non-interactive mode and define timezone to avoid unnecessary prompts during build. +ENV DEBIAN_FRONTEND=noninteractive TZ="America/Chicago" + # 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/* -# 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. +# Combine update, install, and cleanup in a single RUN to minimize layer size. +RUN apt-get update && apt-get install -y --no-install-recommends \ + git sudo cron net-tools && \ + apt-get clean && \ + rm -rf /var/lib/apt/lists/* /var/cache/apt/* -# Expose ports for SSH, HTTPS, and a application port to get to the genmon application. -EXPOSE 22 443 8000 +# Expose necessary ports for HTTPS, and the application. +EXPOSE 443 8000 # Set the working directory for any subsequent instructions. WORKDIR /git -# '/git' directory will hold all our application files. -# Clone the repository and prepare it for use. -RUN git clone http://github.com/jgyates/genmon.git && \ +# Configure application settings via environment variables. +ENV USE_SERIAL_TCP=true + +# Clone the repository with shallow clone to minimize data pulled. +RUN git clone --depth 1 http://github.com/jgyates/genmon.git && \ 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. # 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 -# Run initial setup scripts and modify the configuration to enable TCP for serial communications. +RUN /git/genmon/genmonmaint.sh -i -n +# Run initial setup scripts. + +# Clean up apt caches. +RUN apt-get clean && \ + rm -rf /var/lib/apt/lists/* /var/cache/apt/* + +# Copy the entrypoint script to the container. +COPY entrypoint.sh /entrypoint.sh + +# Make the entrypoint script executable. +RUN chmod +x /entrypoint.sh -# 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. +# Set the custom entrypoint script as the entrypoint +ENTRYPOINT ["/entrypoint.sh"] diff --git a/genmon/VERSION b/genmon/VERSION index 4e379d2..bcab45a 100644 --- a/genmon/VERSION +++ b/genmon/VERSION @@ -1 +1 @@ -0.0.2 +0.0.3 diff --git a/genmon/docker-compose.yml b/genmon/docker-compose.yml index 04336ec..8c973c9 100644 --- a/genmon/docker-compose.yml +++ b/genmon/docker-compose.yml @@ -6,7 +6,7 @@ services: # 'big-bear-genmon' is the name of the service big-bear-genmon: # Specifies the Docker image to use for the big-bear-genmon service - image: bigbeartechworld/big-bear-genmon:0.0.2 + image: bigbeartechworld/big-bear-genmon:0.0.3 # Environment variables to set inside the container environment: - TZ=America/Chicago # Set the timezone to 'America/Chicago' diff --git a/genmon/entrypoint.sh b/genmon/entrypoint.sh new file mode 100644 index 0000000..6a68f35 --- /dev/null +++ b/genmon/entrypoint.sh @@ -0,0 +1,13 @@ +#!/bin/bash + +# Ensure the non-root user can write where necessary +touch /var/log/startup.log + +# If you need to modify configurations owned by root, you need to adjust this beforehand or run as root +sed -i "s/use_serial_tcp = .*/use_serial_tcp = $USE_SERIAL_TCP/g" /etc/genmon/genmon.conf + +# Start the application +/git/genmon/startgenmon.sh start + +# Follow the log for outputs +tail -F /var/log/startup.log