feat: add webcamd service

Signed-off-by: Dominik Willner th33xitus@gmail.com
This commit is contained in:
th33xitus 2022-06-17 21:09:14 +02:00
parent 56e6c0169d
commit 909d814f85
4 changed files with 36 additions and 5 deletions

View File

@ -3,7 +3,7 @@ FROM python:3.10-slim-bullseye AS builder
RUN apt-get update && apt-get install -y \ RUN apt-get update && apt-get install -y \
--no-install-recommends \ --no-install-recommends \
--no-install-suggests \ --no-install-suggests \
### non specific packages ### non-specific packages
git \ git \
swig \ swig \
virtualenv \ virtualenv \
@ -50,13 +50,25 @@ RUN git clone https://github.com/Arksine/moonraker && \
virtualenv -p python3 /build/moonraker-env && \ virtualenv -p python3 /build/moonraker-env && \
/build/moonraker-env/bin/pip install -r /build/moonraker/scripts/moonraker-requirements.txt /build/moonraker-env/bin/pip install -r /build/moonraker/scripts/moonraker-requirements.txt
#### MJPG-Streamer
RUN git clone --depth 1 https://github.com/jacksonliam/mjpg-streamer \
&& cd mjpg-streamer \
&& cd mjpg-streamer-experimental \
&& mkdir _build \
&& cd _build \
&& cmake -DPLUGIN_INPUT_HTTP=OFF -DPLUGIN_INPUT_UVC=OFF -DPLUGIN_OUTPUT_FILE=OFF -DPLUGIN_OUTPUT_RTSP=OFF -DPLUGIN_OUTPUT_UDP=OFF .. \
&& cd .. \
&& make \
&& rm -rf _build
COPY mjpg_streamer_images ./mjpg-streamer/mjpg-streamer-experimental/images
## --------- This is the runner image ## --------- This is the runner image
FROM python:3.10-slim-bullseye AS runner FROM python:3.10-slim-bullseye AS runner
RUN apt-get update && apt-get install -y \ RUN apt-get update && apt-get install -y \
--no-install-recommends \ --no-install-recommends \
--no-install-suggests \ --no-install-suggests \
### non specific packages ### non-specific packages
git \ git \
build-essential \ build-essential \
supervisor \ supervisor \
@ -98,6 +110,7 @@ COPY --from=builder --chown=printer:printer /build/moonraker ./moonraker
COPY --from=builder --chown=printer:printer /build/moonraker-env ./moonraker-env COPY --from=builder --chown=printer:printer /build/moonraker-env ./moonraker-env
COPY --from=builder --chown=printer:printer /build/simulavr ./simulavr COPY --from=builder --chown=printer:printer /build/simulavr ./simulavr
COPY --from=builder --chown=printer:printer /build/simulavr.elf ./simulavr.elf COPY --from=builder --chown=printer:printer /build/simulavr.elf ./simulavr.elf
COPY --from=builder --chown=printer:printer /build/mjpg-streamer/mjpg-streamer-experimental ./mjpg-streamer
COPY ./example-configs/ ./example-configs/ COPY ./example-configs/ ./example-configs/

View File

@ -6,14 +6,21 @@
### **Run a simulated Klipper 3D-Printer in a Docker container.** ### **Run a simulated Klipper 3D-Printer in a Docker container.**
--- ---
### Instructions: ### Setup Instructions:
1. Clone this repository 1. Clone this repository
2. Open a terminal in the cloned folder 2. Open a terminal in the cloned folder
3. Run `docker-compose up -d` to build the docker image and start the container afterwards in detached mode 3. Run `docker-compose up -d` to build the docker image and start the container afterwards in detached mode
--- ---
Common docker commands: ### Configure a Dummy-Webcam:
1) To configure a dummy-webcam, use the following URL for the stream: \
`http://localhost:8110/?action=stream`
2) In Mainsail pick either `MJPEG-Streamer` or `UV4L-MJPEG` as service.
---
### Common Docker commands:
* Get all container IDs: `docker ps -a` * Get all container IDs: `docker ps -a`
* Get only the ID of running containers: `docker ps` * Get only the ID of running containers: `docker ps`
* Access a containers shell: `docker exec -it <CONTAINER ID> bash` * Access a containers shell: `docker exec -it <CONTAINER ID> bash`
@ -21,4 +28,4 @@ Common docker commands:
* Rebuild image, recreate and start container : `docker-compose up -d --build` * Rebuild image, recreate and start container : `docker-compose up -d --build`
--- ---
Current image size: ~685 MB Current image size: 733.73 MB

View File

@ -43,4 +43,14 @@ process_name=moonraker
directory=/home/printer directory=/home/printer
autostart=true autostart=true
autorestart=true autorestart=true
redirect_stderr=true
[program:webcamd]
command=/home/printer/mjpg-streamer/mjpg_streamer -i "input_file.so -e -d 0.8 -f /home/printer/mjpg-streamer/images" -o "output_http.so -w /home/printer/mjpg-streamer/www"
user=printer
process_name=webcamd
directory=/home/printer
environment=LD_LIBRARY_PATH="/home/printer/mjpg-streamer"
autostart=true
autorestart=true
redirect_stderr=true redirect_stderr=true

View File

@ -12,6 +12,7 @@ services:
- ./printer_storage/klipper_logs:/home/printer/klipper_logs:delegated - ./printer_storage/klipper_logs:/home/printer/klipper_logs:delegated
ports: ports:
- "7125:7125" - "7125:7125"
- "8110:8080"
networks: networks:
- dev_net - dev_net
networks: networks: