-
Notifications
You must be signed in to change notification settings - Fork 9
/
NxWitness-LSIO.Dockerfile
113 lines (93 loc) · 4 KB
/
NxWitness-LSIO.Dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
# https://support.networkoptix.com/hc/en-us/articles/205313168-Nx-Witness-Operating-System-Support
# Latest supported for v5.1 is Jammy
# https://hub.docker.com/r/lsiobase/ubuntu/tags?page=1&name=jammy
FROM lsiobase/ubuntu:jammy
# Labels
ARG LABEL_NAME="NxWitness-LSIO"
ARG LABEL_DESCRIPTION="Nx Witness VMS Docker based on LinuxServer"
# Download URL and version
# Current values are defined by the build pipeline
ARG DOWNLOAD_X64_URL="https://updates.networkoptix.com/default/38363/nxwitness-server_update-5.1.3.38363-linux_x64.zip"
ARG DOWNLOAD_ARM64_URL="https://updates.networkoptix.com/default/38363/nxwitness-server_update-5.1.3.38363-linux_arm64.zip"
ARG DOWNLOAD_VERSION="5.1.3.38363"
# NxWitness (networkoptix) or DWSpectrum (digitalwatchdog) or NxMeta (networkoptix-metavms)
ARG RUNTIME_NAME="networkoptix"
# Global builder variables
# https://docs.docker.com/engine/reference/builder/#automatic-platform-args-in-the-global-scope
ARG \
# Platform of the build result. Eg linux/amd64, linux/arm/v7, windows/amd64
TARGETPLATFORM \
# Architecture component of TARGETPLATFORM
TARGETARCH \
# Platform of the node performing the build
BUILDPLATFORM
# The RUN wget command will be cached unless we change the cache tag
# Use the download version for the cache tag
ARG CACHE_DATE=${DOWNLOAD_VERSION}
# Prevent EULA and confirmation prompts in installers
ARG DEBIAN_FRONTEND=noninteractive
# Media server user and directory name
ENV COMPANY_NAME=${RUNTIME_NAME}
# Build tool version set as build argument
ARG LABEL_VERSION="1.0.0.0"
# LABEL_NAME and LABEL_DESCRIPTION set in specific variant of build
# Labels
LABEL name=${LABEL_NAME}-${DOWNLOAD_VERSION} \
description=${LABEL_DESCRIPTION} \
version=${LABEL_VERSION} \
maintainer="Pieter Viljoen <[email protected]>"
# Install required tools and utilities
RUN apt-get update \
&& apt-get upgrade --yes \
&& apt-get install --no-install-recommends --yes \
ca-certificates \
mc \
nano \
unzip \
wget
# Download the installer file
RUN mkdir -p /temp
COPY download.sh /temp/download.sh
# Set the working directory to /temp
WORKDIR /temp
RUN chmod +x download.sh \
&& ./download.sh
# LSIO maps the host PUID and PGID environment variables to "abc" in the container.
# The mediaserver calls "chown ${COMPANY_NAME}" at runtime
# We have to match the ${COMPANY_NAME} username with the LSIO "abc" usernames
# LSIO does not officially support changing the "abc" username
# https://discourse.linuxserver.io/t/changing-abc-container-user/3208
# https://github.com/linuxserver/docker-baseimage-ubuntu/blob/jammy/root/etc/s6-overlay/s6-rc.d/init-adduser/run
# Change user "abc" to ${COMPANY_NAME}
RUN usermod -l ${COMPANY_NAME} abc \
# Change group "abc" to ${COMPANY_NAME}
&& groupmod -n ${COMPANY_NAME} abc \
# Replace "abc" with ${COMPANY_NAME}
&& sed -i "s/abc/\${COMPANY_NAME}/g" /etc/s6-overlay/s6-rc.d/init-adduser/run
# Install the mediaserver and dependencies
RUN apt-get update \
&& apt-get install --no-install-recommends --yes \
gdb \
./vms_server.deb \
# Cleanup
&& apt-get clean \
&& apt-get autoremove --purge \
&& rm -rf /var/lib/apt/lists/* \
&& rm -rf /temp
# Set ownership permissions
RUN chown --verbose ${COMPANY_NAME}:${COMPANY_NAME} /opt/${COMPANY_NAME}/mediaserver/bin \
&& chown --verbose ${COMPANY_NAME}:${COMPANY_NAME} /opt/${COMPANY_NAME}/mediaserver/bin/external.dat
# Copy etc init and services files
# https://github.com/just-containers/s6-overlay#container-environment
# https://www.linuxserver.io/blog/how-is-container-formed
COPY s6-overlay /etc/s6-overlay
# Expose port 7001
EXPOSE 7001
# Create mount points
# Links will be created at runtime in LSIO/etc/s6-overlay/s6-rc.d/init-nx-relocate/run
# /opt/${COMPANY_NAME}/mediaserver/etc -> /config/etc
# /opt/${COMPANY_NAME}/mediaserver/var -> /config/var
# /root/.config/nx_ini links -> /config/ini
# /config is for configuration
# /media is for media recording
VOLUME /config /media