Files
prind/custom/docker-compose.custom.multiple-printers.yaml
2024-02-08 21:41:50 +01:00

149 lines
4.5 KiB
YAML

## Usecase: Run multiple Printers on the same Host
##
## Assumptions:
## * I have two printers
## * One is called printer1, the other one printer2
## * printer1 is using serial port /dev/ttyUSB0 and webcam /dev/video0
## * printer2 is using serial port /dev/ttyUSB1 and webcam /dev/video1
##
## About this setup:
## * Moonraker services for each printer are available via their unique port (8101 and 8201 in this example).
## * Webcam services for each printer are available via their unique port (8102 and 8202 in this example)
## * Fluidd is used as Web frontend and is accessible via 80
## * You'll have to add your printers manually to fluidd via their moonraker ports eg. http://dockerhost:8101 and http://dockerhost:8201
##
## Setup:
## 1. Check out prind and enter the repository
## > git clone https://github.com/mkuf/prind/
## > cd prind
## 2. Create config files for each printer and set permissions
## > for i in printer1 printer2; do cp config/printer.cfg config/${i}.cfg; cp config/moonraker.conf config/${i}.moonraker.conf; done
## > chown -R 1000:1000 config
## 3. Copy this file to the root of the repository, overwriting the original docker-compose.yaml
## > cp custom/docker-compose.custom.multiple-printers.yaml docker-compose.yaml
## 4. For each printer create a klipper, moonraker and webcam service as shown below
## 5. Make sure each service has a unique 'command' and is referencing the files created by 2.
## 6. Add your printers config to their corresponding file
## 7. Set the correct klippy_uds_address in the corresponding *.moonraker.conf
## 8. Update the Devices used for the webcam services
## 9. Start the stack
## > docker compose up -d
## Common Templates
x-klipper-svc: &klipper-svc
image: mkuf/klipper:latest
restart: unless-stopped
privileged: true
volumes:
- /dev:/dev
- ./config:/opt/printer_data/config
- run:/opt/printer_data/run
- gcode:/opt/printer_data/gcodes
- log:/opt/printer_data/logs
x-moonraker-svc: &moonraker-svc
image: mkuf/moonraker:latest
restart: unless-stopped
volumes:
- /dev/null:/opt/klipper/config/null
- /dev/null:/opt/klipper/docs/null
- ./config:/opt/printer_data/config
- run:/opt/printer_data/run
- gcode:/opt/printer_data/gcodes
- log:/opt/printer_data/logs
x-ustreamer-svc: &ustreamer-svc
image: mkuf/ustreamer:latest
restart: unless-stopped
command: >
--host=0.0.0.0
--port=8080
--slowdown
--device=/dev/webcam
--resolution=1280x960
--format=MJPEG
--desired-fps=30
## Service Definitions
services:
## Printer1
## Access api via port 8101/tcp and webcam via 8102/tcp
printer1-klipper:
<<: *klipper-svc
command: >
-I printer_data/run/printer1.klipper.tty
-a printer_data/run/printer1.klipper.sock
printer_data/config/printer1.cfg
-l printer_data/logs/printer1.klippy.log
labels:
org.prind.service: klipper
org.prind.printer: printer1
printer1-moonraker:
<<: *moonraker-svc
command: >
-d printer_data
-c printer_data/config/printer1.moonraker.conf
-l printer_data/logs/printer1.moonraker.log
ports:
- 8101:7125
labels:
org.prind.service: moonraker
org.prind.printer: printer1
printer1-webcam:
<<: *ustreamer-svc
devices:
- /dev/video0:/dev/webcam
ports:
- 8102:8080
labels:
org.prind.service: webcam
org.prind.printer: printer1
## Printer2
## Access api via port 8201/tcp and webcam via 8202/tcp
printer2-klipper:
<<: *klipper-svc
command: >
-I printer_data/run/printer2.klipper.tty
-a printer_data/run/printer2.klipper.sock
printer_data/config/printer2.cfg
-l printer_data/logs/printer2.klippy.log
labels:
org.prind.service: klipper
org.prind.printer: printer2
printer2-moonraker:
<<: *moonraker-svc
command: >
-d printer_data
-c printer_data/config/printer2.moonraker.conf
-l printer_data/logs/printer2.moonraker.log
ports:
- 8201:7125
labels:
org.prind.service: moonraker
org.prind.printer: printer2
printer2-webcam:
<<: *ustreamer-svc
devices:
- /dev/video1:/dev/webcam
ports:
- 8202:8080
labels:
org.prind.service: webcam
org.prind.printer: printer2
## Use Fluidd as Frontend
fluidd:
image: ghcr.io/fluidd-core/fluidd:latest
restart: unless-stopped
ports:
- 80:80
labels:
org.prind.service: fluidd
volumes:
run:
gcode:
log: