Skip to content

Commit 8be5cfe

Browse files
authored
Merge pull request SensorsIot#739 from Paraphraser/20231024-mjpg-streamer-old-menu
2023-10-24 mjpg-streamer container - old-menu branch - PR 2 of 2
2 parents d7d45c7 + 2a5966c commit 8be5cfe

File tree

4 files changed

+114
-0
lines changed

4 files changed

+114
-0
lines changed

.templates/mjpg-streamer/Dockerfile

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
# supported build argument
2+
ARG DEBIAN_VARIANT=bullseye-slim
3+
4+
# Download base image
5+
FROM debian:${DEBIAN_VARIANT}
6+
7+
# re-reference supported argument and copy to environment var
8+
ARG DEBIAN_VARIANT
9+
ENV DEBIAN_VARIANT=${DEBIAN_VARIANT}
10+
11+
ARG DEBIAN_FRONTEND=noninteractive
12+
ENV TZ=UTC
13+
14+
# Refer https://github.com/jacksonliam/mjpg-streamer/issues/386
15+
# This assumes a Debian build and references:
16+
# libjpeg62-turbo-dev
17+
# For Ubuntu, replace with:
18+
# libjpeg8-dev
19+
20+
# acknowledgement: mostly borrowed from https://github.com/Cossey/docker
21+
RUN apt-get -q -y update \
22+
&& apt-get -q -y -o "DPkg::Options::=--force-confold" -o "DPkg::Options::=--force-confdef" install apt-utils \
23+
&& rm -rf /etc/dpkg/dpkg.cfg.d/excludes \
24+
&& apt-get -q -y -o "DPkg::Options::=--force-confold" -o "DPkg::Options::=--force-confdef" install \
25+
cmake \
26+
git \
27+
gcc \
28+
g++ \
29+
libjpeg62-turbo-dev \
30+
tzdata \
31+
uuid-runtime \
32+
&& apt-get -q -y autoremove \
33+
&& apt-get -q -y clean \
34+
&& rm -rf /var/lib/apt/lists/* \
35+
&& git clone https://github.com/jacksonliam/mjpg-streamer.git /usr/src/mjpg-streamer \
36+
&& make -C /usr/src/mjpg-streamer/mjpg-streamer-experimental \
37+
&& make -C /usr/src/mjpg-streamer/mjpg-streamer-experimental install \
38+
&& rm -rf /usr/src/mjpg-streamer \
39+
&& apt-get -q -y -o "DPkg::Options::=--force-confold" -o "DPkg::Options::=--force-confdef" purge \
40+
cmake \
41+
git \
42+
gcc \
43+
g++
44+
45+
# set up the container start point
46+
ENV ENTRYPOINT_SCRIPT="docker-entrypoint.sh"
47+
COPY docker-entrypoint.sh /usr/local/bin
48+
RUN chmod 755 /usr/local/bin/docker-entrypoint.sh
49+
50+
# starting point - self-repair (if ever needed) and launch
51+
ENTRYPOINT ["docker-entrypoint.sh"]
52+
53+
# the streamer invocation
54+
CMD mjpg_streamer \
55+
-i "/usr/local/lib/mjpg-streamer/input_uvc.so -d ${MJPG_STREAMER_INTERNAL_DEVICE} -n -f ${MJPG_STREAMER_FPS} -r ${MJPG_STREAMER_SIZE}" \
56+
-o "/usr/local/lib/mjpg-streamer/output_http.so -p 80 -w /usr/local/share/mjpg-streamer/www ${MJPG_STREAMER_CREDENTIALS}"
57+
58+
# set root's home directory as default (probably unnecessary)
59+
WORKDIR /root
60+
61+
# port
62+
EXPOSE "80"
63+
64+
# set container metadata
65+
LABEL com.github.SensorsIot.IOTstack.Dockerfile.build-args="${DEBIAN_VARIANT}"
66+
LABEL com.github.SensorsIot.IOTstack.Dockerfile.maintainer="Paraphraser <[email protected]>"
67+
68+
# EOF
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#!/bin/bash
2+
3+
set -e
4+
5+
# sensible defaults for supported variables
6+
export MJPG_STREAMER_SIZE=${MJPG_STREAMER_SIZE:-640x480}
7+
export MJPG_STREAMER_FPS=${MJPG_STREAMER_FPS:-5}
8+
export MJPG_STREAMER_INTERNAL_DEVICE=${MJPG_STREAMER_INTERNAL_DEVICE:-/dev/video0}
9+
10+
# form credential string (if the user does not pass a username, the
11+
# username will be the container name - change on each recreate; if
12+
# the user does not pass a password, the password will be a uuid and
13+
# will change on every launch).
14+
MJPG_STREAMER_USERNAME=${MJPG_STREAMER_USERNAME:-$(hostname -s)}
15+
MJPG_STREAMER_PASSWORD=${MJPG_STREAMER_PASSWORD:-$(uuidgen)}
16+
export MJPG_STREAMER_CREDENTIALS="-c ${MJPG_STREAMER_USERNAME}:${MJPG_STREAMER_PASSWORD}"
17+
18+
# are we running as root?
19+
if [ "$(id -u)" = '0' ] ; then
20+
21+
echo "MJPG Streamer launched at $(date)"
22+
23+
# any self-repair code goes here - there is no persistent storage
24+
# at the moment so this is irrelevant.
25+
26+
fi
27+
28+
# away we go
29+
exec "$@"

.templates/mjpg-streamer/service.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
mjpg-streamer:
2+
container_name: mjpg-streamer
3+
build: ./.templates/mjpg-streamer/.
4+
restart: unless-stopped
5+
environment:
6+
- TZ=${TZ:-Etc/UTC}
7+
- MJPG_STREAMER_USERNAME=${MJPG_STREAMER_USERNAME:-}
8+
- MJPG_STREAMER_PASSWORD=${MJPG_STREAMER_PASSWORD:-}
9+
- MJPG_STREAMER_SIZE=${MJPG_STREAMER_SIZE:-}
10+
- MJPG_STREAMER_FPS=${MJPG_STREAMER_FPS:-}
11+
ports:
12+
- "8980:80"
13+
devices:
14+
- "${MJPG_STREAMER_EXTERNAL_DEVICE:-/dev/video0}:/dev/video0"
15+

menu.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ declare -A cont_array=(
6666
[heimdall]="Heimdall Application Dashboard"
6767
[dashmachine]="DashMachine"
6868
[homer]="Homer"
69+
[mjpg-streamer]="MJPG Streamer"
6970
[home_assistant]="Home Assistant Container"
7071
# add yours here
7172
)
@@ -116,6 +117,7 @@ declare -a keylist=(
116117
"heimdall"
117118
"dashmachine"
118119
"homer"
120+
"mjpg-streamer"
119121
"home_assistant"
120122
# add yours here
121123
)

0 commit comments

Comments
 (0)