Skip to content

Commit ff4ca02

Browse files
authored
Custom templates (#42)
* add directory for custom docker compose files * custom: add template for use with portainer * custom: add template to use with multiple printers * custom: add README
1 parent 8b8b6e4 commit ff4ca02

File tree

3 files changed

+234
-0
lines changed

3 files changed

+234
-0
lines changed

custom/README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# Custom Templates
2+
This directory contains custom docker-compose files, that use the Docker Images created by prind.
3+
4+
These files are not part of prind and are geared towards more experienced users. Their aim is to provide a starting point for more complex setups. Documentation from the main README does not apply. Docker and Docker Compose knowledge is strongly recommended as Support for these configurations is limited.
5+
6+
Comments at the beginning of each file describe the usecase and necessary steps to get them to work.
Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
## Usecase: Run multiple Printers on the same Host
2+
##
3+
## Assumptions:
4+
## * I have two printers
5+
## * One is called printer1, the other one printer2
6+
## * printer1 is using serial port /dev/ttyUSB0 and webcam /dev/video0
7+
## * printer2 is using serial port /dev/ttyUSB1 and webcam /dev/video1
8+
##
9+
## About this setup:
10+
## * Moonraker services for each printer are available via their unique port (8101 and 8201 in this example).
11+
## * Webcam services for each printer are available via their unique port (8102 and 8202 in this example)
12+
## * Fluidd is used as Web frontend and is accessible via 80
13+
## * You'll have to add your printers manually to fluidd via their moonraker ports eg. http://dockerhost:8101 and http://dockerhost:8201
14+
##
15+
## Setup:
16+
## 1. Check out prind and enter the repository
17+
## > git clone https://github.com/mkuf/prind/
18+
## > cd prind
19+
## 2. Create config files for each printer and set permissions
20+
## > for i in printer1 printer2; do cp config/printer.cfg config/${i}.cfg; cp config/moonraker.conf config/${i}.moonraker.conf; done
21+
## > chown -R 1000:1000 config
22+
## 3. Copy this file to the root of the repository, overwriting the original docker-compose.yaml
23+
## > cp custom/docker-compose.custom.multiple-printers.yaml docker-compose.yaml
24+
## 4. For each printer create a klipper, moonraker and webcam service as shown below
25+
## 5. Make sure each service has a unique 'command' and is referencing the files created by 2.
26+
## 6. Add your printers config to their corresponding file
27+
## 7. Set the correct klippy_uds_address in the corresponding *.moonraker.conf
28+
## 8. Update the Devices used for klipper and the webcam services
29+
## 9. Start the stack
30+
## > docker compose up -d
31+
32+
## Common Templates
33+
x-klipper-svc: &klipper-svc
34+
image: mkuf/klipper:latest
35+
restart: unless-stopped
36+
volumes:
37+
- ./config:/opt/printer_data/config
38+
- run:/opt/printer_data/run
39+
- gcode:/opt/printer_data/gcodes
40+
- log:/opt/printer_data/logs
41+
42+
x-moonraker-svc: &moonraker-svc
43+
image: mkuf/moonraker:latest
44+
restart: unless-stopped
45+
volumes:
46+
- /dev/null:/opt/klipper/config/null
47+
- /dev/null:/opt/klipper/docs/null
48+
- ./config:/opt/printer_data/config
49+
- run:/opt/printer_data/run
50+
- gcode:/opt/printer_data/gcodes
51+
- log:/opt/printer_data/logs
52+
53+
x-ustreamer-svc: &ustreamer-svc
54+
image: mkuf/ustreamer:latest
55+
restart: unless-stopped
56+
command: --host=0.0.0.0 --port=8080 --slowdown --device=/dev/webcam --resolution=1280x960 --format=MJPEG --desired-fps=30
57+
58+
## Service Definitions
59+
services:
60+
61+
## Printer1
62+
## Access api via port 8101/tcp and webcam via 8102/tcp
63+
printer1-klipper:
64+
<<: *klipper-svc
65+
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
66+
devices:
67+
- /dev/ttyUSB0:/dev/ttyUSB0
68+
printer1-moonraker:
69+
<<: *moonraker-svc
70+
command: -d printer_data -c printer_data/config/printer1.moonraker.conf -l printer_data/logs/printer1.moonraker.log
71+
ports:
72+
- 8101:7125
73+
printer1-webcam:
74+
<<: *ustreamer-svc
75+
devices:
76+
- /dev/video0:/dev/webcam
77+
ports:
78+
- 8102:8080
79+
80+
## Printer2
81+
## Access api via port 8201/tcp and webcam via 8202/tcp
82+
printer2-klipper:
83+
<<: *klipper-svc
84+
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
85+
devices:
86+
- /dev/ttyUSB1:/dev/ttyUSB1
87+
printer2-moonraker:
88+
<<: *moonraker-svc
89+
command: -d printer_data -c printer_data/config/printer2.moonraker.conf -l printer_data/logs/printer2.moonraker.log
90+
ports:
91+
- 8201:7125
92+
printer2-webcam:
93+
<<: *ustreamer-svc
94+
devices:
95+
- /dev/video1:/dev/webcam
96+
ports:
97+
- 8202:8080
98+
99+
## Use Fluidd as Frontend
100+
fluidd:
101+
image: cadriel/fluidd:latest
102+
restart: unless-stopped
103+
ports:
104+
- 80:80
105+
106+
volumes:
107+
run:
108+
gcode:
109+
log:
Lines changed: 119 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
1+
## Usecase: Minimal Configuration to be used with Portainer
2+
## Issue: https://github.com/mkuf/prind/issues/39
3+
##
4+
## Assumptions:
5+
## * I want to manage my printers software via portainer
6+
## * I have shell access to the host running portainer
7+
## * My printers Serial port is /dev/ttyUSB0
8+
## * My printers Webcam device is /dev/video0
9+
##
10+
## About this setup:
11+
## * traefik is used as proxy for the web frontend, moonraker and the webcam service
12+
## * fluidd is used as frontend
13+
##
14+
## Setup:
15+
## 1. Check out prind to a permanent directory
16+
## > git clone https://github.com/mkuf/prind/ /data/prind
17+
## 2. Change permissions for the prind directory
18+
## > chown -R 1000:1000 /data/prind
19+
## 3. Update the Devices used for klipper and the webcam service
20+
## 4. Upload this file to portainer
21+
22+
services:
23+
klipper:
24+
image: mkuf/klipper:latest
25+
restart: unless-stopped
26+
logging:
27+
driver: none
28+
depends_on:
29+
init:
30+
condition: service_completed_successfully
31+
command: -I printer_data/run/klipper.tty -a printer_data/run/klipper.sock printer_data/config/printer.cfg -l printer_data/logs/klippy.log
32+
devices:
33+
- /dev/ttyUSB0:/dev/ttyUSB0
34+
volumes:
35+
- /data/prind/config:/opt/printer_data/config
36+
- run:/opt/printer_data/run
37+
- gcode:/opt/printer_data/gcodes
38+
- log:/opt/printer_data/logs
39+
40+
moonraker:
41+
image: mkuf/moonraker:latest
42+
restart: unless-stopped
43+
pid: host
44+
logging:
45+
driver: none
46+
depends_on:
47+
init:
48+
condition: service_completed_successfully
49+
klipper:
50+
condition: service_started
51+
volumes:
52+
- /dev/null:/opt/klipper/config/null
53+
- /dev/null:/opt/klipper/docs/null
54+
- /run/dbus:/run/dbus
55+
- /run/systemd:/run/systemd
56+
- run:/opt/printer_data/run
57+
- gcode:/opt/printer_data/gcodes
58+
- log:/opt/printer_data/logs
59+
- moonraker-db:/opt/printer_data/database
60+
- /data/prind/config:/opt/printer_data/config
61+
labels:
62+
- "traefik.enable=true"
63+
- "traefik.http.services.moonraker.loadbalancer.server.port=7125"
64+
- "traefik.http.routers.moonraker.rule=PathPrefix(`/websocket`,`/printer`,`/api`,`/access`,`/machine`,`/server`)"
65+
- "traefik.http.routers.moonraker.entrypoints=web"
66+
67+
webcam:
68+
image: mkuf/ustreamer:latest
69+
restart: unless-stopped
70+
command: --host=0.0.0.0 --port=8080 --slowdown --device=/dev/webcam --resolution=1280x960 --format=MJPEG --desired-fps=30
71+
devices:
72+
- /dev/video0:/dev/webcam
73+
labels:
74+
- "traefik.enable=true"
75+
- "traefik.http.services.webcam.loadbalancer.server.port=8080"
76+
- "traefik.http.routers.webcam.rule=PathPrefix(`/webcam`)"
77+
- "traefik.http.routers.webcam.entrypoints=web"
78+
- "traefik.http.middlewares.webcam.stripprefix.prefixes=/webcam"
79+
- "traefik.http.routers.webcam.middlewares=webcam"
80+
81+
fluidd:
82+
image: cadriel/fluidd:latest
83+
restart: unless-stopped
84+
labels:
85+
- "traefik.enable=true"
86+
- "traefik.http.services.fluidd.loadbalancer.server.port=80"
87+
- "traefik.http.routers.fluidd.rule=PathPrefix(`/`)"
88+
- "traefik.http.routers.fluidd.entrypoints=web"
89+
90+
init:
91+
image: busybox:latest
92+
command: chown -R 1000:1000 /prind/config
93+
volumes:
94+
- /data/prind:/prind
95+
96+
traefik:
97+
image: traefik:v2.5
98+
command:
99+
- "--accesslog"
100+
- "--providers.docker=true"
101+
- "--providers.docker.exposedbydefault=false"
102+
- "--entrypoints.web.address=:80"
103+
ports:
104+
- "80:80"
105+
restart: unless-stopped
106+
volumes:
107+
- "/var/run/docker.sock:/var/run/docker.sock:ro"
108+
109+
volumes:
110+
run:
111+
driver_opts:
112+
type: tmpfs
113+
device: tmpfs
114+
gcode:
115+
moonraker-db:
116+
log:
117+
driver_opts:
118+
type: tmpfs
119+
device: tmpfs

0 commit comments

Comments
 (0)