feat: add dummy webcam streamer (#9)
Signed-off-by: Dominik Willner th33xitus@gmail.com
51
Dockerfile
|
|
@ -3,7 +3,7 @@ FROM python:3.10-slim-bullseye AS builder
|
|||
RUN apt-get update && apt-get install -y \
|
||||
--no-install-recommends \
|
||||
--no-install-suggests \
|
||||
### non specific packages
|
||||
### non-specific packages
|
||||
git \
|
||||
swig \
|
||||
virtualenv \
|
||||
|
|
@ -26,29 +26,41 @@ WORKDIR /build
|
|||
|
||||
### Prepare our applications
|
||||
#### Klipper
|
||||
RUN git clone https://github.com/klipper3d/klipper && \
|
||||
virtualenv -p python3 /build/klippy-env && \
|
||||
/build/klippy-env/bin/pip install -r /build/klipper/scripts/klippy-requirements.txt
|
||||
RUN git clone https://github.com/klipper3d/klipper \
|
||||
&& virtualenv -p python3 /build/klippy-env \
|
||||
&& /build/klippy-env/bin/pip install -r /build/klipper/scripts/klippy-requirements.txt
|
||||
|
||||
#### Simulavr
|
||||
COPY config/simulavr.config /usr/src
|
||||
RUN git clone -b master git://git.savannah.nongnu.org/simulavr.git && \
|
||||
RUN git clone -b master git://git.savannah.nongnu.org/simulavr.git \
|
||||
# Build the firmware
|
||||
cd klipper && \
|
||||
cp /usr/src/simulavr.config .config && \
|
||||
make PYTHON=python3 && \
|
||||
cp out/klipper.elf /build/simulavr.elf && \
|
||||
rm -f .config && make PYTHON=python3 clean && \
|
||||
&& cd klipper \
|
||||
&& cp /usr/src/simulavr.config .config \
|
||||
&& make PYTHON=python3 \
|
||||
&& cp out/klipper.elf /build/simulavr.elf \
|
||||
&& rm -f .config \
|
||||
&& make PYTHON=python3 clean \
|
||||
# Build simulavr
|
||||
cd ../simulavr && \
|
||||
make python && \
|
||||
make build && \
|
||||
make clean
|
||||
&& cd ../simulavr \
|
||||
&& make python \
|
||||
&& make build \
|
||||
&& make clean
|
||||
|
||||
#### Moonraker
|
||||
RUN git clone https://github.com/Arksine/moonraker && \
|
||||
virtualenv -p python3 /build/moonraker-env && \
|
||||
/build/moonraker-env/bin/pip install -r /build/moonraker/scripts/moonraker-requirements.txt
|
||||
RUN git clone https://github.com/Arksine/moonraker \
|
||||
&& virtualenv -p python3 /build/moonraker-env \
|
||||
&& /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
|
||||
|
||||
## --------- This is the runner image
|
||||
|
||||
|
|
@ -56,7 +68,7 @@ FROM python:3.10-slim-bullseye AS runner
|
|||
RUN apt-get update && apt-get install -y \
|
||||
--no-install-recommends \
|
||||
--no-install-suggests \
|
||||
### non specific packages
|
||||
### non-specific packages
|
||||
git \
|
||||
build-essential \
|
||||
supervisor \
|
||||
|
|
@ -98,7 +110,10 @@ 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/simulavr ./simulavr
|
||||
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 and dummy streamer images
|
||||
COPY ./example-configs/ ./example-configs/
|
||||
COPY ./mjpg_streamer_images/ ./mjpg_streamer_images/
|
||||
|
||||
ENTRYPOINT ["/bin/start"]
|
||||
|
|
|
|||
15
README.md
|
|
@ -6,14 +6,21 @@
|
|||
### **Run a simulated Klipper 3D-Printer in a Docker container.**
|
||||
---
|
||||
|
||||
### Instructions:
|
||||
### Setup Instructions:
|
||||
1. Clone this repository
|
||||
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 in detached mode
|
||||
|
||||
---
|
||||
|
||||
Common docker commands:
|
||||
### Configure a Dummy-Webcam:
|
||||
To configure a dummy-webcam, use the following URLs:
|
||||
* Stream: `http://localhost:8110/?action=stream`
|
||||
* Snapshot: `http://localhost:8110/?action=snapshot`
|
||||
|
||||
---
|
||||
|
||||
### Common Docker commands:
|
||||
* Get all container IDs: `docker ps -a`
|
||||
* Get only the ID of running containers: `docker ps`
|
||||
* 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`
|
||||
|
||||
---
|
||||
Current image size: ~685 MB
|
||||
Current image size: 734.45 MB
|
||||
|
|
|
|||
|
|
@ -44,3 +44,13 @@ directory=/home/printer
|
|||
autostart=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/webcam_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
|
||||
|
|
@ -10,8 +10,10 @@ services:
|
|||
- ./printer_storage/gcode_files:/home/printer/gcode_files:delegated
|
||||
- ./printer_storage/klipper_config:/home/printer/klipper_config:delegated
|
||||
- ./printer_storage/klipper_logs:/home/printer/klipper_logs:delegated
|
||||
- ./printer_storage/webcam_images:/home/printer/webcam_images:delegated
|
||||
ports:
|
||||
- "7125:7125"
|
||||
- "8110:8080"
|
||||
networks:
|
||||
- dev_net
|
||||
networks:
|
||||
|
|
|
|||
|
After Width: | Height: | Size: 77 KiB |
|
After Width: | Height: | Size: 74 KiB |
|
After Width: | Height: | Size: 87 KiB |
|
After Width: | Height: | Size: 86 KiB |
|
After Width: | Height: | Size: 81 KiB |
|
After Width: | Height: | Size: 85 KiB |
|
After Width: | Height: | Size: 80 KiB |
|
After Width: | Height: | Size: 70 KiB |
|
After Width: | Height: | Size: 82 KiB |
|
After Width: | Height: | Size: 79 KiB |
|
|
@ -1,23 +1,78 @@
|
|||
#!/bin/bash
|
||||
[ ! -e /bin/systemctl ] && sudo -S ln -s /bin/true /bin/systemctl
|
||||
#!/usr/bin/env bash
|
||||
|
||||
cd ~ || exit 1
|
||||
[ ! -d ~/klipper_logs ] && mkdir klipper_logs
|
||||
[ ! -d ~/gcode_files ] && mkdir gcode_files
|
||||
[ ! -d ~/.moonraker_database ] && mkdir .moonraker_database
|
||||
#=======================================================================#
|
||||
# Copyright (C) 2022 mainsail-crew <https://github.com/mainsail-crew> #
|
||||
# Author: Dominik Willner <th33xitus@gmail.com> #
|
||||
# #
|
||||
# This file is part of virtual-klipper-printer #
|
||||
# https://github.com/mainsail-crew/virtual-klipper-printer #
|
||||
# #
|
||||
# This file may be distributed under the terms of the GNU GPLv3 license #
|
||||
#=======================================================================#
|
||||
|
||||
if [ ! -d ~/klipper_config ] || find ~/klipper_config -type d -empty; then
|
||||
cd ~/example-configs || exit 1
|
||||
cp -r ./* ~/klipper_config
|
||||
fi
|
||||
set -e
|
||||
|
||||
sudo chown -R printer:printer ~/klipper_config
|
||||
sudo chown -R printer:printer ~/klipper_logs
|
||||
sudo chown -R printer:printer ~/gcode_files
|
||||
sudo chown -R printer:printer ~/.moonraker_database
|
||||
REQUIRED_FOLDERS=(
|
||||
"${HOME}/klipper_config"
|
||||
"${HOME}/klipper_logs"
|
||||
"${HOME}/gcode_files"
|
||||
"${HOME}/webcam_images"
|
||||
"${HOME}/.moonraker_database"
|
||||
)
|
||||
|
||||
function status_msg() {
|
||||
echo "###[$(date +%T)]: ${1}"
|
||||
}
|
||||
|
||||
######
|
||||
# Test for correct ownership of all required folders
|
||||
###
|
||||
function check_folder_perms() {
|
||||
status_msg "Check folders permissions ..."
|
||||
for folder in "${REQUIRED_FOLDERS[@]}"; do
|
||||
if [[ $(stat -c "%U" "${folder}") != "printer" ]]; then
|
||||
status_msg "chown for user: 'printer' on folder: ${folder}"
|
||||
sudo chown printer:printer "${folder}"
|
||||
fi
|
||||
done
|
||||
status_msg "OK!"
|
||||
}
|
||||
|
||||
######
|
||||
# Copy example configs if ~/klipper_config is empty
|
||||
###
|
||||
function copy_example_configs() {
|
||||
if [[ ! "$(ls -A "${HOME}/klipper_config")" ]]; then
|
||||
status_msg "Directory ${HOME}/klipper_config is empty!"
|
||||
status_msg "Copy example configs ..."
|
||||
cp -R ~/example-configs/* ~/klipper_config
|
||||
status_msg "OK!"
|
||||
fi
|
||||
}
|
||||
|
||||
######
|
||||
# Copy dummy images if ~/webcam_images is empty
|
||||
###
|
||||
function copy_dummy_images() {
|
||||
if [[ ! "$(ls -A "${HOME}/webcam_images")" ]]; then
|
||||
status_msg "Directory ${HOME}/webcam_images is empty!"
|
||||
status_msg "Copy dummy images ..."
|
||||
cp -R ~/mjpg_streamer_images/*.jpg ~/webcam_images
|
||||
status_msg "OK!"
|
||||
fi
|
||||
}
|
||||
|
||||
#===================================================#
|
||||
#===================================================#
|
||||
|
||||
[[ ! -e /bin/systemctl ]] && sudo -S ln -s /bin/true /bin/systemctl
|
||||
|
||||
check_folder_perms
|
||||
copy_example_configs
|
||||
copy_dummy_images
|
||||
|
||||
sudo -S rm /bin/systemctl
|
||||
sudo -S ln -s /bin/service_control /bin/systemctl
|
||||
|
||||
cd ~ && echo "Everything is ready ... Starting ..."
|
||||
cd ~ && status_msg "Everything is ready! Starting ..."
|
||||
/usr/bin/supervisord
|
||||