Skip to content

Commit

Permalink
Add docker image for genmon
Browse files Browse the repository at this point in the history
  • Loading branch information
dragonfire1119 committed May 9, 2024
1 parent 1ea6a55 commit 12d4f27
Show file tree
Hide file tree
Showing 7 changed files with 156 additions and 0 deletions.
46 changes: 46 additions & 0 deletions .github/workflows/build_and_release_for_genmon.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: "Build and release for genmon"

on:
push:
branches:
- main
- add-genmon

jobs:
create:
name: "Creates the newest release by version"
runs-on: "ubuntu-latest"

steps:
- name: Checkout project
uses: actions/[email protected]

# New step to read the VERSION file and set the version as an output
- name: Get the version
id: get_version
run: echo "genmon_version=$(cat genmon/VERSION)" >> $GITHUB_ENV

- name: Set up QEMU
uses: docker/setup-qemu-action@master
with:
platforms: all

- name: Set up Docker Build
uses: docker/setup-buildx-action@v3

- name: Login to DockerHub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Build and push
uses: docker/build-push-action@v3
with:
push: true
platforms: linux/amd64,linux/arm64
context: ./genmon
file: ./genmon/Dockerfile
tags: |
bigbeartechworld/big-bear-genmon:latest
bigbeartechworld/big-bear-genmon:${{ env.genmon_version }}
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,5 @@ pocketbase/build.log
pocketbase/build.sh
pihole-unbound/build.log
pihole-unbound/build.sh
genmon/build.log
genmon/build.sh
44 changes: 44 additions & 0 deletions genmon/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# Use a specific tag for a stable and predictable base image.
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.
# 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 necessary ports for HTTPS, and the application.
EXPOSE 443 8000

# Set the working directory for any subsequent instructions.
WORKDIR /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

# Initialize the application and configure it.
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

# Set the custom entrypoint script as the entrypoint
ENTRYPOINT ["/entrypoint.sh"]
17 changes: 17 additions & 0 deletions genmon/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Instructions to build and run the Docker image

# Build docker image with:

```
docker build . -t genmon
```

# Start the docker instance with:

```
docker run -it -p 8000:8000 -d genmon
```

## Credits

https://github.com/skipfire/genmon-addon/tree/main/docker
1 change: 1 addition & 0 deletions genmon/VERSION
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
0.0.3
33 changes: 33 additions & 0 deletions genmon/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# This specifies the version of the Docker Compose file format
version: "3.8"

# Define the services that make up your application so they can be run together in an isolated environment
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.3
# Environment variables to set inside the container
environment:
- TZ=America/Chicago # Set the timezone to 'America/Chicago'
# Ports to expose, mapping the host port to the container port
ports:
- "20022:22" # Map TCP port 22 in the container to port 20022 on the host
- "38443:443" # Map TCP port 443 in the container to port 38443 on the host
- "8000:8000" # Map TCP port 8000 in the container to port 8000 on the host
# Define the restart policy for the service container
restart: unless-stopped # Restart the container unless it is explicitly stopped
# Mount host paths or named volumes into the container
volumes:
- big_bear_genmon_data:/git/genmon # Mount a named volume 'big_bear_genmon_data' to store data persistently at /git/genmon in the container
- big_bear_genmon_config:/etc/genmon # Mount a named volume 'big_bear_genmon_config' to store configuration files persistently at /etc/genmon in the container
- big_bear_genmon_logs:/var/log # Mount a named volume 'big_bear_genmon_logs' to store logs persistently at /var/log in the container

# Define volumes used by the services
volumes:
big_bear_genmon_data: # Define a volume for persistent data storage
driver: local # Use the local driver for persistent data storage
big_bear_genmon_config: # Define a volume for persistent configuration storage
driver: local # Use the local driver for persistent configuration storage
big_bear_genmon_logs: # Define a volume for persistent log storage
driver: local # Use the local driver for persistent log storage
13 changes: 13 additions & 0 deletions genmon/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 12d4f27

Please sign in to comment.