├── files ├── logrotate.d │ └── nimble ├── service │ └── nimble │ │ ├── log │ │ └── run │ │ └── run └── my_init.d │ └── nimble_reg ├── Dockerfile └── README.md /files/logrotate.d/nimble: -------------------------------------------------------------------------------- 1 | /var/log/nimble/*.log { 2 | daily 3 | rotate 10 4 | compress 5 | delaycompress 6 | missingok 7 | notifempty 8 | nocreate 9 | } 10 | -------------------------------------------------------------------------------- /files/service/nimble/log/run: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | export LOGDIR=/var/log/nimble 4 | export SVCUSER=nimble 5 | 6 | mkdir -p "${LOGDIR}" && chown ${SVCUSER}:${SVCUSER} "${LOGDIR}" 7 | exec /sbin/setuser ${SVCUSER} svlogd -tt "${LOGDIR}" 8 | 9 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM phusion/baseimage 2 | 3 | ## Install nimble and move all config files to /etc/nimble.conf 4 | ## 5 | RUN echo "deb http://nimblestreamer.com/ubuntu xenial/" > /etc/apt/sources.list.d/nimblestreamer.list \ 6 | && curl -L -s http://nimblestreamer.com/gpg.key | apt-key add - \ 7 | && apt-get update \ 8 | && DEBIAN_FRONTEND=noninteractive apt-get install -y nimble \ 9 | && apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* \ 10 | && mkdir /etc/nimble.conf \ 11 | && mv /etc/nimble/* /etc/nimble.conf 12 | 13 | ## Configuration volume 14 | ## 15 | VOLUME /etc/nimble 16 | 17 | ## Cache volume 18 | ## 19 | VOLUME /var/cache/nimble 20 | 21 | ## WMS panel username and password 22 | ## Only required for first time registration 23 | ## 24 | ENV WMSPANEL_USER "" 25 | ENV WMSPANEL_PASS "" 26 | ENV WMSPANEL_SLICES "" 27 | 28 | ## Service configuration 29 | ## 30 | ADD files/my_init.d /etc/my_init.d 31 | ADD files/service /etc/service 32 | ADD files/logrotate.d /etc/logrotate.d 33 | 34 | EXPOSE 1935 8081 35 | -------------------------------------------------------------------------------- /files/my_init.d/nimble_reg: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -eo pipefail 4 | 5 | # If config file does not exist, try to register the instance 6 | if ! [ -f /etc/nimble/nimble.conf ]; then 7 | 8 | # Need username and password to register 9 | if ! [ -z "$WMSPANEL_USER" ]; then 10 | 11 | cp -fr /etc/nimble.conf/* /etc/nimble 12 | ARGS="" 13 | if ! [ -z "$WMSPANEL_SLICES" ]; then 14 | ARGS="--slices=$WMSPANEL_SLICES" 15 | fi 16 | 17 | # Try to register with apply-rules 18 | if ! /usr/bin/nimble_regutil $ARGS --apply-rules-conf \ 19 | -u "$WMSPANEL_USER" -p "$WMSPANEL_PASS"; then 20 | # Try without apply-rules 21 | if ! /usr/bin/nimble_regutil $ARGS --apply-rules-conf \ 22 | -u "$WMSPANEL_USER" -p "$WMSPANEL_PASS"; then 23 | # Not able to register; remove config again 24 | rm -f /etc/nimble/nimble.conf 25 | fi 26 | fi 27 | fi 28 | fi 29 | 30 | chown -R nimble:root /etc/nimble 31 | chown -R nimble:root /var/cache/nimble 32 | rm -f /etc/nimble/run_as_root 33 | -------------------------------------------------------------------------------- /files/service/nimble/run: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | if ! [ -f /etc/nimble/nimble.conf ]; then 4 | 5 | ## Service is not registered yet 6 | ## 7 | cat <