Klipper paths fix. added mjpg-streamer (#56)

* follow recommendation in #20:
add restart: unless-stopped to fluidd

* Update MacOS Compatibility note

Added comment that MacOS Docker cannot currently map TTY devices to containers, preventing using Klipper via host serial devices

* fixed klipper paths
added mjpg stremer

* removed privilaged mode

---------

Co-authored-by: Dieter Schmidt <dima.loschkin@gmail.com>
Co-authored-by: Adam Nock <adamnock@users.noreply.github.com>
Co-authored-by: dimalo <ds_github@schmidt-in.space>
This commit is contained in:
Arun Mallassery
2024-11-03 08:45:57 -05:00
committed by GitHub
parent 059e47447d
commit 90408eef02
7 changed files with 72 additions and 25 deletions

View File

@@ -64,6 +64,7 @@ __Klipper with Moonraker shipped with Fluidd and/or Mainsail__
___Prerequisites:___
- _Your klipper host machine runs Linux or MacOS (Windows was not tested yet)_
- (MacOS) Currently it is not possible to expose serial devices to a container in MacOS Docker. This is a known issue with Docker (https://github.com/docker/for-mac/issues/900)
- _You have docker and docker-compose installed on your machine_
- _You have flashed your printer with the appropriate .bin_
- _You have your printer connected to your machine and you know it's serial mount point (e.g. /dev/ttyACM0 or /dev/ttyUSB0)_

View File

@@ -16,16 +16,17 @@ services:
ports:
- 7125:7125
restart: unless-stopped
volumes:
- gcode_files:/home/klippy/gcode_files
volumes:
- gcode_files:/home/klippy/printer_data/gcodes
# be aware to create your own branch if you mount the config folder as it will be updated on the main branch
# that way you can merge upstream changes to your customized configs
- ./config:/home/klippy/.config
- ./config:/home/klippy/printer_data/config
- moonraker_data:/home/klippy/.moonraker_database
# - <<your_config_path>>:/home/klippy/.config
# - ./printer.cfg:/home/klippy/.config/printer.cfg
# mount serial device - take care to grant sufficient permissions to the device: <host_dev>:<container_dev>
# put <container_dev> into your printer.cfg
devices:
- /dev/ttyUSB0:/dev/ttyUSB0
@@ -65,6 +66,7 @@ services:
# build:
# dockerfile: Dockerfile
# context: frontend
restart: unless-stopped
container_name: fluidd
ports:
- 8010:80

View File

@@ -12,8 +12,8 @@ FROM nginx:alpine as image
ENV KLIPPER_HOST klipper
ENV KLIPPER_API_PORT 7125
ENV JPEG_STREAM_HOST localhost
ENV JPEG_STREAM_PORT 8888
ENV JPEG_STREAM_HOST klipper
ENV JPEG_STREAM_PORT 8080
ADD --chown=101:101 common_vars.conf /etc/nginx/conf.d/common_vars.conf
COPY --chown=101:101 upstreams.conf.template /etc/nginx/templates/upstreams.conf.template

View File

@@ -83,7 +83,7 @@ server {
proxy_set_header X-Scheme $scheme;
}
location /webcam/ {
location /webcam {
proxy_pass http://mjpgstreamer/;
}
}

View File

@@ -15,21 +15,27 @@ ENV PYTHONUNBUFFERED=1
RUN useradd -d ${HOME} -ms /bin/bash ${USER}
RUN apt-get update && \
apt-get install -y \
locales \
git \
sudo \
wget \
curl \
gzip \
tar \
libffi-dev \
build-essential \
libncurses-dev \
libusb-dev \
gpiod \
libopenjp2-7 \
liblmdb-dev \
libsodium-dev
locales \
git \
sudo \
wget \
curl \
gzip \
tar \
libffi-dev \
build-essential \
libncurses-dev \
libusb-dev \
gpiod \
libopenjp2-7 \
liblmdb-dev \
libsodium-dev \
imagemagick \
libv4l-dev \
libjpeg-dev \
libjpeg62-turbo-dev \
cmake \
unzip
RUN sed -i -e 's/# en_GB.UTF-8 UTF-8/en_GB.UTF-8 UTF-8/' /etc/locale.gen
RUN locale-gen
@@ -68,12 +74,18 @@ RUN ${MOONRAKER_VENV_DIR}/bin/pip install wheel gpiod && \
${MOONRAKER_VENV_DIR}/bin/pip install --no-cache-dir -f ${WHEELS} -r scripts/moonraker-requirements.txt
RUN ${MOONRAKER_VENV_DIR}/bin/python -m compileall moonraker
#webcam
WORKDIR ${HOME}
RUN git clone https://github.com/jacksonliam/mjpg-streamer.git
RUN cd mjpg-streamer/mjpg-streamer-experimental && make
RUN mv mjpg-streamer/mjpg-streamer-experimental/* mjpg-streamer && rm -rf mjpg-streamer/mjpg-streamer-experimental
FROM python:3.11-slim as image
ARG DEBIAN_FRONTEND=noninteractive
RUN apt-get update && \
apt-get install -y \
apt-get install -y \
curl \
git \
gpiod \
@@ -88,7 +100,8 @@ RUN apt-get update && \
locales \
rsync \
supervisor \
zlib1g-dev && \
libv4l-dev \
zlib1g-dev && \
sed -i -e 's/# en_GB.UTF-8 UTF-8/en_GB.UTF-8 UTF-8/' /etc/locale.gen && \
locale-gen && \
# Clean up
@@ -119,6 +132,7 @@ RUN useradd --user-group --no-log-init --shell /bin/false -m -d ${HOME} ${USER}
usermod -a -G ${DEVICE_GROUP} ${USER} && \
usermod -a -G tty ${USER} && \
usermod -a -G dialout ${USER} && \
usermod -a -G video ${USER} && \
mkdir -p /var/log/supervisor ${HOME}/.cache/pip && \
touch /var/log/supervisor/supervisord.log && \
chown -R root:${USER} /var/log/supervisor && \
@@ -136,8 +150,9 @@ RUN pip install --no-index -f ${WHEELS} supervisord-dependent-startup gpiod nump
USER ${USER}
WORKDIR ${HOME}
RUN mkdir -p ${DATA_DIR}/gcodes ${CONFIG_DIR} ${HOME}/.moonraker ${HOME}/.klipper_repo_backup ${HOME}/.moonraker_repo_backup
RUN mkdir -p ${DATA_DIR}/gcodes ${CONFIG_DIR} ${HOME}/.klipper_repo_backup ${HOME}/.moonraker_repo_backup ${HOME}/.moonraker_database
VOLUME ${DATA_DIR}
VOLUME ${HOME}/.moonraker_database
EXPOSE 7125
@@ -154,4 +169,11 @@ COPY --chown=${USER}:${USER} klipper/run_in_venv /usr/local/bin/run_in_venv
COPY klipper/supervisord.conf /etc/supervisor/supervisord.conf
COPY klipper/*.ini /etc/supervisor/conf.d/
CMD ["supervisord", "-c", "/etc/supervisor/supervisord.conf"]
COPY --chown=${USER}:${USER} --chmod=700 mjpgstreamer/index.html ${HOME}/www-mjpgstreamer/index.html
COPY --chown=${USER}:${USER} --from=builder ${HOME}/mjpg-streamer ${HOME}/mjpg-streamer
EXPOSE 8080
CMD ["supervisord", "-c", "/etc/supervisor/supervisord.conf

12
klipper/mjpg_streamer.ini Normal file
View File

@@ -0,0 +1,12 @@
[program:mjpg-streamer]
user=klippy
command=/home/klippy/mjpg-streamer/mjpg_streamer -o "output_http.so -w ./www-mjpgstreamer -n" -i "input_uvc.so -d /dev/video0 -"
environment=LD_LIBRARY_PATH=/home/klippy/mjpg-streamer
stdout_logfile=/dev/fd/1
stdout_logfile_maxbytes = 0
stderr_logfile=/dev/fd/2
stderr_logfile_maxbytes = 0
autorestart=true
autostart=false
dependent_startup=true

View File

@@ -0,0 +1,10 @@
<html>
<head><title>mjpg_streamer test page</title></head>
<body>
<h1>Snapshot</h1>
<p>Refresh the page to refresh the snapshot</p>
<img src="./?action=snapshot" alt="Snapshot">
<h1>Stream</h1>
<img src="./?action=stream" alt="Stream">
</body>
</html>