klipper works in docker

This commit is contained in:
Markus Küffner
2021-10-16 18:42:56 +02:00
parent 7e75a3610d
commit e11d757ee7
4 changed files with 60 additions and 0 deletions

21
docker-compose.yaml Normal file
View File

@@ -0,0 +1,21 @@
version: '3.4'
services:
klipper:
image: klipper:latest
build:
args:
VERSION: 319c36df52eb016667d13ab006cae3752d0212e7
dockerfile: klipper.Dockerfile
context: .
target: klippy
container_name: klipper
restart: unless-stopped
volumes:
- ./config:/opt/cfg
- run:/opt/run
devices:
- /dev/ttymxc3:/dev/ttymxc3
volumes:
run:

39
klipper.Dockerfile Normal file
View File

@@ -0,0 +1,39 @@
FROM python:2 as base
ARG REPO=https://github.com/Klipper3d/klipper
ARG VERSION=master
WORKDIR /opt
## Download Klipper
RUN git clone ${REPO} klipper \
&& cd klipper \
&& git checkout ${VERSION}
## Install klipper requirements
RUN pip install -r klipper/scripts/klippy-requirements.txt
## Compile Python code
RUN python klipper/klippy/chelper/__init__.py
## Create directories
RUN mkdir run cfg
## User & Permissions
RUN groupadd klipper --gid 1000 \
&& useradd klipper --uid 1000 --gid klipper \
&& usermod klipper --append --groups dialout \
&& chown -R klipper:klipper klipper run cfg
## --- Targets ---
## Start Klippy
FROM base as klippy
USER klipper
ENTRYPOINT ["python"]
CMD ["klipper/klippy/klippy.py", "-I", "run/klipper.tty", "-a", "run/klipper.sock", "cfg/printer.cfg"]
## For building MCU Code
FROM base as build
RUN apt update \
&& apt install build-essential libncurses-dev libnewlib-arm-none-eabi gcc-arm-none-eabi binutils-arm-none-eabi