diff --git a/.github/copilot-instructions.md b/.github/copilot-instructions.md index 269352c..fa9f57c 100644 --- a/.github/copilot-instructions.md +++ b/.github/copilot-instructions.md @@ -14,7 +14,7 @@ If any instruction conflicts, follow CODESTYLE.md first, then AGENTS.md. ## Solution Summary -This repository builds and publishes Docker images for Network Optix VMS products (Nx Witness, Nx Meta, Nx Go, DW Spectrum, Wisenet WAVE). It includes a .NET tooling project that generates Dockerfiles, matrices, and version inputs used by CI and packaging scripts. +This repository builds and publishes Docker images for Network Optix VMS products (Nx Witness, Nx Meta, Nx Go, DW Spectrum, Wisenet WAVE). It includes base images (nx-base, nx-base-lsio) and derived product images, plus a .NET tooling project that generates Dockerfiles, matrices, and version inputs used by CI and packaging scripts. ### Core Projects @@ -24,7 +24,7 @@ This repository builds and publishes Docker images for Network Optix VMS product ### Key Inputs and Outputs - Inputs: version and matrix data in `version.json`, [Make/Version.json](../Make/Version.json), and [Make/Matrix.json](../Make/Matrix.json). -- Outputs: Dockerfiles in [Docker/](../Docker/) and compose/test artifacts in [Make/](../Make/). +- Outputs: Dockerfiles in [Docker/](../Docker/) (base images and derived product images) and compose/test artifacts in [Make/](../Make/). - Templates: Unraid container templates in [Unraid/](../Unraid/). ### Build and Validation Workflow (High Level) @@ -33,9 +33,15 @@ This repository builds and publishes Docker images for Network Optix VMS product - Formatting and style verification are enforced by CSharpier and dotnet format, with Husky.Net hooks. - The `.Net Format` VS Code task in [`.vscode/tasks.json`](../.vscode/tasks.json) must be clean and warning-free at all times. +### Image Architecture + +- Base images (`nx-base`, `nx-base-lsio`) are built and pushed, then used as `FROM` images for derived product Dockerfiles. +- Derived images should track base image tag changes (for example, the Ubuntu distro tag) to keep builds consistent. + ## What to Keep in Sync - Generated Dockerfiles and scripts must reflect CreateMatrix behavior. +- Base image Dockerfiles and derived image Dockerfiles should remain aligned since derived images build on the base images. - Documentation in [README.md](../README.md) and release notes should align with current outputs and supported product variants. ## Expectations for Changes diff --git a/.github/workflows/build-base-images-task.yml b/.github/workflows/build-base-images-task.yml new file mode 100644 index 0000000..c59ff42 --- /dev/null +++ b/.github/workflows/build-base-images-task.yml @@ -0,0 +1,67 @@ +name: Build base images task + +on: + workflow_call: + inputs: + push: + required: false + type: boolean + default: true + +jobs: + + build-base: + name: Build base image job + runs-on: ubuntu-latest + + strategy: + matrix: + base: + - name: nx-base + dockerfile: Docker/NxBase.Dockerfile + tags: | + docker.io/ptr727/nx-base:ubuntu-noble + - name: nx-base-lsio + dockerfile: Docker/NxBase-LSIO.Dockerfile + tags: | + docker.io/ptr727/nx-base-lsio:ubuntu-noble + + steps: + + - name: Checkout step + uses: actions/checkout@v6 + + - name: Setup QEMU step + uses: docker/setup-qemu-action@v3 + with: + platforms: linux/amd64,linux/arm64 + + - name: Setup Buildx step + uses: docker/setup-buildx-action@v3 + with: + platforms: linux/amd64,linux/arm64 + + - name: Login to Docker Hub step + uses: docker/login-action@v3 + with: + registry: docker.io + username: ${{ secrets.DOCKER_HUB_USERNAME }} + password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }} + + - name: Docker build and push base step + uses: docker/build-push-action@v6 + with: + push: ${{ inputs.push && (github.ref_name == 'main' || github.ref_name == 'develop') }} + context: Docker + file: ${{ matrix.base.dockerfile }} + platforms: linux/amd64,linux/arm64 + tags: ${{ matrix.base.tags }} + cache-from: | + type=registry,ref=${{ matrix.base.tags }} + type=gha,scope=develop-base-${{ matrix.base.name }} + type=gha,scope=main-base-${{ matrix.base.name }} + ${{ github.event.pull_request && format('type=gha,scope=pr-base-{0}-{1}', github.event.pull_request.number, matrix.base.name) || '' }} + cache-to: | + ${{ inputs.push && (github.ref_name == 'main' || github.ref_name == 'develop') && format('type=gha,mode=max,scope={0}-base-{1}', github.ref_name, matrix.base.name) || '' }} + ${{ inputs.push && (github.ref_name == 'main' || github.ref_name == 'develop') && 'type=inline' || '' }} + ${{ github.event.pull_request && !github.event.pull_request.head.repo.fork && format('type=gha,mode=max,scope=pr-base-{0}-{1}', github.event.pull_request.number, matrix.base.name) || '' }} diff --git a/.github/workflows/build-datebadge-task.yml b/.github/workflows/build-datebadge-task.yml index 08eaed3..8f7f8f8 100644 --- a/.github/workflows/build-datebadge-task.yml +++ b/.github/workflows/build-datebadge-task.yml @@ -1,8 +1,5 @@ name: Build BYOB date badge task -env: - IS_MAIN_BRANCH: ${{ endsWith(github.ref, 'refs/heads/main') }} - on: workflow_call: @@ -20,7 +17,7 @@ jobs: echo "date=$(date)" >> $GITHUB_OUTPUT - name: Build BYOB date badge step - if: ${{ env.IS_MAIN_BRANCH == 'true' }} + if: ${{ github.ref_name == 'main' }} uses: RubbaBoy/BYOB@v1 with: name: lastbuild diff --git a/.github/workflows/build-docker-task.yml b/.github/workflows/build-docker-task.yml index fb40eb5..db31739 100644 --- a/.github/workflows/build-docker-task.yml +++ b/.github/workflows/build-docker-task.yml @@ -1,13 +1,9 @@ name: Build Docker image task -env: - IS_MAIN_BRANCH: ${{ endsWith(github.ref, 'refs/heads/main') }} - DOCKER_REGISTRY: docker.io on: workflow_call: inputs: - # Input to control whether to push the Docker image to Docker Hub push: required: false type: boolean @@ -28,7 +24,6 @@ jobs: - name: Load matrix.json step id: getmatrix - # Create compact version of matrix.json run: | echo "matrix=$(jq --compact-output '.' ./Make/Matrix.json)" >> $GITHUB_OUTPUT @@ -37,10 +32,17 @@ jobs: uses: ./.github/workflows/get-version-task.yml secrets: inherit + build-base: + name: Build base image job + uses: ./.github/workflows/build-base-images-task.yml + with: + push: ${{ inputs.push }} + secrets: inherit + build-docker: name: Build Docker image job runs-on: ubuntu-latest - needs: [get-version, get-matrix] + needs: [get-version, get-matrix, build-base] strategy: max-parallel: 4 @@ -65,7 +67,7 @@ jobs: - name: Login to Docker Hub step uses: docker/login-action@v3 with: - registry: ${{ env.DOCKER_REGISTRY }} + registry: docker.io username: ${{ secrets.DOCKER_HUB_USERNAME }} password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }} @@ -83,7 +85,7 @@ jobs: echo "LABEL_VERSION=${{ needs.get-version.outputs.SemVer2 }}" echo "EOF" } >> "$GITHUB_OUTPUT" - + - name: Docker build and push step uses: docker/build-push-action@v6 with: @@ -96,4 +98,7 @@ jobs: cache-from: | type=gha,scope=develop-${{ matrix.images.Name }} type=gha,scope=main-${{ matrix.images.Name }} - cache-to: ${{ (github.ref_name == 'main' || github.ref_name == 'develop') && format('type=gha,mode=max,scope={0}-{1}', github.ref_name, matrix.images.Name) || 'type=gha,mode=min,scope=ro' }} + ${{ github.event.pull_request && format('type=gha,scope=pr-{0}-{1}', github.event.pull_request.number, matrix.images.Name) || '' }} + cache-to: | + ${{ (github.ref_name == 'main' || github.ref_name == 'develop') && format('type=gha,mode=max,scope={0}-{1}', github.ref_name, matrix.images.Name) || '' }} + ${{ github.event.pull_request && !github.event.pull_request.head.repo.fork && format('type=gha,mode=max,scope=pr-{0}-{1}', github.event.pull_request.number, matrix.images.Name) || '' }} diff --git a/.github/workflows/build-release-task.yml b/.github/workflows/build-release-task.yml index 57e7785..adc5ed8 100644 --- a/.github/workflows/build-release-task.yml +++ b/.github/workflows/build-release-task.yml @@ -1,17 +1,12 @@ name: Build project release task -env: - IS_MAIN_BRANCH: ${{ endsWith(github.ref, 'refs/heads/main') }} - on: workflow_call: inputs: - # Input to control whether to create a GitHub release github: required: false type: boolean default: false - # Input to control whether to push the Docker image to Docker Hub dockerhub: required: false type: boolean @@ -29,12 +24,10 @@ jobs: uses: ./.github/workflows/build-docker-task.yml secrets: inherit with: - # Conditional push to Docker Hub push: ${{ inputs.dockerhub }} github-release: name: Publish GitHub release job - # Conditional GitHub release if: ${{ inputs.github }} runs-on: ubuntu-latest needs: [get-version, build-docker] @@ -49,7 +42,7 @@ jobs: with: generate_release_notes: true tag_name: ${{ needs.get-version.outputs.SemVer2 }} - prerelease: ${{ env.IS_MAIN_BRANCH != 'true' }} + prerelease: ${{ github.ref_name != 'main' }} files: | LICENSE README.md diff --git a/.github/workflows/get-version-task.yml b/.github/workflows/get-version-task.yml index 9130588..d88cb35 100644 --- a/.github/workflows/get-version-task.yml +++ b/.github/workflows/get-version-task.yml @@ -3,7 +3,6 @@ name: Get version information task on: workflow_call: outputs: - # Version information outputs SemVer2: value: ${{ jobs.get-version.outputs.SemVer2 }} AssemblyVersion: diff --git a/.github/workflows/publish-docker-readme-task.yml b/.github/workflows/publish-docker-readme-task.yml index 9649fbb..2d6706a 100644 --- a/.github/workflows/publish-docker-readme-task.yml +++ b/.github/workflows/publish-docker-readme-task.yml @@ -18,9 +18,8 @@ jobs: - name: Load matrix.json step id: getrepos - # Create array of docker hub repositories from matrix.json run: | - echo "repos=$(jq --compact-output '[.Images[].Name | ascii_downcase | \"ptr727/\\(.)\"] | sort | unique' ./Make/Matrix.json)" >> "$GITHUB_OUTPUT" + echo "repos=$(jq --compact-output '[.Images[].Name | ascii_downcase | "ptr727/\(.)" ] + ["ptr727/nx-base","ptr727/nx-base-lsio"] | sort | unique' ./Make/Matrix.json)" >> "$GITHUB_OUTPUT" publish-readme: name: Publish docker hub readme job diff --git a/.github/workflows/publish-periodic-docker-release.yml b/.github/workflows/publish-periodic-docker-release.yml index a264c59..e37eae3 100644 --- a/.github/workflows/publish-periodic-docker-release.yml +++ b/.github/workflows/publish-periodic-docker-release.yml @@ -3,7 +3,6 @@ name: Publish weekly Docker image to Docker Hub action on: workflow_dispatch: schedule: - # Run weekly on Mondays at 02:00 UTC - cron: '0 2 * * MON' concurrency: diff --git a/.github/workflows/publish-release.yml b/.github/workflows/publish-release.yml index 91069eb..25bc2d9 100644 --- a/.github/workflows/publish-release.yml +++ b/.github/workflows/publish-release.yml @@ -18,7 +18,6 @@ jobs: permissions: contents: write with: - # Publish github: true dockerhub: true diff --git a/.github/workflows/run-codegen-pull-request-task.yml b/.github/workflows/run-codegen-pull-request-task.yml index 32cdd29..89fe1c7 100644 --- a/.github/workflows/run-codegen-pull-request-task.yml +++ b/.github/workflows/run-codegen-pull-request-task.yml @@ -1,9 +1,5 @@ name: Run codegen and pull request task -env: - PROJECT_FILE: ./CreateMatrix/CreateMatrix.csproj - CODEGEN_ARGS: matrix --versionpath=./Make/Version.json --matrixpath=./Make/Matrix.json --updateversion - on: workflow_call: @@ -25,8 +21,8 @@ jobs: - name: Run codegen step run: >- - dotnet run --project ${{ env.PROJECT_FILE }} -- - ${{ env.CODEGEN_ARGS }} + dotnet run --project ./CreateMatrix/CreateMatrix.csproj -- + matrix --versionpath=./Make/Version.json --matrixpath=./Make/Matrix.json --updateversion - name: Format code step run: | diff --git a/.github/workflows/run-periodic-codegen-pull-request.yml b/.github/workflows/run-periodic-codegen-pull-request.yml index f82e2cf..486214b 100644 --- a/.github/workflows/run-periodic-codegen-pull-request.yml +++ b/.github/workflows/run-periodic-codegen-pull-request.yml @@ -3,7 +3,6 @@ name: Run weekly CodeGen and Pull Request action on: workflow_dispatch: schedule: - # Run weekly on Sundays at 02:00 UTC - cron: '0 2 * * SUN' concurrency: diff --git a/.github/workflows/test-release-task.yml b/.github/workflows/test-release-task.yml index c664fbd..0c808df 100644 --- a/.github/workflows/test-release-task.yml +++ b/.github/workflows/test-release-task.yml @@ -35,6 +35,5 @@ jobs: uses: ./.github/workflows/build-release-task.yml secrets: inherit with: - # Do not publish github: false dockerhub: false diff --git a/AGENTS.md b/AGENTS.md index ff63057..6cda8d8 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -1,6 +1,6 @@ # Instructions for AI Coding Agents -This repository builds and publishes Docker images for Network Optix VMS products (Nx Witness, Nx Meta, Nx Go, DW Spectrum, Wisenet WAVE). It includes a .NET tooling project that generates Dockerfiles and build matrices, plus scripts and templates for packaging. +This repository builds and publishes Docker images for Network Optix VMS products (Nx Witness, Nx Meta, Nx Go, DW Spectrum, Wisenet WAVE). It includes base images (nx-base, nx-base-lsio) and derived product images that use the base images, plus a .NET tooling project that generates Dockerfiles and build matrices and scripts/templates for packaging. For comprehensive coding and formatting standards, follow: @@ -19,10 +19,10 @@ For comprehensive coding and formatting standards, follow: - `CreateMatrixTests/CreateMatrixTests.csproj` - xUnit v3 test project with AwesomeAssertions. -### Key Directories - -- `Docker/` - - Generated and static Dockerfiles for product variants. +### Key Directories + +- `Docker/` + - Generated and static Dockerfiles for base images and product variants. - `Make/` - Build orchestration scripts and test compose files. - `Unraid/` @@ -30,16 +30,21 @@ For comprehensive coding and formatting standards, follow: - `version.json`, `Make/Version.json`, `Make/Matrix.json` - Version and matrix inputs consumed by the build pipeline. -## Build and Validation Workflow +## Build and Validation Workflow - Primary developer entry points are the `CreateMatrix` CLI commands invoked directly or via the scripts in `Make/`: - `version --versionpath=./Make/Version.json`. - `matrix --versionpath=./Make/Version.json --matrixpath=./Make/Matrix.json --updateversion`. - `make --versionpath=./Make/Version.json --makedirectory=./Make --dockerdirectory=./Docker --versionlabel=Beta`. -- Formatting and style checks are enforced by Husky.Net and VS Code tasks. -- Required tasks are documented in `CODESTYLE.md` and `.husky/task-runner.json`. -- C# code should be formatted with CSharpier, then verified with `dotnet format` (style). -- The `.Net Format` VS Code task in `.vscode/tasks.json` must be clean and warning-free at all times. +- Formatting and style checks are enforced by Husky.Net and VS Code tasks. +- Required tasks are documented in `CODESTYLE.md` and `.husky/task-runner.json`. +- C# code should be formatted with CSharpier, then verified with `dotnet format` (style). +- The `.Net Format` VS Code task in `.vscode/tasks.json` must be clean and warning-free at all times. + +## Image Architecture + +- Base images (`nx-base`, `nx-base-lsio`) are built and pushed, then reused as `FROM` images for derived product Dockerfiles. +- Derived product images should stay aligned with the base image changes and tags (for example, the Ubuntu distro tag). ## Coding Conventions (Highlights) @@ -49,7 +54,8 @@ For comprehensive coding and formatting standards, follow: - UTF-8 encoding without BOM. - Respect line ending rules in `.editorconfig`. -## Notes for Changes - -- When modifying Dockerfiles or build scripts, ensure generated outputs stay in sync with `CreateMatrix` behavior. -- Keep `README.md` and release documentation aligned with build outputs and product variants. +## Notes for Changes + +- When modifying Dockerfiles or build scripts, ensure generated outputs stay in sync with `CreateMatrix` behavior. +- Keep base image definitions and derived image Dockerfiles aligned, since derived images build on the base images. +- Keep `README.md` and release documentation aligned with build outputs and product variants. diff --git a/CreateMatrix/Dockerfile.cs b/CreateMatrix/Dockerfile.cs index fedfa77..98cccd0 100644 --- a/CreateMatrix/Dockerfile.cs +++ b/CreateMatrix/Dockerfile.cs @@ -2,12 +2,18 @@ namespace CreateMatrix; internal static class DockerFile { + private const string UbuntuBaseTag = "noble"; + private const string BaseImage = "docker.io/ptr727/nx-base:ubuntu-" + UbuntuBaseTag; + private const string BaseImageLsio = "docker.io/ptr727/nx-base-lsio:ubuntu-" + UbuntuBaseTag; + public static void Create( List productList, string dockerPath, VersionInfo.LabelType label ) { + CreateBaseDockerfiles(dockerPath); + // Create a Docker file for each product type foreach (ProductInfo.ProductType productType in ProductInfo.GetProductTypes()) { @@ -87,25 +93,84 @@ private static string CreateFrom(ProductInfo.ProductType productType, bool lsio) # https://support.networkoptix.com/hc/en-us/articles/205313168-Nx-Witness-Operating-System-Support # Latest Ubuntu supported for v6 is Noble + # Base images are built in this repo, see Docker/NxBase*.Dockerfile """; if (lsio) { - from += """ - FROM lsiobase/ubuntu:noble + from += $$""" + FROM {{BaseImageLsio}} """; } else { - from += """ - FROM ubuntu:noble + from += $$""" + FROM {{BaseImage}} """; } return from; } + private static void CreateBaseDockerfiles(string dockerPath) + { + string baseDockerfile = $$""" + # Base Dockerfile for Nx Witness images + # Built from ubuntu:{{UbuntuBaseTag}} + FROM ubuntu:{{UbuntuBaseTag}} + + # Prevent EULA and confirmation prompts in installers + ARG DEBIAN_FRONTEND=noninteractive + + # Common packages used by all product images + # https://github.com/ptr727/NxWitness/issues/282 + RUN apt-get update \ + && apt-get upgrade --yes \ + && apt-get install --no-install-recommends --yes \ + ca-certificates \ + gdb \ + libdrm2 \ + sudo \ + unzip \ + wget \ + && apt-get clean \ + && apt-get autoremove --purge \ + && rm -rf /var/lib/apt/lists/* + """; + + string baseFilePath = Path.Combine(dockerPath, "NxBase.Dockerfile"); + Log.Logger.Information("Writing Dockerfile to {Path}", baseFilePath); + File.WriteAllText(baseFilePath, baseDockerfile); + + string baseLsioDockerfile = $$""" + # Base Dockerfile for Nx Witness LSIO images + # Built from lsiobase/ubuntu:{{UbuntuBaseTag}} + FROM lsiobase/ubuntu:{{UbuntuBaseTag}} + + # Prevent EULA and confirmation prompts in installers + ARG DEBIAN_FRONTEND=noninteractive + + # Common packages used by all product images + # https://github.com/ptr727/NxWitness/issues/282 + RUN apt-get update \ + && apt-get upgrade --yes \ + && apt-get install --no-install-recommends --yes \ + ca-certificates \ + gdb \ + libdrm2 \ + unzip \ + wget \ + && apt-get clean \ + && apt-get autoremove --purge \ + && rm -rf /var/lib/apt/lists/* + """; + + string baseLsioFilePath = Path.Combine(dockerPath, "NxBase-LSIO.Dockerfile"); + Log.Logger.Information("Writing Dockerfile to {Path}", baseLsioFilePath); + File.WriteAllText(baseLsioFilePath, baseLsioDockerfile); + } + private static string CreateArgs( ProductInfo.ProductType productType, VersionInfo versionInfo, @@ -137,10 +202,6 @@ bool lsio # 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 @@ -159,21 +220,46 @@ private static string CreateInstall(bool lsio) { // Install string install = """ - # Install required tools and utilities - RUN apt-get update \ - && apt-get upgrade --yes \ - && apt-get install --no-install-recommends --yes \ - ca-certificates \ - unzip \ - wget - + # Base image includes required tools and utilities. # 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 + RUN /bin/bash -euo pipefail -c '\ + DEB_FILE="./vms_server.deb"; \ + TARGET_PLATFORM="${TARGETPLATFORM:-}"; \ + DOWNLOAD_URL="${DOWNLOAD_X64_URL:?DOWNLOAD_X64_URL is required}"; \ + if [ "${TARGET_PLATFORM}" = "linux/arm64" ]; then \ + DOWNLOAD_URL="${DOWNLOAD_ARM64_URL:?DOWNLOAD_ARM64_URL is required}"; \ + fi; \ + echo "Download URL: ${DOWNLOAD_URL}"; \ + DOWNLOAD_FILENAME="$(basename -- "${DOWNLOAD_URL}")"; \ + echo "Download Filename: ${DOWNLOAD_FILENAME}"; \ + wget --no-verbose --tries=5 --timeout=30 --retry-connrefused "${DOWNLOAD_URL}"; \ + case "${DOWNLOAD_FILENAME}" in \ + *.zip) \ + echo "Downloaded ZIP: ${DOWNLOAD_FILENAME}"; \ + DOWNLOAD_DIR="./download_zip"; \ + rm -rf "${DOWNLOAD_DIR}"; \ + mkdir -p "${DOWNLOAD_DIR}"; \ + unzip -q -d "${DOWNLOAD_DIR}" "${DOWNLOAD_FILENAME}"; \ + DEB_ZIP_FILE="$(find "${DOWNLOAD_DIR}" -maxdepth 1 -type f -name "*.deb" -print -quit)"; \ + if [ -z "${DEB_ZIP_FILE}" ]; then \ + echo "No .deb found in ${DOWNLOAD_DIR}" >&2; \ + exit 1; \ + fi; \ + echo "DEB in ZIP: ${DEB_ZIP_FILE}"; \ + mv "${DEB_ZIP_FILE}" "${DEB_FILE}"; \ + rm -rf "${DOWNLOAD_DIR}" "${DOWNLOAD_FILENAME}"; \ + ;; \ + *.deb) \ + echo "Downloaded DEB: ${DOWNLOAD_FILENAME}"; \ + mv "${DOWNLOAD_FILENAME}" "${DEB_FILE}"; \ + ;; \ + *) \ + echo "Unsupported download type: ${DOWNLOAD_FILENAME}" >&2; \ + exit 1; \ + ;; \ + esac; \ + echo "DEB File: ${DEB_FILE}"' """; @@ -197,25 +283,10 @@ RUN usermod -l ${COMPANY_NAME} abc \ """; } - // https://github.com/ptr727/NxWitness/issues/282 install += """ - # Install the mediaserver and dependencies + # Install the mediaserver RUN apt-get update \ - # https://github.com/ptr727/NxWitness/issues/282 && apt-get install --no-install-recommends --yes \ - gdb \ - libdrm2 \ - - """; - if (!lsio) - { - install += """ - sudo \ - - """; - } - - install += """ ./vms_server.deb \ # Cleanup && apt-get clean \ diff --git a/CreateMatrix/ImageInfo.cs b/CreateMatrix/ImageInfo.cs index c2ca075..7370709 100644 --- a/CreateMatrix/ImageInfo.cs +++ b/CreateMatrix/ImageInfo.cs @@ -4,26 +4,42 @@ namespace CreateMatrix; internal class ImageInfo { + public enum BranchType + { + None, + Main, + Develop, + } + + public enum BaseType + { + None, + Ubuntu, + LSIO, + } + public string Name { get; set; } = string.Empty; - public string Branch { get; set; } = string.Empty; - public string CacheScope { get; set; } = string.Empty; + + [JsonConverter(typeof(LowercaseEnumConverter))] + public ProductInfo.ProductType Product { get; set; } = ProductInfo.ProductType.None; + + [JsonConverter(typeof(LowercaseEnumConverter))] + public BranchType Branch { get; set; } = BranchType.None; + + [JsonConverter(typeof(LowercaseEnumConverter))] + public BaseType Base { get; set; } = BaseType.None; + public List Tags { get; set; } = []; public List Args { get; set; } = []; - private static readonly string[] s_baseNames = ["", "LSIO"]; - private static readonly string[] s_registryNames = ["docker.io/ptr727"]; + private const string Registry = "docker.io/ptr727"; - private void SetName(ProductInfo.ProductType productType, string baseName) + private ImageInfo(ProductInfo.ProductType productType, BranchType branchType, BaseType baseType) { - // E.g. NxMeta, NxMeta-LSIO - Name = string.IsNullOrEmpty(baseName) - ? productType.ToString() - : $"{productType}-{baseName}"; - - // E.g. default, lsio - CacheScope = string.IsNullOrEmpty(baseName) - ? "default" - : $"{baseName.ToLower(CultureInfo.InvariantCulture)}"; + Product = productType; + Branch = branchType; + Base = baseType; + Name = baseType == BaseType.Ubuntu ? productType.ToString() : $"{productType}-LSIO"; } private void AddArgs(VersionInfo versionInfo) @@ -33,56 +49,35 @@ private void AddArgs(VersionInfo versionInfo) Args.Add($"{DownloadArm64Url}={versionInfo.UriArm64}"); } - private void AddTag(string tag, string? tagPrefix = null) + private void AddTag(string tag) { - // E.g. latest, develop-latest - string prefixTag = string.IsNullOrEmpty(tagPrefix) ? tag : $"{tagPrefix}-{tag}"; + if (Branch == BranchType.Develop) + { + tag = $"develop-{tag}"; + } + Tags.Add($"{Registry}/{Name.ToLowerInvariant()}:{tag.ToLowerInvariant()}"); + } - // E.g. "docker.io/ptr727", "ghcr.io/ptr727" - foreach (string registry in s_registryNames) + private void AddTag(VersionInfo.LabelType labelType) + { + string tag = labelType.ToString().ToLowerInvariant(); + if (Branch == BranchType.Develop) { - Tags.Add( - $"{registry}/{Name.ToLower(CultureInfo.InvariantCulture)}:{prefixTag.ToLower(CultureInfo.InvariantCulture)}" - ); + tag = labelType == VersionInfo.LabelType.Latest ? $"develop" : $"develop-{tag}"; } + Tags.Add($"{Registry}/{Name.ToLowerInvariant()}:{tag.ToLowerInvariant()}"); } public static List CreateImages(List productList) { // Create images for all products List imageList = []; - foreach (ProductInfo productInfo in productList) - { - foreach (string baseName in s_baseNames) - { - imageList.AddRange(CreateImages(productInfo, baseName)); - } - } - - // Set branch as "main" on all images - imageList.ForEach(item => item.Branch = "main"); - - // Create develop tagged images for all products - List developList = []; - foreach (ProductInfo productInfo in productList) - { - foreach (string baseName in s_baseNames) - { - developList.AddRange(CreateImages(productInfo, baseName, "develop")); - } - } - - // Set branch as "develop" - developList.ForEach(item => item.Branch = "develop"); - - // Add images to list - imageList.AddRange(developList); - - // Sort args and tags to make diffs easier - imageList.ForEach(item => + productList.ForEach(product => { - item.Args.Sort(); - item.Tags.Sort(); + imageList.AddRange(CreateImages(product, BaseType.Ubuntu, BranchType.Main)); + imageList.AddRange(CreateImages(product, BaseType.Ubuntu, BranchType.Develop)); + imageList.AddRange(CreateImages(product, BaseType.LSIO, BranchType.Main)); + imageList.AddRange(CreateImages(product, BaseType.LSIO, BranchType.Develop)); }); return imageList; @@ -90,8 +85,8 @@ public static List CreateImages(List productList) private static List CreateImages( ProductInfo productInfo, - string baseName, - string? tagPrefix = null + BaseType baseType, + BranchType branchType ) { // Create a set by unique versions @@ -102,29 +97,23 @@ private static List CreateImages( // Create images for each version List imageList = []; - foreach (VersionInfo versionUri in versionSet) + foreach (VersionInfo version in versionSet) { // Create image - ImageInfo imageInfo = new(); - imageInfo.SetName(productInfo.Product, baseName); + ImageInfo imageInfo = new(productInfo.Product, branchType, baseType); // Add a tag for the version - imageInfo.AddTag(versionUri.Version, tagPrefix); + imageInfo.AddTag(version.Version); // Add tags for all labels - versionUri.Labels.ForEach(item => imageInfo.AddTag(item.ToString(), tagPrefix)); - - // Add prefix as a standalone tag for latest - if ( - !string.IsNullOrEmpty(tagPrefix) - && versionUri.Labels.Contains(VersionInfo.LabelType.Latest) - ) - { - imageInfo.AddTag(tagPrefix); - } + version.Labels.ForEach(imageInfo.AddTag); // Add args - imageInfo.AddArgs(versionUri); + imageInfo.AddArgs(version); + + // Sort args and tags to make diffs easier + imageInfo.Args.Sort(); + imageInfo.Tags.Sort(); // Add image to list imageList.Add(imageInfo); @@ -137,8 +126,9 @@ private static List CreateImages( public void LogInformation() { Log.Logger.Information( - "Name: {Name}, Branch: {Branch}, Tags: {Tags}, Args: {Args}", + "Name: {Name}, Base: {Base}, Branch: {Branch}, Tags: {Tags}, Args: {Args}", Name, + Base, Branch, Tags.Count, Args.Count diff --git a/CreateMatrix/MatrixJsonSchema.cs b/CreateMatrix/MatrixJsonSchema.cs index 6b30b02..61ff55c 100644 --- a/CreateMatrix/MatrixJsonSchema.cs +++ b/CreateMatrix/MatrixJsonSchema.cs @@ -24,6 +24,27 @@ private static string ToJson(MatrixJsonSchema json) => JsonSerializer.Serialize(json, MatrixJsonContext.Default.MatrixJsonSchema); } +internal sealed class LowercaseEnumConverter : JsonConverter + where T : struct, Enum +{ + public override T Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + string? value = + reader.GetString() ?? throw new JsonException($"Expected {typeof(T).Name} value."); + + return !Enum.TryParse(value, true, out T result) + ? throw new JsonException($"Invalid {typeof(T).Name} value '{value}'.") + : result; + } + + public override void Write(Utf8JsonWriter writer, T value, JsonSerializerOptions options) => + writer.WriteStringValue(value.ToString().ToLowerInvariant()); +} + [JsonSourceGenerationOptions( AllowTrailingCommas = true, DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull, diff --git a/CreateMatrix/Program.cs b/CreateMatrix/Program.cs index a801cd8..d7e3f81 100644 --- a/CreateMatrix/Program.cs +++ b/CreateMatrix/Program.cs @@ -59,10 +59,7 @@ internal async Task ExecuteVersionAsync() // Get versions for all products using releases API VersionJsonSchema versionSchema = new(); Log.Logger.Information("Getting version information online..."); - foreach (ProductInfo productInfo in ProductInfo.GetProducts()) - { - versionSchema.Products.Add(productInfo); - } + versionSchema.Products.AddRange(ProductInfo.GetProducts()); foreach (ProductInfo productInfo in versionSchema.Products) { await productInfo.FetchVersionsAsync(cancellationToken).ConfigureAwait(false); @@ -93,6 +90,7 @@ internal async Task ExecuteMatrixAsync() VersionJsonSchema fileSchema = VersionJsonSchema.FromFile( commandLineOptions.VersionPath.FullName ); + // Re-verify as rules may have changed after file was written foreach (ProductInfo productInfo in fileSchema.Products) { @@ -106,10 +104,7 @@ internal async Task ExecuteMatrixAsync() // Get versions for all products using releases API VersionJsonSchema onlineSchema = new(); Log.Logger.Information("Getting version information online..."); - foreach (ProductInfo productInfo in ProductInfo.GetProducts()) - { - onlineSchema.Products.Add(productInfo); - } + onlineSchema.Products.AddRange(ProductInfo.GetProducts()); foreach (ProductInfo productInfo in onlineSchema.Products) { await productInfo.FetchVersionsAsync(cancellationToken).ConfigureAwait(false); @@ -117,9 +112,7 @@ internal async Task ExecuteMatrixAsync() } // Make sure the labelled version numbers do not regress - List fileProducts = [.. fileSchema.Products]; - List onlineProducts = [.. onlineSchema.Products]; - ReleaseVersionForward.Verify(fileProducts, onlineProducts); + ReleaseVersionForward.Verify(fileSchema.Products, onlineSchema.Products); // Verify URL's foreach (ProductInfo productInfo in onlineSchema.Products) @@ -147,19 +140,9 @@ internal async Task ExecuteMatrixAsync() // Create matrix Log.Logger.Information("Creating Matrix from versions"); MatrixJsonSchema matrixSchema = new(); - List products = [.. fileSchema.Products]; - IReadOnlyList images = ImageInfo.CreateImages(products); - foreach (ImageInfo imageInfo in images) - { - matrixSchema.Images.Add(imageInfo); - } + matrixSchema.Images.AddRange(ImageInfo.CreateImages(fileSchema.Products)); Log.Logger.Information("Created {Count} images in matrix", matrixSchema.Images.Count); - - // Log info - foreach (ImageInfo imageInfo in matrixSchema.Images) - { - imageInfo.LogInformation(); - } + matrixSchema.Images.ForEach(imageInfo => imageInfo.LogInformation()); // Write matrix Log.Logger.Information( diff --git a/Docker/DWSpectrum-LSIO.Dockerfile b/Docker/DWSpectrum-LSIO.Dockerfile index b9ef459..00a84eb 100644 --- a/Docker/DWSpectrum-LSIO.Dockerfile +++ b/Docker/DWSpectrum-LSIO.Dockerfile @@ -7,7 +7,8 @@ # https://support.networkoptix.com/hc/en-us/articles/205313168-Nx-Witness-Operating-System-Support # Latest Ubuntu supported for v6 is Noble -FROM lsiobase/ubuntu:noble +# Base images are built in this repo, see Docker/NxBase*.Dockerfile +FROM docker.io/ptr727/nx-base-lsio:ubuntu-noble # Labels ARG LABEL_NAME="DWSpectrum-LSIO" @@ -33,12 +34,8 @@ ARG \ # 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 +# Prevent EULA and confirmation prompts in installers +ARG DEBIAN_FRONTEND=noninteractive # Media server user and directory name ENV COMPANY_NAME=${RUNTIME_NAME} @@ -49,21 +46,46 @@ LABEL name=${LABEL_NAME}-${DOWNLOAD_VERSION} \ version=${LABEL_VERSION} \ maintainer="Pieter Viljoen " -# Install required tools and utilities -RUN apt-get update \ - && apt-get upgrade --yes \ - && apt-get install --no-install-recommends --yes \ - ca-certificates \ - unzip \ - wget - +# Base image includes required tools and utilities. # 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 +RUN /bin/bash -euo pipefail -c '\ + DEB_FILE="./vms_server.deb"; \ + TARGET_PLATFORM="${TARGETPLATFORM:-}"; \ + DOWNLOAD_URL="${DOWNLOAD_X64_URL:?DOWNLOAD_X64_URL is required}"; \ + if [ "${TARGET_PLATFORM}" = "linux/arm64" ]; then \ + DOWNLOAD_URL="${DOWNLOAD_ARM64_URL:?DOWNLOAD_ARM64_URL is required}"; \ + fi; \ + echo "Download URL: ${DOWNLOAD_URL}"; \ + DOWNLOAD_FILENAME="$(basename -- "${DOWNLOAD_URL}")"; \ + echo "Download Filename: ${DOWNLOAD_FILENAME}"; \ + wget --no-verbose --tries=5 --timeout=30 --retry-connrefused "${DOWNLOAD_URL}"; \ + case "${DOWNLOAD_FILENAME}" in \ + *.zip) \ + echo "Downloaded ZIP: ${DOWNLOAD_FILENAME}"; \ + DOWNLOAD_DIR="./download_zip"; \ + rm -rf "${DOWNLOAD_DIR}"; \ + mkdir -p "${DOWNLOAD_DIR}"; \ + unzip -q -d "${DOWNLOAD_DIR}" "${DOWNLOAD_FILENAME}"; \ + DEB_ZIP_FILE="$(find "${DOWNLOAD_DIR}" -maxdepth 1 -type f -name "*.deb" -print -quit)"; \ + if [ -z "${DEB_ZIP_FILE}" ]; then \ + echo "No .deb found in ${DOWNLOAD_DIR}" >&2; \ + exit 1; \ + fi; \ + echo "DEB in ZIP: ${DEB_ZIP_FILE}"; \ + mv "${DEB_ZIP_FILE}" "${DEB_FILE}"; \ + rm -rf "${DOWNLOAD_DIR}" "${DOWNLOAD_FILENAME}"; \ + ;; \ + *.deb) \ + echo "Downloaded DEB: ${DOWNLOAD_FILENAME}"; \ + mv "${DOWNLOAD_FILENAME}" "${DEB_FILE}"; \ + ;; \ + *) \ + echo "Unsupported download type: ${DOWNLOAD_FILENAME}" >&2; \ + exit 1; \ + ;; \ + esac; \ + echo "DEB File: ${DEB_FILE}"' # LSIO maps the host PUID and PGID environment variables to "abc" in the container. # https://docs.linuxserver.io/misc/non-root/ @@ -78,12 +100,9 @@ RUN usermod -l ${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 +# Install the mediaserver RUN apt-get update \ - # https://github.com/ptr727/NxWitness/issues/282 && apt-get install --no-install-recommends --yes \ - gdb \ - libdrm2 \ ./vms_server.deb \ # Cleanup && apt-get clean \ diff --git a/Docker/DWSpectrum.Dockerfile b/Docker/DWSpectrum.Dockerfile index d127577..2542d53 100644 --- a/Docker/DWSpectrum.Dockerfile +++ b/Docker/DWSpectrum.Dockerfile @@ -7,7 +7,8 @@ # https://support.networkoptix.com/hc/en-us/articles/205313168-Nx-Witness-Operating-System-Support # Latest Ubuntu supported for v6 is Noble -FROM ubuntu:noble +# Base images are built in this repo, see Docker/NxBase*.Dockerfile +FROM docker.io/ptr727/nx-base:ubuntu-noble # Labels ARG LABEL_NAME="DWSpectrum" @@ -33,12 +34,8 @@ ARG \ # 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 +# Prevent EULA and confirmation prompts in installers +ARG DEBIAN_FRONTEND=noninteractive # Media server user and directory name ENV COMPANY_NAME=${RUNTIME_NAME} @@ -49,29 +46,50 @@ LABEL name=${LABEL_NAME}-${DOWNLOAD_VERSION} \ version=${LABEL_VERSION} \ maintainer="Pieter Viljoen " -# Install required tools and utilities -RUN apt-get update \ - && apt-get upgrade --yes \ - && apt-get install --no-install-recommends --yes \ - ca-certificates \ - unzip \ - wget - +# Base image includes required tools and utilities. # 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 /bin/bash -euo pipefail -c '\ + DEB_FILE="./vms_server.deb"; \ + TARGET_PLATFORM="${TARGETPLATFORM:-}"; \ + DOWNLOAD_URL="${DOWNLOAD_X64_URL:?DOWNLOAD_X64_URL is required}"; \ + if [ "${TARGET_PLATFORM}" = "linux/arm64" ]; then \ + DOWNLOAD_URL="${DOWNLOAD_ARM64_URL:?DOWNLOAD_ARM64_URL is required}"; \ + fi; \ + echo "Download URL: ${DOWNLOAD_URL}"; \ + DOWNLOAD_FILENAME="$(basename -- "${DOWNLOAD_URL}")"; \ + echo "Download Filename: ${DOWNLOAD_FILENAME}"; \ + wget --no-verbose --tries=5 --timeout=30 --retry-connrefused "${DOWNLOAD_URL}"; \ + case "${DOWNLOAD_FILENAME}" in \ + *.zip) \ + echo "Downloaded ZIP: ${DOWNLOAD_FILENAME}"; \ + DOWNLOAD_DIR="./download_zip"; \ + rm -rf "${DOWNLOAD_DIR}"; \ + mkdir -p "${DOWNLOAD_DIR}"; \ + unzip -q -d "${DOWNLOAD_DIR}" "${DOWNLOAD_FILENAME}"; \ + DEB_ZIP_FILE="$(find "${DOWNLOAD_DIR}" -maxdepth 1 -type f -name "*.deb" -print -quit)"; \ + if [ -z "${DEB_ZIP_FILE}" ]; then \ + echo "No .deb found in ${DOWNLOAD_DIR}" >&2; \ + exit 1; \ + fi; \ + echo "DEB in ZIP: ${DEB_ZIP_FILE}"; \ + mv "${DEB_ZIP_FILE}" "${DEB_FILE}"; \ + rm -rf "${DOWNLOAD_DIR}" "${DOWNLOAD_FILENAME}"; \ + ;; \ + *.deb) \ + echo "Downloaded DEB: ${DOWNLOAD_FILENAME}"; \ + mv "${DOWNLOAD_FILENAME}" "${DEB_FILE}"; \ + ;; \ + *) \ + echo "Unsupported download type: ${DOWNLOAD_FILENAME}" >&2; \ + exit 1; \ + ;; \ + esac; \ + echo "DEB File: ${DEB_FILE}"' + +# Install the mediaserver RUN apt-get update \ - # https://github.com/ptr727/NxWitness/issues/282 && apt-get install --no-install-recommends --yes \ - gdb \ - libdrm2 \ - sudo \ ./vms_server.deb \ # Cleanup && apt-get clean \ diff --git a/Docker/NxBase-LSIO.Dockerfile b/Docker/NxBase-LSIO.Dockerfile new file mode 100644 index 0000000..8bcc16c --- /dev/null +++ b/Docker/NxBase-LSIO.Dockerfile @@ -0,0 +1,20 @@ +# Base Dockerfile for Nx Witness LSIO images +# Built from lsiobase/ubuntu:noble +FROM lsiobase/ubuntu:noble + +# Prevent EULA and confirmation prompts in installers +ARG DEBIAN_FRONTEND=noninteractive + +# Common packages used by all product images +# https://github.com/ptr727/NxWitness/issues/282 +RUN apt-get update \ + && apt-get upgrade --yes \ + && apt-get install --no-install-recommends --yes \ + ca-certificates \ + gdb \ + libdrm2 \ + unzip \ + wget \ + && apt-get clean \ + && apt-get autoremove --purge \ + && rm -rf /var/lib/apt/lists/* \ No newline at end of file diff --git a/Docker/NxBase.Dockerfile b/Docker/NxBase.Dockerfile new file mode 100644 index 0000000..d828e65 --- /dev/null +++ b/Docker/NxBase.Dockerfile @@ -0,0 +1,21 @@ +# Base Dockerfile for Nx Witness images +# Built from ubuntu:noble +FROM ubuntu:noble + +# Prevent EULA and confirmation prompts in installers +ARG DEBIAN_FRONTEND=noninteractive + +# Common packages used by all product images +# https://github.com/ptr727/NxWitness/issues/282 +RUN apt-get update \ + && apt-get upgrade --yes \ + && apt-get install --no-install-recommends --yes \ + ca-certificates \ + gdb \ + libdrm2 \ + sudo \ + unzip \ + wget \ + && apt-get clean \ + && apt-get autoremove --purge \ + && rm -rf /var/lib/apt/lists/* \ No newline at end of file diff --git a/Docker/NxGo-LSIO.Dockerfile b/Docker/NxGo-LSIO.Dockerfile index 2629acf..75c5634 100644 --- a/Docker/NxGo-LSIO.Dockerfile +++ b/Docker/NxGo-LSIO.Dockerfile @@ -7,7 +7,8 @@ # https://support.networkoptix.com/hc/en-us/articles/205313168-Nx-Witness-Operating-System-Support # Latest Ubuntu supported for v6 is Noble -FROM lsiobase/ubuntu:noble +# Base images are built in this repo, see Docker/NxBase*.Dockerfile +FROM docker.io/ptr727/nx-base-lsio:ubuntu-noble # Labels ARG LABEL_NAME="NxGo-LSIO" @@ -33,12 +34,8 @@ ARG \ # 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 +# Prevent EULA and confirmation prompts in installers +ARG DEBIAN_FRONTEND=noninteractive # Media server user and directory name ENV COMPANY_NAME=${RUNTIME_NAME} @@ -49,21 +46,46 @@ LABEL name=${LABEL_NAME}-${DOWNLOAD_VERSION} \ version=${LABEL_VERSION} \ maintainer="Pieter Viljoen " -# Install required tools and utilities -RUN apt-get update \ - && apt-get upgrade --yes \ - && apt-get install --no-install-recommends --yes \ - ca-certificates \ - unzip \ - wget - +# Base image includes required tools and utilities. # 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 +RUN /bin/bash -euo pipefail -c '\ + DEB_FILE="./vms_server.deb"; \ + TARGET_PLATFORM="${TARGETPLATFORM:-}"; \ + DOWNLOAD_URL="${DOWNLOAD_X64_URL:?DOWNLOAD_X64_URL is required}"; \ + if [ "${TARGET_PLATFORM}" = "linux/arm64" ]; then \ + DOWNLOAD_URL="${DOWNLOAD_ARM64_URL:?DOWNLOAD_ARM64_URL is required}"; \ + fi; \ + echo "Download URL: ${DOWNLOAD_URL}"; \ + DOWNLOAD_FILENAME="$(basename -- "${DOWNLOAD_URL}")"; \ + echo "Download Filename: ${DOWNLOAD_FILENAME}"; \ + wget --no-verbose --tries=5 --timeout=30 --retry-connrefused "${DOWNLOAD_URL}"; \ + case "${DOWNLOAD_FILENAME}" in \ + *.zip) \ + echo "Downloaded ZIP: ${DOWNLOAD_FILENAME}"; \ + DOWNLOAD_DIR="./download_zip"; \ + rm -rf "${DOWNLOAD_DIR}"; \ + mkdir -p "${DOWNLOAD_DIR}"; \ + unzip -q -d "${DOWNLOAD_DIR}" "${DOWNLOAD_FILENAME}"; \ + DEB_ZIP_FILE="$(find "${DOWNLOAD_DIR}" -maxdepth 1 -type f -name "*.deb" -print -quit)"; \ + if [ -z "${DEB_ZIP_FILE}" ]; then \ + echo "No .deb found in ${DOWNLOAD_DIR}" >&2; \ + exit 1; \ + fi; \ + echo "DEB in ZIP: ${DEB_ZIP_FILE}"; \ + mv "${DEB_ZIP_FILE}" "${DEB_FILE}"; \ + rm -rf "${DOWNLOAD_DIR}" "${DOWNLOAD_FILENAME}"; \ + ;; \ + *.deb) \ + echo "Downloaded DEB: ${DOWNLOAD_FILENAME}"; \ + mv "${DOWNLOAD_FILENAME}" "${DEB_FILE}"; \ + ;; \ + *) \ + echo "Unsupported download type: ${DOWNLOAD_FILENAME}" >&2; \ + exit 1; \ + ;; \ + esac; \ + echo "DEB File: ${DEB_FILE}"' # LSIO maps the host PUID and PGID environment variables to "abc" in the container. # https://docs.linuxserver.io/misc/non-root/ @@ -78,12 +100,9 @@ RUN usermod -l ${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 +# Install the mediaserver RUN apt-get update \ - # https://github.com/ptr727/NxWitness/issues/282 && apt-get install --no-install-recommends --yes \ - gdb \ - libdrm2 \ ./vms_server.deb \ # Cleanup && apt-get clean \ diff --git a/Docker/NxGo.Dockerfile b/Docker/NxGo.Dockerfile index 58c5c8e..de3a173 100644 --- a/Docker/NxGo.Dockerfile +++ b/Docker/NxGo.Dockerfile @@ -7,7 +7,8 @@ # https://support.networkoptix.com/hc/en-us/articles/205313168-Nx-Witness-Operating-System-Support # Latest Ubuntu supported for v6 is Noble -FROM ubuntu:noble +# Base images are built in this repo, see Docker/NxBase*.Dockerfile +FROM docker.io/ptr727/nx-base:ubuntu-noble # Labels ARG LABEL_NAME="NxGo" @@ -33,12 +34,8 @@ ARG \ # 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 +# Prevent EULA and confirmation prompts in installers +ARG DEBIAN_FRONTEND=noninteractive # Media server user and directory name ENV COMPANY_NAME=${RUNTIME_NAME} @@ -49,29 +46,50 @@ LABEL name=${LABEL_NAME}-${DOWNLOAD_VERSION} \ version=${LABEL_VERSION} \ maintainer="Pieter Viljoen " -# Install required tools and utilities -RUN apt-get update \ - && apt-get upgrade --yes \ - && apt-get install --no-install-recommends --yes \ - ca-certificates \ - unzip \ - wget - +# Base image includes required tools and utilities. # 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 /bin/bash -euo pipefail -c '\ + DEB_FILE="./vms_server.deb"; \ + TARGET_PLATFORM="${TARGETPLATFORM:-}"; \ + DOWNLOAD_URL="${DOWNLOAD_X64_URL:?DOWNLOAD_X64_URL is required}"; \ + if [ "${TARGET_PLATFORM}" = "linux/arm64" ]; then \ + DOWNLOAD_URL="${DOWNLOAD_ARM64_URL:?DOWNLOAD_ARM64_URL is required}"; \ + fi; \ + echo "Download URL: ${DOWNLOAD_URL}"; \ + DOWNLOAD_FILENAME="$(basename -- "${DOWNLOAD_URL}")"; \ + echo "Download Filename: ${DOWNLOAD_FILENAME}"; \ + wget --no-verbose --tries=5 --timeout=30 --retry-connrefused "${DOWNLOAD_URL}"; \ + case "${DOWNLOAD_FILENAME}" in \ + *.zip) \ + echo "Downloaded ZIP: ${DOWNLOAD_FILENAME}"; \ + DOWNLOAD_DIR="./download_zip"; \ + rm -rf "${DOWNLOAD_DIR}"; \ + mkdir -p "${DOWNLOAD_DIR}"; \ + unzip -q -d "${DOWNLOAD_DIR}" "${DOWNLOAD_FILENAME}"; \ + DEB_ZIP_FILE="$(find "${DOWNLOAD_DIR}" -maxdepth 1 -type f -name "*.deb" -print -quit)"; \ + if [ -z "${DEB_ZIP_FILE}" ]; then \ + echo "No .deb found in ${DOWNLOAD_DIR}" >&2; \ + exit 1; \ + fi; \ + echo "DEB in ZIP: ${DEB_ZIP_FILE}"; \ + mv "${DEB_ZIP_FILE}" "${DEB_FILE}"; \ + rm -rf "${DOWNLOAD_DIR}" "${DOWNLOAD_FILENAME}"; \ + ;; \ + *.deb) \ + echo "Downloaded DEB: ${DOWNLOAD_FILENAME}"; \ + mv "${DOWNLOAD_FILENAME}" "${DEB_FILE}"; \ + ;; \ + *) \ + echo "Unsupported download type: ${DOWNLOAD_FILENAME}" >&2; \ + exit 1; \ + ;; \ + esac; \ + echo "DEB File: ${DEB_FILE}"' + +# Install the mediaserver RUN apt-get update \ - # https://github.com/ptr727/NxWitness/issues/282 && apt-get install --no-install-recommends --yes \ - gdb \ - libdrm2 \ - sudo \ ./vms_server.deb \ # Cleanup && apt-get clean \ diff --git a/Docker/NxMeta-LSIO.Dockerfile b/Docker/NxMeta-LSIO.Dockerfile index 8076a8e..8492e1d 100644 --- a/Docker/NxMeta-LSIO.Dockerfile +++ b/Docker/NxMeta-LSIO.Dockerfile @@ -7,7 +7,8 @@ # https://support.networkoptix.com/hc/en-us/articles/205313168-Nx-Witness-Operating-System-Support # Latest Ubuntu supported for v6 is Noble -FROM lsiobase/ubuntu:noble +# Base images are built in this repo, see Docker/NxBase*.Dockerfile +FROM docker.io/ptr727/nx-base-lsio:ubuntu-noble # Labels ARG LABEL_NAME="NxMeta-LSIO" @@ -33,12 +34,8 @@ ARG \ # 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 +# Prevent EULA and confirmation prompts in installers +ARG DEBIAN_FRONTEND=noninteractive # Media server user and directory name ENV COMPANY_NAME=${RUNTIME_NAME} @@ -49,21 +46,46 @@ LABEL name=${LABEL_NAME}-${DOWNLOAD_VERSION} \ version=${LABEL_VERSION} \ maintainer="Pieter Viljoen " -# Install required tools and utilities -RUN apt-get update \ - && apt-get upgrade --yes \ - && apt-get install --no-install-recommends --yes \ - ca-certificates \ - unzip \ - wget - +# Base image includes required tools and utilities. # 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 +RUN /bin/bash -euo pipefail -c '\ + DEB_FILE="./vms_server.deb"; \ + TARGET_PLATFORM="${TARGETPLATFORM:-}"; \ + DOWNLOAD_URL="${DOWNLOAD_X64_URL:?DOWNLOAD_X64_URL is required}"; \ + if [ "${TARGET_PLATFORM}" = "linux/arm64" ]; then \ + DOWNLOAD_URL="${DOWNLOAD_ARM64_URL:?DOWNLOAD_ARM64_URL is required}"; \ + fi; \ + echo "Download URL: ${DOWNLOAD_URL}"; \ + DOWNLOAD_FILENAME="$(basename -- "${DOWNLOAD_URL}")"; \ + echo "Download Filename: ${DOWNLOAD_FILENAME}"; \ + wget --no-verbose --tries=5 --timeout=30 --retry-connrefused "${DOWNLOAD_URL}"; \ + case "${DOWNLOAD_FILENAME}" in \ + *.zip) \ + echo "Downloaded ZIP: ${DOWNLOAD_FILENAME}"; \ + DOWNLOAD_DIR="./download_zip"; \ + rm -rf "${DOWNLOAD_DIR}"; \ + mkdir -p "${DOWNLOAD_DIR}"; \ + unzip -q -d "${DOWNLOAD_DIR}" "${DOWNLOAD_FILENAME}"; \ + DEB_ZIP_FILE="$(find "${DOWNLOAD_DIR}" -maxdepth 1 -type f -name "*.deb" -print -quit)"; \ + if [ -z "${DEB_ZIP_FILE}" ]; then \ + echo "No .deb found in ${DOWNLOAD_DIR}" >&2; \ + exit 1; \ + fi; \ + echo "DEB in ZIP: ${DEB_ZIP_FILE}"; \ + mv "${DEB_ZIP_FILE}" "${DEB_FILE}"; \ + rm -rf "${DOWNLOAD_DIR}" "${DOWNLOAD_FILENAME}"; \ + ;; \ + *.deb) \ + echo "Downloaded DEB: ${DOWNLOAD_FILENAME}"; \ + mv "${DOWNLOAD_FILENAME}" "${DEB_FILE}"; \ + ;; \ + *) \ + echo "Unsupported download type: ${DOWNLOAD_FILENAME}" >&2; \ + exit 1; \ + ;; \ + esac; \ + echo "DEB File: ${DEB_FILE}"' # LSIO maps the host PUID and PGID environment variables to "abc" in the container. # https://docs.linuxserver.io/misc/non-root/ @@ -78,12 +100,9 @@ RUN usermod -l ${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 +# Install the mediaserver RUN apt-get update \ - # https://github.com/ptr727/NxWitness/issues/282 && apt-get install --no-install-recommends --yes \ - gdb \ - libdrm2 \ ./vms_server.deb \ # Cleanup && apt-get clean \ diff --git a/Docker/NxMeta.Dockerfile b/Docker/NxMeta.Dockerfile index b1204b7..41e0baa 100644 --- a/Docker/NxMeta.Dockerfile +++ b/Docker/NxMeta.Dockerfile @@ -7,7 +7,8 @@ # https://support.networkoptix.com/hc/en-us/articles/205313168-Nx-Witness-Operating-System-Support # Latest Ubuntu supported for v6 is Noble -FROM ubuntu:noble +# Base images are built in this repo, see Docker/NxBase*.Dockerfile +FROM docker.io/ptr727/nx-base:ubuntu-noble # Labels ARG LABEL_NAME="NxMeta" @@ -33,12 +34,8 @@ ARG \ # 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 +# Prevent EULA and confirmation prompts in installers +ARG DEBIAN_FRONTEND=noninteractive # Media server user and directory name ENV COMPANY_NAME=${RUNTIME_NAME} @@ -49,29 +46,50 @@ LABEL name=${LABEL_NAME}-${DOWNLOAD_VERSION} \ version=${LABEL_VERSION} \ maintainer="Pieter Viljoen " -# Install required tools and utilities -RUN apt-get update \ - && apt-get upgrade --yes \ - && apt-get install --no-install-recommends --yes \ - ca-certificates \ - unzip \ - wget - +# Base image includes required tools and utilities. # 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 /bin/bash -euo pipefail -c '\ + DEB_FILE="./vms_server.deb"; \ + TARGET_PLATFORM="${TARGETPLATFORM:-}"; \ + DOWNLOAD_URL="${DOWNLOAD_X64_URL:?DOWNLOAD_X64_URL is required}"; \ + if [ "${TARGET_PLATFORM}" = "linux/arm64" ]; then \ + DOWNLOAD_URL="${DOWNLOAD_ARM64_URL:?DOWNLOAD_ARM64_URL is required}"; \ + fi; \ + echo "Download URL: ${DOWNLOAD_URL}"; \ + DOWNLOAD_FILENAME="$(basename -- "${DOWNLOAD_URL}")"; \ + echo "Download Filename: ${DOWNLOAD_FILENAME}"; \ + wget --no-verbose --tries=5 --timeout=30 --retry-connrefused "${DOWNLOAD_URL}"; \ + case "${DOWNLOAD_FILENAME}" in \ + *.zip) \ + echo "Downloaded ZIP: ${DOWNLOAD_FILENAME}"; \ + DOWNLOAD_DIR="./download_zip"; \ + rm -rf "${DOWNLOAD_DIR}"; \ + mkdir -p "${DOWNLOAD_DIR}"; \ + unzip -q -d "${DOWNLOAD_DIR}" "${DOWNLOAD_FILENAME}"; \ + DEB_ZIP_FILE="$(find "${DOWNLOAD_DIR}" -maxdepth 1 -type f -name "*.deb" -print -quit)"; \ + if [ -z "${DEB_ZIP_FILE}" ]; then \ + echo "No .deb found in ${DOWNLOAD_DIR}" >&2; \ + exit 1; \ + fi; \ + echo "DEB in ZIP: ${DEB_ZIP_FILE}"; \ + mv "${DEB_ZIP_FILE}" "${DEB_FILE}"; \ + rm -rf "${DOWNLOAD_DIR}" "${DOWNLOAD_FILENAME}"; \ + ;; \ + *.deb) \ + echo "Downloaded DEB: ${DOWNLOAD_FILENAME}"; \ + mv "${DOWNLOAD_FILENAME}" "${DEB_FILE}"; \ + ;; \ + *) \ + echo "Unsupported download type: ${DOWNLOAD_FILENAME}" >&2; \ + exit 1; \ + ;; \ + esac; \ + echo "DEB File: ${DEB_FILE}"' + +# Install the mediaserver RUN apt-get update \ - # https://github.com/ptr727/NxWitness/issues/282 && apt-get install --no-install-recommends --yes \ - gdb \ - libdrm2 \ - sudo \ ./vms_server.deb \ # Cleanup && apt-get clean \ diff --git a/Docker/NxWitness-LSIO.Dockerfile b/Docker/NxWitness-LSIO.Dockerfile index 3c39a69..50271f9 100644 --- a/Docker/NxWitness-LSIO.Dockerfile +++ b/Docker/NxWitness-LSIO.Dockerfile @@ -7,7 +7,8 @@ # https://support.networkoptix.com/hc/en-us/articles/205313168-Nx-Witness-Operating-System-Support # Latest Ubuntu supported for v6 is Noble -FROM lsiobase/ubuntu:noble +# Base images are built in this repo, see Docker/NxBase*.Dockerfile +FROM docker.io/ptr727/nx-base-lsio:ubuntu-noble # Labels ARG LABEL_NAME="NxWitness-LSIO" @@ -33,12 +34,8 @@ ARG \ # 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 +# Prevent EULA and confirmation prompts in installers +ARG DEBIAN_FRONTEND=noninteractive # Media server user and directory name ENV COMPANY_NAME=${RUNTIME_NAME} @@ -49,21 +46,46 @@ LABEL name=${LABEL_NAME}-${DOWNLOAD_VERSION} \ version=${LABEL_VERSION} \ maintainer="Pieter Viljoen " -# Install required tools and utilities -RUN apt-get update \ - && apt-get upgrade --yes \ - && apt-get install --no-install-recommends --yes \ - ca-certificates \ - unzip \ - wget - +# Base image includes required tools and utilities. # 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 +RUN /bin/bash -euo pipefail -c '\ + DEB_FILE="./vms_server.deb"; \ + TARGET_PLATFORM="${TARGETPLATFORM:-}"; \ + DOWNLOAD_URL="${DOWNLOAD_X64_URL:?DOWNLOAD_X64_URL is required}"; \ + if [ "${TARGET_PLATFORM}" = "linux/arm64" ]; then \ + DOWNLOAD_URL="${DOWNLOAD_ARM64_URL:?DOWNLOAD_ARM64_URL is required}"; \ + fi; \ + echo "Download URL: ${DOWNLOAD_URL}"; \ + DOWNLOAD_FILENAME="$(basename -- "${DOWNLOAD_URL}")"; \ + echo "Download Filename: ${DOWNLOAD_FILENAME}"; \ + wget --no-verbose --tries=5 --timeout=30 --retry-connrefused "${DOWNLOAD_URL}"; \ + case "${DOWNLOAD_FILENAME}" in \ + *.zip) \ + echo "Downloaded ZIP: ${DOWNLOAD_FILENAME}"; \ + DOWNLOAD_DIR="./download_zip"; \ + rm -rf "${DOWNLOAD_DIR}"; \ + mkdir -p "${DOWNLOAD_DIR}"; \ + unzip -q -d "${DOWNLOAD_DIR}" "${DOWNLOAD_FILENAME}"; \ + DEB_ZIP_FILE="$(find "${DOWNLOAD_DIR}" -maxdepth 1 -type f -name "*.deb" -print -quit)"; \ + if [ -z "${DEB_ZIP_FILE}" ]; then \ + echo "No .deb found in ${DOWNLOAD_DIR}" >&2; \ + exit 1; \ + fi; \ + echo "DEB in ZIP: ${DEB_ZIP_FILE}"; \ + mv "${DEB_ZIP_FILE}" "${DEB_FILE}"; \ + rm -rf "${DOWNLOAD_DIR}" "${DOWNLOAD_FILENAME}"; \ + ;; \ + *.deb) \ + echo "Downloaded DEB: ${DOWNLOAD_FILENAME}"; \ + mv "${DOWNLOAD_FILENAME}" "${DEB_FILE}"; \ + ;; \ + *) \ + echo "Unsupported download type: ${DOWNLOAD_FILENAME}" >&2; \ + exit 1; \ + ;; \ + esac; \ + echo "DEB File: ${DEB_FILE}"' # LSIO maps the host PUID and PGID environment variables to "abc" in the container. # https://docs.linuxserver.io/misc/non-root/ @@ -78,12 +100,9 @@ RUN usermod -l ${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 +# Install the mediaserver RUN apt-get update \ - # https://github.com/ptr727/NxWitness/issues/282 && apt-get install --no-install-recommends --yes \ - gdb \ - libdrm2 \ ./vms_server.deb \ # Cleanup && apt-get clean \ diff --git a/Docker/NxWitness.Dockerfile b/Docker/NxWitness.Dockerfile index cd69299..4e269f7 100644 --- a/Docker/NxWitness.Dockerfile +++ b/Docker/NxWitness.Dockerfile @@ -7,7 +7,8 @@ # https://support.networkoptix.com/hc/en-us/articles/205313168-Nx-Witness-Operating-System-Support # Latest Ubuntu supported for v6 is Noble -FROM ubuntu:noble +# Base images are built in this repo, see Docker/NxBase*.Dockerfile +FROM docker.io/ptr727/nx-base:ubuntu-noble # Labels ARG LABEL_NAME="NxWitness" @@ -33,12 +34,8 @@ ARG \ # 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 +# Prevent EULA and confirmation prompts in installers +ARG DEBIAN_FRONTEND=noninteractive # Media server user and directory name ENV COMPANY_NAME=${RUNTIME_NAME} @@ -49,29 +46,50 @@ LABEL name=${LABEL_NAME}-${DOWNLOAD_VERSION} \ version=${LABEL_VERSION} \ maintainer="Pieter Viljoen " -# Install required tools and utilities -RUN apt-get update \ - && apt-get upgrade --yes \ - && apt-get install --no-install-recommends --yes \ - ca-certificates \ - unzip \ - wget - +# Base image includes required tools and utilities. # 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 /bin/bash -euo pipefail -c '\ + DEB_FILE="./vms_server.deb"; \ + TARGET_PLATFORM="${TARGETPLATFORM:-}"; \ + DOWNLOAD_URL="${DOWNLOAD_X64_URL:?DOWNLOAD_X64_URL is required}"; \ + if [ "${TARGET_PLATFORM}" = "linux/arm64" ]; then \ + DOWNLOAD_URL="${DOWNLOAD_ARM64_URL:?DOWNLOAD_ARM64_URL is required}"; \ + fi; \ + echo "Download URL: ${DOWNLOAD_URL}"; \ + DOWNLOAD_FILENAME="$(basename -- "${DOWNLOAD_URL}")"; \ + echo "Download Filename: ${DOWNLOAD_FILENAME}"; \ + wget --no-verbose --tries=5 --timeout=30 --retry-connrefused "${DOWNLOAD_URL}"; \ + case "${DOWNLOAD_FILENAME}" in \ + *.zip) \ + echo "Downloaded ZIP: ${DOWNLOAD_FILENAME}"; \ + DOWNLOAD_DIR="./download_zip"; \ + rm -rf "${DOWNLOAD_DIR}"; \ + mkdir -p "${DOWNLOAD_DIR}"; \ + unzip -q -d "${DOWNLOAD_DIR}" "${DOWNLOAD_FILENAME}"; \ + DEB_ZIP_FILE="$(find "${DOWNLOAD_DIR}" -maxdepth 1 -type f -name "*.deb" -print -quit)"; \ + if [ -z "${DEB_ZIP_FILE}" ]; then \ + echo "No .deb found in ${DOWNLOAD_DIR}" >&2; \ + exit 1; \ + fi; \ + echo "DEB in ZIP: ${DEB_ZIP_FILE}"; \ + mv "${DEB_ZIP_FILE}" "${DEB_FILE}"; \ + rm -rf "${DOWNLOAD_DIR}" "${DOWNLOAD_FILENAME}"; \ + ;; \ + *.deb) \ + echo "Downloaded DEB: ${DOWNLOAD_FILENAME}"; \ + mv "${DOWNLOAD_FILENAME}" "${DEB_FILE}"; \ + ;; \ + *) \ + echo "Unsupported download type: ${DOWNLOAD_FILENAME}" >&2; \ + exit 1; \ + ;; \ + esac; \ + echo "DEB File: ${DEB_FILE}"' + +# Install the mediaserver RUN apt-get update \ - # https://github.com/ptr727/NxWitness/issues/282 && apt-get install --no-install-recommends --yes \ - gdb \ - libdrm2 \ - sudo \ ./vms_server.deb \ # Cleanup && apt-get clean \ diff --git a/Docker/WisenetWAVE-LSIO.Dockerfile b/Docker/WisenetWAVE-LSIO.Dockerfile index 8549b5e..18a3cf2 100644 --- a/Docker/WisenetWAVE-LSIO.Dockerfile +++ b/Docker/WisenetWAVE-LSIO.Dockerfile @@ -7,7 +7,8 @@ # https://support.networkoptix.com/hc/en-us/articles/205313168-Nx-Witness-Operating-System-Support # Latest Ubuntu supported for v6 is Noble -FROM lsiobase/ubuntu:noble +# Base images are built in this repo, see Docker/NxBase*.Dockerfile +FROM docker.io/ptr727/nx-base-lsio:ubuntu-noble # Labels ARG LABEL_NAME="WisenetWAVE-LSIO" @@ -33,12 +34,8 @@ ARG \ # 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 +# Prevent EULA and confirmation prompts in installers +ARG DEBIAN_FRONTEND=noninteractive # Media server user and directory name ENV COMPANY_NAME=${RUNTIME_NAME} @@ -49,21 +46,46 @@ LABEL name=${LABEL_NAME}-${DOWNLOAD_VERSION} \ version=${LABEL_VERSION} \ maintainer="Pieter Viljoen " -# Install required tools and utilities -RUN apt-get update \ - && apt-get upgrade --yes \ - && apt-get install --no-install-recommends --yes \ - ca-certificates \ - unzip \ - wget - +# Base image includes required tools and utilities. # 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 +RUN /bin/bash -euo pipefail -c '\ + DEB_FILE="./vms_server.deb"; \ + TARGET_PLATFORM="${TARGETPLATFORM:-}"; \ + DOWNLOAD_URL="${DOWNLOAD_X64_URL:?DOWNLOAD_X64_URL is required}"; \ + if [ "${TARGET_PLATFORM}" = "linux/arm64" ]; then \ + DOWNLOAD_URL="${DOWNLOAD_ARM64_URL:?DOWNLOAD_ARM64_URL is required}"; \ + fi; \ + echo "Download URL: ${DOWNLOAD_URL}"; \ + DOWNLOAD_FILENAME="$(basename -- "${DOWNLOAD_URL}")"; \ + echo "Download Filename: ${DOWNLOAD_FILENAME}"; \ + wget --no-verbose --tries=5 --timeout=30 --retry-connrefused "${DOWNLOAD_URL}"; \ + case "${DOWNLOAD_FILENAME}" in \ + *.zip) \ + echo "Downloaded ZIP: ${DOWNLOAD_FILENAME}"; \ + DOWNLOAD_DIR="./download_zip"; \ + rm -rf "${DOWNLOAD_DIR}"; \ + mkdir -p "${DOWNLOAD_DIR}"; \ + unzip -q -d "${DOWNLOAD_DIR}" "${DOWNLOAD_FILENAME}"; \ + DEB_ZIP_FILE="$(find "${DOWNLOAD_DIR}" -maxdepth 1 -type f -name "*.deb" -print -quit)"; \ + if [ -z "${DEB_ZIP_FILE}" ]; then \ + echo "No .deb found in ${DOWNLOAD_DIR}" >&2; \ + exit 1; \ + fi; \ + echo "DEB in ZIP: ${DEB_ZIP_FILE}"; \ + mv "${DEB_ZIP_FILE}" "${DEB_FILE}"; \ + rm -rf "${DOWNLOAD_DIR}" "${DOWNLOAD_FILENAME}"; \ + ;; \ + *.deb) \ + echo "Downloaded DEB: ${DOWNLOAD_FILENAME}"; \ + mv "${DOWNLOAD_FILENAME}" "${DEB_FILE}"; \ + ;; \ + *) \ + echo "Unsupported download type: ${DOWNLOAD_FILENAME}" >&2; \ + exit 1; \ + ;; \ + esac; \ + echo "DEB File: ${DEB_FILE}"' # LSIO maps the host PUID and PGID environment variables to "abc" in the container. # https://docs.linuxserver.io/misc/non-root/ @@ -78,12 +100,9 @@ RUN usermod -l ${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 +# Install the mediaserver RUN apt-get update \ - # https://github.com/ptr727/NxWitness/issues/282 && apt-get install --no-install-recommends --yes \ - gdb \ - libdrm2 \ ./vms_server.deb \ # Cleanup && apt-get clean \ diff --git a/Docker/WisenetWAVE.Dockerfile b/Docker/WisenetWAVE.Dockerfile index 32d5063..0233fc1 100644 --- a/Docker/WisenetWAVE.Dockerfile +++ b/Docker/WisenetWAVE.Dockerfile @@ -7,7 +7,8 @@ # https://support.networkoptix.com/hc/en-us/articles/205313168-Nx-Witness-Operating-System-Support # Latest Ubuntu supported for v6 is Noble -FROM ubuntu:noble +# Base images are built in this repo, see Docker/NxBase*.Dockerfile +FROM docker.io/ptr727/nx-base:ubuntu-noble # Labels ARG LABEL_NAME="WisenetWAVE" @@ -33,12 +34,8 @@ ARG \ # 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 +# Prevent EULA and confirmation prompts in installers +ARG DEBIAN_FRONTEND=noninteractive # Media server user and directory name ENV COMPANY_NAME=${RUNTIME_NAME} @@ -49,29 +46,50 @@ LABEL name=${LABEL_NAME}-${DOWNLOAD_VERSION} \ version=${LABEL_VERSION} \ maintainer="Pieter Viljoen " -# Install required tools and utilities -RUN apt-get update \ - && apt-get upgrade --yes \ - && apt-get install --no-install-recommends --yes \ - ca-certificates \ - unzip \ - wget - +# Base image includes required tools and utilities. # 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 /bin/bash -euo pipefail -c '\ + DEB_FILE="./vms_server.deb"; \ + TARGET_PLATFORM="${TARGETPLATFORM:-}"; \ + DOWNLOAD_URL="${DOWNLOAD_X64_URL:?DOWNLOAD_X64_URL is required}"; \ + if [ "${TARGET_PLATFORM}" = "linux/arm64" ]; then \ + DOWNLOAD_URL="${DOWNLOAD_ARM64_URL:?DOWNLOAD_ARM64_URL is required}"; \ + fi; \ + echo "Download URL: ${DOWNLOAD_URL}"; \ + DOWNLOAD_FILENAME="$(basename -- "${DOWNLOAD_URL}")"; \ + echo "Download Filename: ${DOWNLOAD_FILENAME}"; \ + wget --no-verbose --tries=5 --timeout=30 --retry-connrefused "${DOWNLOAD_URL}"; \ + case "${DOWNLOAD_FILENAME}" in \ + *.zip) \ + echo "Downloaded ZIP: ${DOWNLOAD_FILENAME}"; \ + DOWNLOAD_DIR="./download_zip"; \ + rm -rf "${DOWNLOAD_DIR}"; \ + mkdir -p "${DOWNLOAD_DIR}"; \ + unzip -q -d "${DOWNLOAD_DIR}" "${DOWNLOAD_FILENAME}"; \ + DEB_ZIP_FILE="$(find "${DOWNLOAD_DIR}" -maxdepth 1 -type f -name "*.deb" -print -quit)"; \ + if [ -z "${DEB_ZIP_FILE}" ]; then \ + echo "No .deb found in ${DOWNLOAD_DIR}" >&2; \ + exit 1; \ + fi; \ + echo "DEB in ZIP: ${DEB_ZIP_FILE}"; \ + mv "${DEB_ZIP_FILE}" "${DEB_FILE}"; \ + rm -rf "${DOWNLOAD_DIR}" "${DOWNLOAD_FILENAME}"; \ + ;; \ + *.deb) \ + echo "Downloaded DEB: ${DOWNLOAD_FILENAME}"; \ + mv "${DOWNLOAD_FILENAME}" "${DEB_FILE}"; \ + ;; \ + *) \ + echo "Unsupported download type: ${DOWNLOAD_FILENAME}" >&2; \ + exit 1; \ + ;; \ + esac; \ + echo "DEB File: ${DEB_FILE}"' + +# Install the mediaserver RUN apt-get update \ - # https://github.com/ptr727/NxWitness/issues/282 && apt-get install --no-install-recommends --yes \ - gdb \ - libdrm2 \ - sudo \ ./vms_server.deb \ # Cleanup && apt-get clean \ diff --git a/Docker/download.sh b/Docker/download.sh deleted file mode 100755 index b80459e..0000000 --- a/Docker/download.sh +++ /dev/null @@ -1,37 +0,0 @@ -#!/bin/bash - -# Installer expected filename -DEB_FILE="./vms_server.deb" - -# Use X64 or ARM64 URL -DOWNLOAD_URL=${DOWNLOAD_X64_URL} -if [ "${TARGETPLATFORM}" == "linux/arm64" ]; then - DOWNLOAD_URL=${DOWNLOAD_ARM64_URL}; - fi - -# Get the filename fom the URL -echo "Download URL: ${DOWNLOAD_URL}" -DOWNLOAD_FILENAME=$(basename "$DOWNLOAD_URL") -echo "Download Filename: ${DOWNLOAD_FILENAME}" - -# Download the file -wget --no-verbose ${DOWNLOAD_URL} - -# Test if the filename is a DEB file or a ZIP file -if [ "${DOWNLOAD_FILENAME: -4}" == ".zip" ] -then - echo "Downloaded ZIP: ${DOWNLOAD_FILENAME}" - # Extract the zip contents - unzip -d ./download_zip ${DOWNLOAD_FILENAME} - # The DEB file is not always the same name as the ZIP file, get the DEB filename - DEB_FILES=( ./download_zip/*.deb ) - DEB_ZIP_FILE=${DEB_FILES[0]} - echo "DEB in ZIP: ${DEB_ZIP_FILE}" - # Copy - cp ${DEB_ZIP_FILE} ${DEB_FILE} -else - echo "Downloaded DEB: ${DOWNLOAD_FILENAME}" - # Copy - cp ${DOWNLOAD_FILENAME} ./vms_server.deb -fi -echo "DEB File: ${DEB_FILE}" diff --git a/HISTORY.md b/HISTORY.md index 1d684c2..f0455a5 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -4,11 +4,13 @@ This is a project to build and publish docker images for various [Network Optix] ## Release History +- Version 2.10: + - Split the docker images into a base image and product images, improves build times and reduces GH actions cache utilization. - Version 2.9: - Refactoring to match layout and style used in other projects. - Updated to .NET 10, adding support for Nullable, and AOT. - Restructured CLI handling logic. - - Update GHA cache usage to prevent the cache from running out of space. + - Update GHA cache usage to prevent the GH actions cache from running out of space. - Version 2.8: - Add default `analytics` volume, along with `media` and `backup` volumes, media server complains when sharing analytics storage. - Version 2.7: diff --git a/Make/Build.sh b/Make/Build.sh index 1af9b18..d911e2f 100755 --- a/Make/Build.sh +++ b/Make/Build.sh @@ -1,12 +1,10 @@ #!/bin/bash -set -e +set -euo pipefail ## Dependencies: # sudo apt update && sudo apt upgrade --yes -# sudo add-apt-repository ppa:dotnet/backports --yes && sudo apt update -# sudo apt install m4 dotnet-sdk-9.0 docker-compose docker-buildx --yes -# sudo apt autoremove --yes +# sudo apt install dotnet-sdk-10.0 docker-compose docker-buildx --yes ## Test installing in container: @@ -34,8 +32,8 @@ set -e # docker exec --interactive --tty [containername] /bin/bash ## Usage: -# Create.sh : Update Version.json and Matrix.json and create Dockerfile's from M4 snippets. -# Build.sh : Build docker images from Dockerfile's. +# Create.sh : Update Version.json and Matrix.json and create Dockerfiles. +# PUSH_BASE_IMAGES=true ./Build.sh : Build docker images from Dockerfiles and push base images. # Test.sh : Create and build and launch compose Test.yml compose stack. # Clean.sh : Shutdown compose stack and delete images. @@ -48,8 +46,38 @@ function BuildDockerfile { docker buildx build --platform linux/amd64 --load --tag test_${1,,} --file ../Docker/$1.Dockerfile ../Docker } +# Build base Dockerfile +function BuildBaseDockerfile { + local PushBaseImages + local RegistryCacheFrom + PushBaseImages="${PUSH_BASE_IMAGES:-false}" + RegistryCacheFrom="--cache-from=type=registry,ref=$2" + # Build x64 and ARM64 targets + if [[ "${PushBaseImages}" == "true" ]]; then + docker buildx build --platform linux/amd64,linux/arm64 --push --cache-to=type=inline ${RegistryCacheFrom} --tag $2 --file ../Docker/$1.Dockerfile ../Docker + else + docker buildx build --platform linux/amd64,linux/arm64 ${RegistryCacheFrom} --tag $2 --file ../Docker/$1.Dockerfile ../Docker + fi + # Build and load x64 target + docker buildx build --platform linux/amd64 --load ${RegistryCacheFrom} --tag $2 --file ../Docker/$1.Dockerfile ../Docker +} + # Create and use multi platform build environment -docker buildx create --name "nxwitness" --use || true +if docker buildx inspect "nxwitness" >/dev/null 2>&1; then + docker buildx use "nxwitness" +else + docker buildx create --name "nxwitness" --use +fi + +# Login to docker Hub if pushing base images +if [[ "${PUSH_BASE_IMAGES:-false}" == "true" ]]; then + echo "Pushing base images with inline cache metadata. Please login to Docker Hub if not already logged in." + docker login +fi + +# Build base Dockerfiles +BuildBaseDockerfile "NxBase" "docker.io/ptr727/nx-base:ubuntu-noble" +BuildBaseDockerfile "NxBase-LSIO" "docker.io/ptr727/nx-base-lsio:ubuntu-noble" # Build Dockerfiles BuildDockerfile "NxGo" diff --git a/Make/Clean.sh b/Make/Clean.sh index a32010b..103e305 100755 --- a/Make/Clean.sh +++ b/Make/Clean.sh @@ -1,6 +1,6 @@ #!/bin/bash -set -e +set -euo pipefail # Delete images function DeleteImage { diff --git a/Make/Create.sh b/Make/Create.sh index 2f311c3..cb32acd 100755 --- a/Make/Create.sh +++ b/Make/Create.sh @@ -1,9 +1,9 @@ #!/bin/bash -set -e +set -euo pipefail # Update Version.json and create Matrix.json dotnet run --project ../CreateMatrix -- matrix --updateversion --versionpath=Version.json --matrixpath=Matrix.json # Create Dockerfiles -dotnet run --project ../CreateMatrix -- make --versionpath=Version.json --makedirectory=./ --dockerdirectory=../Docker --versionlabel=Beta +dotnet run --project ../CreateMatrix -- make --versionpath=Version.json --makedirectory=./ --dockerdirectory=../Docker diff --git a/Make/Down-develop.sh b/Make/Down-develop.sh index b6a290a..d5f1957 100755 --- a/Make/Down-develop.sh +++ b/Make/Down-develop.sh @@ -1,6 +1,6 @@ #!/bin/bash -set -e +set -euo pipefail # Stop stack and cleanup volumes docker compose --file Test-develop.yml down --volumes diff --git a/Make/Down-latest.sh b/Make/Down-latest.sh index a77078b..205a2f2 100755 --- a/Make/Down-latest.sh +++ b/Make/Down-latest.sh @@ -1,6 +1,6 @@ #!/bin/bash -set -e +set -euo pipefail # Stop stack and cleanup volumes docker compose --file Test-latest.yml down --volumes diff --git a/Make/Down.sh b/Make/Down.sh index 80c4815..6780879 100755 --- a/Make/Down.sh +++ b/Make/Down.sh @@ -1,8 +1,8 @@ #!/bin/bash -set -e +set -euo pipefail # Stop stack and cleanup volumes docker compose --file Test.yml down --volumes -echo "Run 'Clean.sh' to delete images" \ No newline at end of file +echo "Run 'Clean.sh' to delete images" diff --git a/Make/Instructions.sh b/Make/Instructions.sh index c146f5b..d36b54a 100755 --- a/Make/Instructions.sh +++ b/Make/Instructions.sh @@ -1,5 +1,7 @@ #!/bin/bash +set -euo pipefail + # Instructions echo "Ctrl-Click on links to launch web UI in browser" echo "Nx Go:" "https://$HOSTNAME:7101/" diff --git a/Make/Matrix.json b/Make/Matrix.json index 2e5280c..38c2c2a 100644 --- a/Make/Matrix.json +++ b/Make/Matrix.json @@ -3,8 +3,9 @@ "Images": [ { "Name": "NxGo", + "Product": "nxgo", "Branch": "main", - "CacheScope": "default", + "Base": "ubuntu", "Tags": [ "docker.io/ptr727/nxgo:6.1.0.42176", "docker.io/ptr727/nxgo:latest", @@ -16,10 +17,27 @@ "DOWNLOAD_X64_URL=https://updates.networkoptix.com/nxgo/42176/nxgo-server_update-6.1.0.42176-linux_x64.zip" ] }, + { + "Name": "NxGo", + "Product": "nxgo", + "Branch": "develop", + "Base": "ubuntu", + "Tags": [ + "docker.io/ptr727/nxgo:develop", + "docker.io/ptr727/nxgo:develop-6.1.0.42176", + "docker.io/ptr727/nxgo:develop-stable" + ], + "Args": [ + "DOWNLOAD_ARM64_URL=https://updates.networkoptix.com/nxgo/42176/nxgo-server_update-6.1.0.42176-linux_arm64.zip", + "DOWNLOAD_VERSION=6.1.0.42176", + "DOWNLOAD_X64_URL=https://updates.networkoptix.com/nxgo/42176/nxgo-server_update-6.1.0.42176-linux_x64.zip" + ] + }, { "Name": "NxGo-LSIO", + "Product": "nxgo", "Branch": "main", - "CacheScope": "lsio", + "Base": "lsio", "Tags": [ "docker.io/ptr727/nxgo-lsio:6.1.0.42176", "docker.io/ptr727/nxgo-lsio:latest", @@ -31,10 +49,27 @@ "DOWNLOAD_X64_URL=https://updates.networkoptix.com/nxgo/42176/nxgo-server_update-6.1.0.42176-linux_x64.zip" ] }, + { + "Name": "NxGo-LSIO", + "Product": "nxgo", + "Branch": "develop", + "Base": "lsio", + "Tags": [ + "docker.io/ptr727/nxgo-lsio:develop", + "docker.io/ptr727/nxgo-lsio:develop-6.1.0.42176", + "docker.io/ptr727/nxgo-lsio:develop-stable" + ], + "Args": [ + "DOWNLOAD_ARM64_URL=https://updates.networkoptix.com/nxgo/42176/nxgo-server_update-6.1.0.42176-linux_arm64.zip", + "DOWNLOAD_VERSION=6.1.0.42176", + "DOWNLOAD_X64_URL=https://updates.networkoptix.com/nxgo/42176/nxgo-server_update-6.1.0.42176-linux_x64.zip" + ] + }, { "Name": "NxMeta", + "Product": "nxmeta", "Branch": "main", - "CacheScope": "default", + "Base": "ubuntu", "Tags": [ "docker.io/ptr727/nxmeta:6.1.0.42176", "docker.io/ptr727/nxmeta:latest", @@ -46,10 +81,27 @@ "DOWNLOAD_X64_URL=https://updates.networkoptix.com/metavms/42176/metavms-server_update-6.1.0.42176-linux_x64.zip" ] }, + { + "Name": "NxMeta", + "Product": "nxmeta", + "Branch": "develop", + "Base": "ubuntu", + "Tags": [ + "docker.io/ptr727/nxmeta:develop", + "docker.io/ptr727/nxmeta:develop-6.1.0.42176", + "docker.io/ptr727/nxmeta:develop-stable" + ], + "Args": [ + "DOWNLOAD_ARM64_URL=https://updates.networkoptix.com/metavms/42176/metavms-server_update-6.1.0.42176-linux_arm64.zip", + "DOWNLOAD_VERSION=6.1.0.42176", + "DOWNLOAD_X64_URL=https://updates.networkoptix.com/metavms/42176/metavms-server_update-6.1.0.42176-linux_x64.zip" + ] + }, { "Name": "NxMeta-LSIO", + "Product": "nxmeta", "Branch": "main", - "CacheScope": "lsio", + "Base": "lsio", "Tags": [ "docker.io/ptr727/nxmeta-lsio:6.1.0.42176", "docker.io/ptr727/nxmeta-lsio:latest", @@ -61,10 +113,27 @@ "DOWNLOAD_X64_URL=https://updates.networkoptix.com/metavms/42176/metavms-server_update-6.1.0.42176-linux_x64.zip" ] }, + { + "Name": "NxMeta-LSIO", + "Product": "nxmeta", + "Branch": "develop", + "Base": "lsio", + "Tags": [ + "docker.io/ptr727/nxmeta-lsio:develop", + "docker.io/ptr727/nxmeta-lsio:develop-6.1.0.42176", + "docker.io/ptr727/nxmeta-lsio:develop-stable" + ], + "Args": [ + "DOWNLOAD_ARM64_URL=https://updates.networkoptix.com/metavms/42176/metavms-server_update-6.1.0.42176-linux_arm64.zip", + "DOWNLOAD_VERSION=6.1.0.42176", + "DOWNLOAD_X64_URL=https://updates.networkoptix.com/metavms/42176/metavms-server_update-6.1.0.42176-linux_x64.zip" + ] + }, { "Name": "NxWitness", + "Product": "nxwitness", "Branch": "main", - "CacheScope": "default", + "Base": "ubuntu", "Tags": [ "docker.io/ptr727/nxwitness:6.1.0.42176", "docker.io/ptr727/nxwitness:latest", @@ -76,10 +145,27 @@ "DOWNLOAD_X64_URL=https://updates.networkoptix.com/default/42176/nxwitness-server_update-6.1.0.42176-linux_x64.zip" ] }, + { + "Name": "NxWitness", + "Product": "nxwitness", + "Branch": "develop", + "Base": "ubuntu", + "Tags": [ + "docker.io/ptr727/nxwitness:develop", + "docker.io/ptr727/nxwitness:develop-6.1.0.42176", + "docker.io/ptr727/nxwitness:develop-stable" + ], + "Args": [ + "DOWNLOAD_ARM64_URL=https://updates.networkoptix.com/default/42176/nxwitness-server_update-6.1.0.42176-linux_arm64.zip", + "DOWNLOAD_VERSION=6.1.0.42176", + "DOWNLOAD_X64_URL=https://updates.networkoptix.com/default/42176/nxwitness-server_update-6.1.0.42176-linux_x64.zip" + ] + }, { "Name": "NxWitness-LSIO", + "Product": "nxwitness", "Branch": "main", - "CacheScope": "lsio", + "Base": "lsio", "Tags": [ "docker.io/ptr727/nxwitness-lsio:6.1.0.42176", "docker.io/ptr727/nxwitness-lsio:latest", @@ -91,10 +177,27 @@ "DOWNLOAD_X64_URL=https://updates.networkoptix.com/default/42176/nxwitness-server_update-6.1.0.42176-linux_x64.zip" ] }, + { + "Name": "NxWitness-LSIO", + "Product": "nxwitness", + "Branch": "develop", + "Base": "lsio", + "Tags": [ + "docker.io/ptr727/nxwitness-lsio:develop", + "docker.io/ptr727/nxwitness-lsio:develop-6.1.0.42176", + "docker.io/ptr727/nxwitness-lsio:develop-stable" + ], + "Args": [ + "DOWNLOAD_ARM64_URL=https://updates.networkoptix.com/default/42176/nxwitness-server_update-6.1.0.42176-linux_arm64.zip", + "DOWNLOAD_VERSION=6.1.0.42176", + "DOWNLOAD_X64_URL=https://updates.networkoptix.com/default/42176/nxwitness-server_update-6.1.0.42176-linux_x64.zip" + ] + }, { "Name": "DWSpectrum", + "Product": "dwspectrum", "Branch": "main", - "CacheScope": "default", + "Base": "ubuntu", "Tags": [ "docker.io/ptr727/dwspectrum:6.0.6.41837", "docker.io/ptr727/dwspectrum:stable" @@ -107,8 +210,9 @@ }, { "Name": "DWSpectrum", + "Product": "dwspectrum", "Branch": "main", - "CacheScope": "default", + "Base": "ubuntu", "Tags": [ "docker.io/ptr727/dwspectrum:6.1.0.42176", "docker.io/ptr727/dwspectrum:latest" @@ -120,12 +224,13 @@ ] }, { - "Name": "DWSpectrum-LSIO", - "Branch": "main", - "CacheScope": "lsio", + "Name": "DWSpectrum", + "Product": "dwspectrum", + "Branch": "develop", + "Base": "ubuntu", "Tags": [ - "docker.io/ptr727/dwspectrum-lsio:6.0.6.41837", - "docker.io/ptr727/dwspectrum-lsio:stable" + "docker.io/ptr727/dwspectrum:develop-6.0.6.41837", + "docker.io/ptr727/dwspectrum:develop-stable" ], "Args": [ "DOWNLOAD_ARM64_URL=https://updates.networkoptix.com/digitalwatchdog/41837/dwspectrum-server_update-6.0.6.41837-linux_arm64.zip", @@ -134,12 +239,13 @@ ] }, { - "Name": "DWSpectrum-LSIO", - "Branch": "main", - "CacheScope": "lsio", + "Name": "DWSpectrum", + "Product": "dwspectrum", + "Branch": "develop", + "Base": "ubuntu", "Tags": [ - "docker.io/ptr727/dwspectrum-lsio:6.1.0.42176", - "docker.io/ptr727/dwspectrum-lsio:latest" + "docker.io/ptr727/dwspectrum:develop", + "docker.io/ptr727/dwspectrum:develop-6.1.0.42176" ], "Args": [ "DOWNLOAD_ARM64_URL=https://updates.networkoptix.com/digitalwatchdog/42176/dwspectrum-server_update-6.1.0.42176-linux_arm64.zip", @@ -148,222 +254,133 @@ ] }, { - "Name": "WisenetWAVE", - "Branch": "main", - "CacheScope": "default", - "Tags": [ - "docker.io/ptr727/wisenetwave:6.0.5.41290", - "docker.io/ptr727/wisenetwave:stable" - ], - "Args": [ - "DOWNLOAD_ARM64_URL=https://updates.networkoptix.com/hanwha/41290/wave-server_update-6.0.5.41290-linux_arm64.zip", - "DOWNLOAD_VERSION=6.0.5.41290", - "DOWNLOAD_X64_URL=https://updates.networkoptix.com/hanwha/41290/wave-server_update-6.0.5.41290-linux_x64.zip" - ] - }, - { - "Name": "WisenetWAVE", - "Branch": "main", - "CacheScope": "default", - "Tags": [ - "docker.io/ptr727/wisenetwave:6.1.0.42176", - "docker.io/ptr727/wisenetwave:latest" - ], - "Args": [ - "DOWNLOAD_ARM64_URL=https://updates.networkoptix.com/hanwha/42176/wave-server_update-6.1.0.42176-linux_arm64.zip", - "DOWNLOAD_VERSION=6.1.0.42176", - "DOWNLOAD_X64_URL=https://updates.networkoptix.com/hanwha/42176/wave-server_update-6.1.0.42176-linux_x64.zip" - ] - }, - { - "Name": "WisenetWAVE-LSIO", + "Name": "DWSpectrum-LSIO", + "Product": "dwspectrum", "Branch": "main", - "CacheScope": "lsio", + "Base": "lsio", "Tags": [ - "docker.io/ptr727/wisenetwave-lsio:6.0.5.41290", - "docker.io/ptr727/wisenetwave-lsio:stable" + "docker.io/ptr727/dwspectrum-lsio:6.0.6.41837", + "docker.io/ptr727/dwspectrum-lsio:stable" ], "Args": [ - "DOWNLOAD_ARM64_URL=https://updates.networkoptix.com/hanwha/41290/wave-server_update-6.0.5.41290-linux_arm64.zip", - "DOWNLOAD_VERSION=6.0.5.41290", - "DOWNLOAD_X64_URL=https://updates.networkoptix.com/hanwha/41290/wave-server_update-6.0.5.41290-linux_x64.zip" + "DOWNLOAD_ARM64_URL=https://updates.networkoptix.com/digitalwatchdog/41837/dwspectrum-server_update-6.0.6.41837-linux_arm64.zip", + "DOWNLOAD_VERSION=6.0.6.41837", + "DOWNLOAD_X64_URL=https://updates.networkoptix.com/digitalwatchdog/41837/dwspectrum-server_update-6.0.6.41837-linux_x64.zip" ] }, { - "Name": "WisenetWAVE-LSIO", + "Name": "DWSpectrum-LSIO", + "Product": "dwspectrum", "Branch": "main", - "CacheScope": "lsio", - "Tags": [ - "docker.io/ptr727/wisenetwave-lsio:6.1.0.42176", - "docker.io/ptr727/wisenetwave-lsio:latest" - ], - "Args": [ - "DOWNLOAD_ARM64_URL=https://updates.networkoptix.com/hanwha/42176/wave-server_update-6.1.0.42176-linux_arm64.zip", - "DOWNLOAD_VERSION=6.1.0.42176", - "DOWNLOAD_X64_URL=https://updates.networkoptix.com/hanwha/42176/wave-server_update-6.1.0.42176-linux_x64.zip" - ] - }, - { - "Name": "NxGo", - "Branch": "develop", - "CacheScope": "default", - "Tags": [ - "docker.io/ptr727/nxgo:develop", - "docker.io/ptr727/nxgo:develop-6.1.0.42176", - "docker.io/ptr727/nxgo:develop-latest", - "docker.io/ptr727/nxgo:develop-stable" - ], - "Args": [ - "DOWNLOAD_ARM64_URL=https://updates.networkoptix.com/nxgo/42176/nxgo-server_update-6.1.0.42176-linux_arm64.zip", - "DOWNLOAD_VERSION=6.1.0.42176", - "DOWNLOAD_X64_URL=https://updates.networkoptix.com/nxgo/42176/nxgo-server_update-6.1.0.42176-linux_x64.zip" - ] - }, - { - "Name": "NxGo-LSIO", - "Branch": "develop", - "CacheScope": "lsio", - "Tags": [ - "docker.io/ptr727/nxgo-lsio:develop", - "docker.io/ptr727/nxgo-lsio:develop-6.1.0.42176", - "docker.io/ptr727/nxgo-lsio:develop-latest", - "docker.io/ptr727/nxgo-lsio:develop-stable" - ], - "Args": [ - "DOWNLOAD_ARM64_URL=https://updates.networkoptix.com/nxgo/42176/nxgo-server_update-6.1.0.42176-linux_arm64.zip", - "DOWNLOAD_VERSION=6.1.0.42176", - "DOWNLOAD_X64_URL=https://updates.networkoptix.com/nxgo/42176/nxgo-server_update-6.1.0.42176-linux_x64.zip" - ] - }, - { - "Name": "NxMeta", - "Branch": "develop", - "CacheScope": "default", - "Tags": [ - "docker.io/ptr727/nxmeta:develop", - "docker.io/ptr727/nxmeta:develop-6.1.0.42176", - "docker.io/ptr727/nxmeta:develop-latest", - "docker.io/ptr727/nxmeta:develop-stable" - ], - "Args": [ - "DOWNLOAD_ARM64_URL=https://updates.networkoptix.com/metavms/42176/metavms-server_update-6.1.0.42176-linux_arm64.zip", - "DOWNLOAD_VERSION=6.1.0.42176", - "DOWNLOAD_X64_URL=https://updates.networkoptix.com/metavms/42176/metavms-server_update-6.1.0.42176-linux_x64.zip" - ] - }, - { - "Name": "NxMeta-LSIO", - "Branch": "develop", - "CacheScope": "lsio", + "Base": "lsio", "Tags": [ - "docker.io/ptr727/nxmeta-lsio:develop", - "docker.io/ptr727/nxmeta-lsio:develop-6.1.0.42176", - "docker.io/ptr727/nxmeta-lsio:develop-latest", - "docker.io/ptr727/nxmeta-lsio:develop-stable" + "docker.io/ptr727/dwspectrum-lsio:6.1.0.42176", + "docker.io/ptr727/dwspectrum-lsio:latest" ], "Args": [ - "DOWNLOAD_ARM64_URL=https://updates.networkoptix.com/metavms/42176/metavms-server_update-6.1.0.42176-linux_arm64.zip", + "DOWNLOAD_ARM64_URL=https://updates.networkoptix.com/digitalwatchdog/42176/dwspectrum-server_update-6.1.0.42176-linux_arm64.zip", "DOWNLOAD_VERSION=6.1.0.42176", - "DOWNLOAD_X64_URL=https://updates.networkoptix.com/metavms/42176/metavms-server_update-6.1.0.42176-linux_x64.zip" + "DOWNLOAD_X64_URL=https://updates.networkoptix.com/digitalwatchdog/42176/dwspectrum-server_update-6.1.0.42176-linux_x64.zip" ] }, { - "Name": "NxWitness", + "Name": "DWSpectrum-LSIO", + "Product": "dwspectrum", "Branch": "develop", - "CacheScope": "default", + "Base": "lsio", "Tags": [ - "docker.io/ptr727/nxwitness:develop", - "docker.io/ptr727/nxwitness:develop-6.1.0.42176", - "docker.io/ptr727/nxwitness:develop-latest", - "docker.io/ptr727/nxwitness:develop-stable" + "docker.io/ptr727/dwspectrum-lsio:develop-6.0.6.41837", + "docker.io/ptr727/dwspectrum-lsio:develop-stable" ], "Args": [ - "DOWNLOAD_ARM64_URL=https://updates.networkoptix.com/default/42176/nxwitness-server_update-6.1.0.42176-linux_arm64.zip", - "DOWNLOAD_VERSION=6.1.0.42176", - "DOWNLOAD_X64_URL=https://updates.networkoptix.com/default/42176/nxwitness-server_update-6.1.0.42176-linux_x64.zip" + "DOWNLOAD_ARM64_URL=https://updates.networkoptix.com/digitalwatchdog/41837/dwspectrum-server_update-6.0.6.41837-linux_arm64.zip", + "DOWNLOAD_VERSION=6.0.6.41837", + "DOWNLOAD_X64_URL=https://updates.networkoptix.com/digitalwatchdog/41837/dwspectrum-server_update-6.0.6.41837-linux_x64.zip" ] }, { - "Name": "NxWitness-LSIO", + "Name": "DWSpectrum-LSIO", + "Product": "dwspectrum", "Branch": "develop", - "CacheScope": "lsio", + "Base": "lsio", "Tags": [ - "docker.io/ptr727/nxwitness-lsio:develop", - "docker.io/ptr727/nxwitness-lsio:develop-6.1.0.42176", - "docker.io/ptr727/nxwitness-lsio:develop-latest", - "docker.io/ptr727/nxwitness-lsio:develop-stable" + "docker.io/ptr727/dwspectrum-lsio:develop", + "docker.io/ptr727/dwspectrum-lsio:develop-6.1.0.42176" ], "Args": [ - "DOWNLOAD_ARM64_URL=https://updates.networkoptix.com/default/42176/nxwitness-server_update-6.1.0.42176-linux_arm64.zip", + "DOWNLOAD_ARM64_URL=https://updates.networkoptix.com/digitalwatchdog/42176/dwspectrum-server_update-6.1.0.42176-linux_arm64.zip", "DOWNLOAD_VERSION=6.1.0.42176", - "DOWNLOAD_X64_URL=https://updates.networkoptix.com/default/42176/nxwitness-server_update-6.1.0.42176-linux_x64.zip" + "DOWNLOAD_X64_URL=https://updates.networkoptix.com/digitalwatchdog/42176/dwspectrum-server_update-6.1.0.42176-linux_x64.zip" ] }, { - "Name": "DWSpectrum", - "Branch": "develop", - "CacheScope": "default", + "Name": "WisenetWAVE", + "Product": "wisenetwave", + "Branch": "main", + "Base": "ubuntu", "Tags": [ - "docker.io/ptr727/dwspectrum:develop-6.0.6.41837", - "docker.io/ptr727/dwspectrum:develop-stable" + "docker.io/ptr727/wisenetwave:6.0.5.41290", + "docker.io/ptr727/wisenetwave:stable" ], "Args": [ - "DOWNLOAD_ARM64_URL=https://updates.networkoptix.com/digitalwatchdog/41837/dwspectrum-server_update-6.0.6.41837-linux_arm64.zip", - "DOWNLOAD_VERSION=6.0.6.41837", - "DOWNLOAD_X64_URL=https://updates.networkoptix.com/digitalwatchdog/41837/dwspectrum-server_update-6.0.6.41837-linux_x64.zip" + "DOWNLOAD_ARM64_URL=https://updates.networkoptix.com/hanwha/41290/wave-server_update-6.0.5.41290-linux_arm64.zip", + "DOWNLOAD_VERSION=6.0.5.41290", + "DOWNLOAD_X64_URL=https://updates.networkoptix.com/hanwha/41290/wave-server_update-6.0.5.41290-linux_x64.zip" ] }, { - "Name": "DWSpectrum", - "Branch": "develop", - "CacheScope": "default", + "Name": "WisenetWAVE", + "Product": "wisenetwave", + "Branch": "main", + "Base": "ubuntu", "Tags": [ - "docker.io/ptr727/dwspectrum:develop", - "docker.io/ptr727/dwspectrum:develop-6.1.0.42176", - "docker.io/ptr727/dwspectrum:develop-latest" + "docker.io/ptr727/wisenetwave:6.1.0.42176", + "docker.io/ptr727/wisenetwave:latest" ], "Args": [ - "DOWNLOAD_ARM64_URL=https://updates.networkoptix.com/digitalwatchdog/42176/dwspectrum-server_update-6.1.0.42176-linux_arm64.zip", + "DOWNLOAD_ARM64_URL=https://updates.networkoptix.com/hanwha/42176/wave-server_update-6.1.0.42176-linux_arm64.zip", "DOWNLOAD_VERSION=6.1.0.42176", - "DOWNLOAD_X64_URL=https://updates.networkoptix.com/digitalwatchdog/42176/dwspectrum-server_update-6.1.0.42176-linux_x64.zip" + "DOWNLOAD_X64_URL=https://updates.networkoptix.com/hanwha/42176/wave-server_update-6.1.0.42176-linux_x64.zip" ] }, { - "Name": "DWSpectrum-LSIO", + "Name": "WisenetWAVE", + "Product": "wisenetwave", "Branch": "develop", - "CacheScope": "lsio", + "Base": "ubuntu", "Tags": [ - "docker.io/ptr727/dwspectrum-lsio:develop-6.0.6.41837", - "docker.io/ptr727/dwspectrum-lsio:develop-stable" + "docker.io/ptr727/wisenetwave:develop-6.0.5.41290", + "docker.io/ptr727/wisenetwave:develop-stable" ], "Args": [ - "DOWNLOAD_ARM64_URL=https://updates.networkoptix.com/digitalwatchdog/41837/dwspectrum-server_update-6.0.6.41837-linux_arm64.zip", - "DOWNLOAD_VERSION=6.0.6.41837", - "DOWNLOAD_X64_URL=https://updates.networkoptix.com/digitalwatchdog/41837/dwspectrum-server_update-6.0.6.41837-linux_x64.zip" + "DOWNLOAD_ARM64_URL=https://updates.networkoptix.com/hanwha/41290/wave-server_update-6.0.5.41290-linux_arm64.zip", + "DOWNLOAD_VERSION=6.0.5.41290", + "DOWNLOAD_X64_URL=https://updates.networkoptix.com/hanwha/41290/wave-server_update-6.0.5.41290-linux_x64.zip" ] }, { - "Name": "DWSpectrum-LSIO", + "Name": "WisenetWAVE", + "Product": "wisenetwave", "Branch": "develop", - "CacheScope": "lsio", + "Base": "ubuntu", "Tags": [ - "docker.io/ptr727/dwspectrum-lsio:develop", - "docker.io/ptr727/dwspectrum-lsio:develop-6.1.0.42176", - "docker.io/ptr727/dwspectrum-lsio:develop-latest" + "docker.io/ptr727/wisenetwave:develop", + "docker.io/ptr727/wisenetwave:develop-6.1.0.42176" ], "Args": [ - "DOWNLOAD_ARM64_URL=https://updates.networkoptix.com/digitalwatchdog/42176/dwspectrum-server_update-6.1.0.42176-linux_arm64.zip", + "DOWNLOAD_ARM64_URL=https://updates.networkoptix.com/hanwha/42176/wave-server_update-6.1.0.42176-linux_arm64.zip", "DOWNLOAD_VERSION=6.1.0.42176", - "DOWNLOAD_X64_URL=https://updates.networkoptix.com/digitalwatchdog/42176/dwspectrum-server_update-6.1.0.42176-linux_x64.zip" + "DOWNLOAD_X64_URL=https://updates.networkoptix.com/hanwha/42176/wave-server_update-6.1.0.42176-linux_x64.zip" ] }, { - "Name": "WisenetWAVE", - "Branch": "develop", - "CacheScope": "default", + "Name": "WisenetWAVE-LSIO", + "Product": "wisenetwave", + "Branch": "main", + "Base": "lsio", "Tags": [ - "docker.io/ptr727/wisenetwave:develop-6.0.5.41290", - "docker.io/ptr727/wisenetwave:develop-stable" + "docker.io/ptr727/wisenetwave-lsio:6.0.5.41290", + "docker.io/ptr727/wisenetwave-lsio:stable" ], "Args": [ "DOWNLOAD_ARM64_URL=https://updates.networkoptix.com/hanwha/41290/wave-server_update-6.0.5.41290-linux_arm64.zip", @@ -372,13 +389,13 @@ ] }, { - "Name": "WisenetWAVE", - "Branch": "develop", - "CacheScope": "default", + "Name": "WisenetWAVE-LSIO", + "Product": "wisenetwave", + "Branch": "main", + "Base": "lsio", "Tags": [ - "docker.io/ptr727/wisenetwave:develop", - "docker.io/ptr727/wisenetwave:develop-6.1.0.42176", - "docker.io/ptr727/wisenetwave:develop-latest" + "docker.io/ptr727/wisenetwave-lsio:6.1.0.42176", + "docker.io/ptr727/wisenetwave-lsio:latest" ], "Args": [ "DOWNLOAD_ARM64_URL=https://updates.networkoptix.com/hanwha/42176/wave-server_update-6.1.0.42176-linux_arm64.zip", @@ -388,8 +405,9 @@ }, { "Name": "WisenetWAVE-LSIO", + "Product": "wisenetwave", "Branch": "develop", - "CacheScope": "lsio", + "Base": "lsio", "Tags": [ "docker.io/ptr727/wisenetwave-lsio:develop-6.0.5.41290", "docker.io/ptr727/wisenetwave-lsio:develop-stable" @@ -402,12 +420,12 @@ }, { "Name": "WisenetWAVE-LSIO", + "Product": "wisenetwave", "Branch": "develop", - "CacheScope": "lsio", + "Base": "lsio", "Tags": [ "docker.io/ptr727/wisenetwave-lsio:develop", - "docker.io/ptr727/wisenetwave-lsio:develop-6.1.0.42176", - "docker.io/ptr727/wisenetwave-lsio:develop-latest" + "docker.io/ptr727/wisenetwave-lsio:develop-6.1.0.42176" ], "Args": [ "DOWNLOAD_ARM64_URL=https://updates.networkoptix.com/hanwha/42176/wave-server_update-6.1.0.42176-linux_arm64.zip", diff --git a/Make/Test.sh b/Make/Test.sh index 85a9137..afbaa5b 100755 --- a/Make/Test.sh +++ b/Make/Test.sh @@ -1,11 +1,11 @@ #!/bin/bash -set -e +set -euo pipefail -# Create Dockerfile from M4 +# Create Dockerfiles ./Create.sh -# Build Dockerfile +# Build Dockerfiles ./Build.sh # Launch compose stack diff --git a/Make/Up-develop.sh b/Make/Up-develop.sh index c7888b1..70e9b7a 100755 --- a/Make/Up-develop.sh +++ b/Make/Up-develop.sh @@ -1,6 +1,6 @@ #!/bin/bash -set -e +set -euo pipefail # Launch stack docker compose --file Test-develop.yml up --detach diff --git a/Make/Up-latest.sh b/Make/Up-latest.sh index 3ab6e36..67a99ba 100755 --- a/Make/Up-latest.sh +++ b/Make/Up-latest.sh @@ -1,6 +1,6 @@ #!/bin/bash -set -e +set -euo pipefail # Launch stack docker compose --file Test-latest.yml up --detach diff --git a/Make/Up.sh b/Make/Up.sh index b2f7639..deb6b27 100755 --- a/Make/Up.sh +++ b/Make/Up.sh @@ -1,6 +1,6 @@ #!/bin/bash -set -e +set -euo pipefail # Launch stack docker compose --file Test.yml up --detach diff --git a/NxWitness.code-workspace b/NxWitness.code-workspace index 15e882f..adacbca 100644 --- a/NxWitness.code-workspace +++ b/NxWitness.code-workspace @@ -18,6 +18,7 @@ "buildx", "cloudhost", "Composefile", + "connrefused", "contentfiles", "csdevkit", "davidanson", @@ -28,6 +29,7 @@ "domainname", "dotnettools", "dwspectrum", + "esac", "filesystems", "getmatrix", "gruntfuggly", @@ -60,6 +62,7 @@ "Optix", "PGID", "Pieter", + "pipefail", "posixacl", "PUID", "relatime", diff --git a/README.md b/README.md index 52bd7e0..13e9ddb 100644 --- a/README.md +++ b/README.md @@ -12,12 +12,11 @@ This is a project to build and publish docker images for various [Network Optix] ### Release Notes -**Version: 2.9**: +**Version: 2.10**: **Summary**: -- Refactoring to match layout and style used in other projects. -- Updated to .NET 10, adding support for Nullable and AOT. +- Split the docker images into a base image and product images, improves build times and reduces GH actions cache utilization. See [Release History](./HISTORY.md) for complete release notes and older versions. @@ -265,8 +264,12 @@ Today Network Optix supports [Docker][nxdocker-link], and they publish [build sc The project creates two variants of each product using different base images: -- [Ubuntu][ubuntu-link] using [ubuntu:jammy][ubuntudocker-link] base image. -- [LinuxServer][lsio-link] using [lsiobase/ubuntu:jammy][ubuntulsiodocker-link] base image. +- [Ubuntu][ubuntu-link] using [ubuntu:noble][ubuntudocker-link] base image. +- [LinuxServer][lsio-link] using [lsiobase/ubuntu:noble][ubuntulsiodocker-link] base image. + +The build pipeline also publishes internal base images (`ptr727/nx-base:ubuntu-noble` and +`ptr727/nx-base-lsio:ubuntu-noble`) built from `ubuntu:noble` and `lsiobase/ubuntu:noble` +to reduce CI cache churn. These base images are not intended for end-user deployments. Note that smaller base images like [Alpine][alpine-link] are not [supported][nxossupport-link] by the mediaserver. diff --git a/version.json b/version.json index 8ab1689..7dc755a 100644 --- a/version.json +++ b/version.json @@ -1,6 +1,6 @@ { "$schema": "https://raw.githubusercontent.com/dotnet/Nerdbank.GitVersioning/master/src/NerdBank.GitVersioning/version.schema.json", - "version": "2.9", + "version": "2.10", "publicReleaseRefSpec": [ "^refs/heads/main$" ],