Files
prind/docker/moonraker/README.md

111 lines
3.9 KiB
Markdown
Raw Normal View History

2023-12-07 17:42:13 +01:00
This Image is built and used by [prind](.).
# Moonraker packaged in Docker
## What is Moonraker?
>Moonraker is a Python 3 based web server that exposes APIs with which client applications may use to interact with the 3D printing firmware Klipper. Communcation between the Klippy host and Moonraker is done over a Unix Domain Socket. Tornado is used to provide Moonraker's server functionality.
_via https://moonraker.readthedocs.io/en/latest/_
## Usage
Moonraker requires Klipper to operate. See the Images' [README.md](../klipper/README.md) on how to run the Klipper Image.
Both Containers need to share their `run` Volume in order to be able to communicate via klippers unix socket. Configure Moonraker to use `/opt/printer_data/run/klipper.sock` as klippys uds address.
Create `moonraker.conf` and `printer.cfg` as well as the directories `run` and `gcode`, then run the containers.
#### Run
```bash
docker run \
--privileged \
-v /dev:/dev \
-v $(pwd)/run:/opt/printer_data/run \
-v $(pwd)/gcode:/opt/printer_data/gcodes \
-v $(pwd)/printer.cfg:/opt/printer_data/config/printer.cfg \
mkuf/klipper:latest
docker run \
-v $(pwd)/run:/opt/printer_data/run \
-v $(pwd)/gcode:/opt/printer_data/gcodes \
-v $(pwd)/moonraker.conf:/opt/printer_data/config/moonraker.conf \
-p 7125:7125 \
mkuf/moonraker:latest
```
#### Compose
```yaml
services:
klipper:
image: mkuf/klipper:latest
privileged: true
volumes:
- /dev:/dev
- ./printer.cfg:/opt/printer_data/conf/printer.cfg
- ./run:/opt/printer_data/run
- ./gcode:/opt/printer_data/gcodes
moonraker:
image: mkuf/moonraker:latest
ports:
- "7125:7125"
volumes:
- ./moonraker.conf:/opt/printer_data/conf/moonraker.conf
- ./run:/opt/printer_data/run
- ./gcode:/opt/printer_data/gcodes
```
## Defaults
|Entity|Description|
|---|---|
|User| `moonraker (1000:1000)` |
|Workdir|`/opt`|
|Entrypoint|`/opt/venv/bin/python moonraker/moonraker/moonraker.py`|
|Cmd|`-d /opt/printer_data/`|
## Ports
|Port|Description|
|---|---|
|`7125/tcp`|Default Webapi Port|
## Volumes
|Volume|Description|
|---|---|
|`/opt/printer_data/run`| Default Location for runtime Files generated by Klipper. Used to access `klipper.sock`, the unix socket that is used for communation with klipper |
|`/opt/printer_data/config`|Config directory to host `moonraker.conf`|
|`/opt/printer_data/gcodes`|Stores uploaded GCODE Files|
|`/opt/printer_data/logs`|Log directory for Klipper and Moonraker|
## Tags
|Tag|Description|Static|
|---|---|---|
|`latest`|Refers to the most recent runtime Image.|May point to a new build within 24h, depending on code changes in the upstream repository.|
|`<git description>` <br>eg: `v0.8.0-314-gaadff0d`|Refers to a specific [git description](https://git-scm.com/docs/git-describe#_examples) in the upstream repository. eg: [arksine/moonraker:v0.8.0-314-gaadff0d](https://github.com/Arksine/moonraker/commit/aadff0d54e98a536c13d4aca295e3250e06b67b8)|Yes|
## Targets
|Target|Description|Pushed|
|---|---|---|
|`build`|Pull Upstream Codebase and build python venv|No|
|`run`|Default runtime Image|Yes|
## Healthcheck
`/opt/health.sh` gets executed every 5s inside the container.
2024-11-24 11:45:15 +01:00
> Be aware that enabling health checks in docker may increase CPU usage drastically.
> In tests, cpu usage of the container was doubled when executing the healtch check every 30s and increased sixfold when executing every 5s.
> This may lead to resource shortages on low powered host and unwanted behaviour
The script does the following:
* queries the `/server/info` endpoint of moonraker
* Performs the following checks
* Number of failed moonraker_components = 0
* klippy_connected is `true`
* klippy_state is `ready`
2024-11-24 11:45:15 +01:00
* If one of the above requirements is not met, the script exits with a failure state to indicate the container is unhealthy
Compose example:
```yaml
services:
moonraker:
healthcheck:
test: ["bash", "/opt/health.sh"]
interval: 30s
```