Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nx Go Support #172

Merged
merged 13 commits into from
Aug 30, 2024
Merged
4 changes: 3 additions & 1 deletion .github/workflows/DockerHubDescription.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ on:
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
description:
name: "Update Docker Hub Description"
Expand All @@ -22,6 +22,8 @@ jobs:
matrix:
repos:
[
ptr727/nxgo,
ptr727/nxgo-lsio,
ptr727/nxmeta,
ptr727/nxmeta-lsio,
ptr727/nxwitness,
Expand Down
3 changes: 2 additions & 1 deletion CreateMatrix/JSON/Version.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"Product": {
"enum": [
"None",
"NxGo",
"NxMeta",
"NxWitness",
"DWSpectrum"
Expand Down Expand Up @@ -57,4 +58,4 @@
"title": "CreateMatrix Version Schema",
"$id": "https://raw.githubusercontent.com/ptr727/NxWitness/main/CreateMatrix/JSON/Version.schema.json",
"$schema": "https://json-schema.org/draft/2020-12/schema"
}
}
20 changes: 12 additions & 8 deletions CreateMatrix/ProductInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ public class ProductInfo
public enum ProductType
{
None,
NxGo,
NxMeta,
NxWitness,
DWSpectrum,
Expand All @@ -35,6 +36,7 @@ public static string GetRelease(ProductType productType)
{
return productType switch
{
ProductType.NxGo => "nxgo",
ProductType.NxMeta => "metavms",
ProductType.NxWitness => "default",
ProductType.DWSpectrum => "digitalwatchdog",
Expand All @@ -48,6 +50,7 @@ public static string GetCompany(ProductType productType)
{
return productType switch
{
ProductType.NxGo => "networkoptix",
ProductType.NxMeta => "networkoptix-metavms",
ProductType.NxWitness => "networkoptix",
ProductType.DWSpectrum => "digitalwatchdog",
Expand All @@ -61,6 +64,7 @@ public static string GetDescription(ProductType productType)
{
return productType switch
{
ProductType.NxGo => "Nx Go VMS",
ProductType.NxMeta => "Nx Meta VMS",
ProductType.NxWitness => "Nx Witness VMS",
ProductType.DWSpectrum => "DW Spectrum IPVMS",
Expand Down Expand Up @@ -93,7 +97,7 @@ public void GetVersions()
// Match the logic with ReleasesTests.CreateProductInfo()
// TODO: Refactor to reduce duplication and chance of divergence

// Get version information using releases.json and package.json
// Get version information using releases.json and package.json
Log.Logger.Information("{Product}: Getting online release information...", Product);
try
{
Expand Down Expand Up @@ -135,7 +139,7 @@ public void GetVersions()
versionInfo.UriArm64 = $"https://updates.networkoptix.com/{GetRelease()}/{buildNumber}/{packageArm64.File}";

// Verify and add to list
if (VerifyVersion(versionInfo))
if (VerifyVersion(versionInfo))
Versions.Add(versionInfo);
}

Expand All @@ -154,9 +158,9 @@ private bool VerifyVersion(VersionInfo versionInfo)
// Static rules:

// Ubuntu Jammy requires version 5.1 or later
if (versionInfo.CompareTo("5.1") >= 0)
if (versionInfo.CompareTo("5.1") >= 0)
return true;

Log.Logger.Warning("{Product}:{Version} : Ubuntu Jammy requires v5.1+", Product, versionInfo.Version);
return false;
}
Expand All @@ -177,9 +181,9 @@ public void AddLabel(VersionInfo versionInfo, VersionInfo.LabelType label)
}

// Is this version larger than the other version
if (versionInfo.CompareTo(existingVersion) <= 0)
if (versionInfo.CompareTo(existingVersion) <= 0)
return;

Log.Logger.Warning("{Product}: Replacing {Label} from {ExistingVersion} to {NewVersion}", Product, label, existingVersion.Version, versionInfo.Version);

// Remove from other version and add to this version
Expand Down Expand Up @@ -250,7 +254,7 @@ public void VerifyUrls()
{
using HttpClient httpClient = new();
foreach (var versionUri in Versions)
{
{
// Will throw on error
VerifyUrl(httpClient, versionUri.UriX64);
VerifyUrl(httpClient, versionUri.UriArm64);
Expand Down Expand Up @@ -301,4 +305,4 @@ public void Verify()
// Verify labels
VerifyLabels();
}
}
}
111 changes: 111 additions & 0 deletions Docker/NxGo-LSIO.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
# Dockerfile created by CreateMatrix, do not modify by hand
# Product: NxGo
# Description: Nx Go VMS
# Company: networkoptix
# Release: nxgo
# LSIO: True

# https://support.networkoptix.com/hc/en-us/articles/205313168-Nx-Witness-Operating-System-Support
# Latest Ubuntu supported for v5.1 is Jammy
FROM lsiobase/ubuntu:jammy

# Labels
ARG LABEL_NAME="NxGo-LSIO"
ARG LABEL_DESCRIPTION="Nx Go VMS"
ARG LABEL_VERSION="6.0.0.38908"

# Download URL and version
# Current values are defined by the build pipeline
ARG DOWNLOAD_X64_URL="https://updates.networkoptix.com/nxgo/39242/linux/nxgo-server-6.0.0.38908-linux_x64.deb"
ARG DOWNLOAD_ARM64_URL="https://updates.networkoptix.com/nxgo/39242/arm/nxgo-server-6.0.0.38908-linux_arm64.deb"
ARG DOWNLOAD_VERSION="6.0.0.38908"

# Used for ${COMPANY_NAME} setting the server user and install directory
ARG RUNTIME_NAME="networkoptix"

# Global builder variables
# https://docs.docker.com/engine/reference/builder/#automatic-platform-args-in-the-global-scope
ARG \
# Platform of the build result. Eg linux/amd64, linux/arm/v7, windows/amd64
TARGETPLATFORM \
# Architecture component of TARGETPLATFORM
TARGETARCH \
# Platform of the node performing the build
BUILDPLATFORM

# The RUN wget command will be cached unless we change the cache tag
# Use the download version for the cache tag
ARG CACHE_DATE=${DOWNLOAD_VERSION}

# Prevent EULA and confirmation prompts in installers
ARG DEBIAN_FRONTEND=noninteractive

# Media server user and directory name
ENV COMPANY_NAME=${RUNTIME_NAME}

# Labels
LABEL name=${LABEL_NAME}-${DOWNLOAD_VERSION} \
description=${LABEL_DESCRIPTION} \
version=${LABEL_VERSION} \
maintainer="Pieter Viljoen <[email protected]>"

# Install required tools and utilities
RUN apt-get update \
&& apt-get upgrade --yes \
&& apt-get install --no-install-recommends --yes \
ca-certificates \
unzip \
wget

# Download the installer file
RUN mkdir -p /temp
COPY download.sh /temp/download.sh
# Set the working directory to /temp
WORKDIR /temp
RUN chmod +x download.sh \
&& ./download.sh

# LSIO maps the host PUID and PGID environment variables to "abc" in the container.
# The mediaserver calls "chown ${COMPANY_NAME}" at runtime
# We have to match the ${COMPANY_NAME} username with the LSIO "abc" usernames
# LSIO does not officially support changing the "abc" username
# https://discourse.linuxserver.io/t/changing-abc-container-user/3208
# https://github.com/linuxserver/docker-baseimage-ubuntu/blob/jammy/root/etc/s6-overlay/s6-rc.d/init-adduser/run
# Change user "abc" to ${COMPANY_NAME}
RUN usermod -l ${COMPANY_NAME} abc \
# Change group "abc" to ${COMPANY_NAME}
&& groupmod -n ${COMPANY_NAME} abc \
# Replace "abc" with ${COMPANY_NAME}
&& sed -i "s/abc/\${COMPANY_NAME}/g" /etc/s6-overlay/s6-rc.d/init-adduser/run

# Install the mediaserver and dependencies
RUN apt-get update \
&& apt-get install --no-install-recommends --yes \
gdb \
./vms_server.deb \
# Cleanup
&& apt-get clean \
&& apt-get autoremove --purge \
&& rm -rf /var/lib/apt/lists/* \
&& rm -rf /temp

# Set ownership permissions
RUN chown --verbose ${COMPANY_NAME}:${COMPANY_NAME} /opt/${COMPANY_NAME}/mediaserver/bin \
&& chown --verbose ${COMPANY_NAME}:${COMPANY_NAME} /opt/${COMPANY_NAME}/mediaserver/bin/external.dat

# Copy etc init and services files
# https://github.com/just-containers/s6-overlay#container-environment
# https://www.linuxserver.io/blog/how-is-container-formed
COPY s6-overlay /etc/s6-overlay

# Expose port 7001
EXPOSE 7001

# Create mount points
# Links will be created at runtime in LSIO/etc/s6-overlay/s6-rc.d/init-nx-relocate/run
# /opt/${COMPANY_NAME}/mediaserver/etc -> /config/etc
# /opt/${COMPANY_NAME}/mediaserver/var -> /config/var
# /root/.config/nx_ini links -> /config/ini
# /config is for configuration
# /media is for media recording
VOLUME /config /media
103 changes: 103 additions & 0 deletions Docker/NxGo.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
# Dockerfile created by CreateMatrix, do not modify by hand
# Product: NxGo
# Description: Nx Go VMS
# Company: networkoptix
# Release: nxgo
# LSIO: False

# https://support.networkoptix.com/hc/en-us/articles/205313168-Nx-Witness-Operating-System-Support
# Latest Ubuntu supported for v5.1 is Jammy
FROM ubuntu:jammy

# Labels
ARG LABEL_NAME="NxGo"
ARG LABEL_DESCRIPTION="Nx Go VMS"
ARG LABEL_VERSION="6.0.0.38908"

# Download URL and version
# Current values are defined by the build pipeline
ARG DOWNLOAD_X64_URL="https://updates.networkoptix.com/nxgo/39242/linux/nxgo-server-6.0.0.38908-linux_x64.deb"
ARG DOWNLOAD_ARM64_URL="https://updates.networkoptix.com/nxgo/39242/arm/nxgo-server-6.0.0.38908-linux_arm64.deb"
ARG DOWNLOAD_VERSION="6.0.0.38908"

# Used for ${COMPANY_NAME} setting the server user and install directory
ARG RUNTIME_NAME="networkoptix"

# Global builder variables
# https://docs.docker.com/engine/reference/builder/#automatic-platform-args-in-the-global-scope
ARG \
# Platform of the build result. Eg linux/amd64, linux/arm/v7, windows/amd64
TARGETPLATFORM \
# Architecture component of TARGETPLATFORM
TARGETARCH \
# Platform of the node performing the build
BUILDPLATFORM

# The RUN wget command will be cached unless we change the cache tag
# Use the download version for the cache tag
ARG CACHE_DATE=${DOWNLOAD_VERSION}

# Prevent EULA and confirmation prompts in installers
ARG DEBIAN_FRONTEND=noninteractive

# Media server user and directory name
ENV COMPANY_NAME=${RUNTIME_NAME}

# Labels
LABEL name=${LABEL_NAME}-${DOWNLOAD_VERSION} \
description=${LABEL_DESCRIPTION} \
version=${LABEL_VERSION} \
maintainer="Pieter Viljoen <[email protected]>"

# Install required tools and utilities
RUN apt-get update \
&& apt-get upgrade --yes \
&& apt-get install --no-install-recommends --yes \
ca-certificates \
unzip \
wget

# Download the installer file
RUN mkdir -p /temp
COPY download.sh /temp/download.sh
# Set the working directory to /temp
WORKDIR /temp
RUN chmod +x download.sh \
&& ./download.sh

# Install the mediaserver and dependencies
RUN apt-get update \
&& apt-get install --no-install-recommends --yes \
gdb \
sudo \
./vms_server.deb \
# Cleanup
&& apt-get clean \
&& apt-get autoremove --purge \
&& rm -rf /var/lib/apt/lists/* \
&& rm -rf /temp

# Add the mediaserver ${COMPANY_NAME} user to the sudoers group
# Only allow sudo no password access to the root-tool
RUN echo "${COMPANY_NAME} ALL = NOPASSWD: /opt/${COMPANY_NAME}/mediaserver/bin/root-tool" > /etc/sudoers.d/${COMPANY_NAME}

# Copy the entrypoint.sh launch script
# entrypoint.sh will run the mediaserver and root-tool
COPY entrypoint.sh /opt/entrypoint.sh
RUN chmod +x /opt/entrypoint.sh

# Run the entrypoint as the mediaserver ${COMPANY_NAME} user
# Note that this user exists in the container and does not directly map to a user on the host
USER ${COMPANY_NAME}

# Runs entrypoint.sh on container start
ENTRYPOINT ["/opt/entrypoint.sh"]

# Expose port 7001
EXPOSE 7001

# Link volumes directly, e.g.
# /mnt/config/etc:opt/networkoptix/mediaserver/etc
# /mnt/config/nx_ini:/home/networkoptix/.config/nx_ini
# /mnt/config/var:/opt/networkoptix/mediaserver/var
# /mnt/media:/media
1 change: 1 addition & 0 deletions Make/Build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ function BuildDockerfile {
docker buildx create --name "nxwitness" --use || true

# Build Dockerfiles
BuildDockerfile "NxGo"
BuildDockerfile "NxMeta"
BuildDockerfile "NxMeta-LSIO"
BuildDockerfile "NxWitness"
Expand Down
1 change: 1 addition & 0 deletions Make/Clean.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ function DeleteImage {
./Down.sh

# Delete images
DeleteImage "NxGo"
DeleteImage "NxMeta"
DeleteImage "NxMeta-LSIO"
DeleteImage "NxWitness"
Expand Down
18 changes: 10 additions & 8 deletions Make/Instructions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@

# Instructions
echo "Ctrl-Click on links to launch web UI in browser"
echo "Nx Meta:" "https://$HOSTNAME:7101/"
echo "Nx Meta LSIO:" "https://$HOSTNAME:7201/"
echo "Nx Witness:" "https://$HOSTNAME:7102/"
echo "Nx Witness LSIO:" "https://$HOSTNAME:7202/"
echo "DW Spectrum:" "https://$HOSTNAME:7103/"
echo "DW Spectrum LSIO:" "https://$HOSTNAME:7203/"
echo "Wisenet WAVE:" "https://$HOSTNAME:7104/"
echo "Wisenet WAVE LSIO:" "https://$HOSTNAME:7204/"
echo "Nx Go:" "https://$HOSTNAME:7101/"
echo "Nx Go LSIO:" "https://$HOSTNAME:7201/"
echo "Nx Meta:" "https://$HOSTNAME:7102/"
echo "Nx Meta LSIO:" "https://$HOSTNAME:7202/"
echo "Nx Witness:" "https://$HOSTNAME:7103/"
echo "Nx Witness LSIO:" "https://$HOSTNAME:7203/"
echo "DW Spectrum:" "https://$HOSTNAME:7104/"
echo "DW Spectrum LSIO:" "https://$HOSTNAME:7204/"
echo "Wisenet WAVE:" "https://$HOSTNAME:7105/"
echo "Wisenet WAVE LSIO:" "https://$HOSTNAME:7205/"
Loading