-
Notifications
You must be signed in to change notification settings - Fork 77
/
Dockerfile
86 lines (69 loc) · 2.41 KB
/
Dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
## Get Code and Build venv
FROM python:2 as build
ARG REPO=https://github.com/Klipper3d/klipper
ARG VERSION=master
WORKDIR /opt
RUN git clone ${REPO} klipper \
&& cd klipper \
&& git checkout ${VERSION}
RUN virtualenv -p python2 venv \
&& venv/bin/pip install -r klipper/scripts/klippy-requirements.txt \
&& venv/bin/pip install numpy \
&& venv/bin/python -m compileall klipper/klippy \
&& venv/bin/python klipper/klippy/chelper/__init__.py
## Runtime Image
FROM python:2-slim as run
WORKDIR /opt
COPY --from=build /opt/klipper ./klipper
COPY --from=build /opt/venv ./venv
RUN mkdir -p printer_data/run printer_data/gcodes printer_data/logs printer_data/config
RUN groupadd klipper --gid 1000 \
&& useradd klipper --uid 1000 --gid klipper \
&& usermod klipper --append --groups dialout \
&& chown -R klipper:klipper /opt/*
USER klipper
VOLUME ["/opt/printer_data/run", "/opt/printer_data/gcodes", "/opt/printer_data/logs", "/opt/printer_data/config"]
ENTRYPOINT ["/opt/venv/bin/python", "klipper/klippy/klippy.py"]
CMD ["-I", "printer_data/run/klipper.tty", "-a", "printer_data/run/klipper.sock", "printer_data/config/printer.cfg"]
## For building MCU Code
FROM ubuntu:18.04 as mcu
WORKDIR /opt
COPY --from=build /opt/klipper ./klipper
COPY --from=build /opt/venv ./venv
ARG DEBIAN_FRONTEND=noninteractive
RUN apt update \
&& apt install -y \
virtualenv python-dev libffi-dev build-essential \
libncurses-dev \
libusb-dev \
avrdude gcc-avr binutils-avr avr-libc \
stm32flash libnewlib-arm-none-eabi \
gcc-arm-none-eabi binutils-arm-none-eabi libusb-1.0 \
python3-numpy python3-matplotlib \
&& apt clean
## Build klipper.elf for Simulavr and Simulavr itself
FROM mcu as build-simulavr
RUN apt update \
&& apt install -y \
git cmake swig \
python3-dev \
&& apt clean
WORKDIR /opt/klipper
COPY config.simulavr .config
RUN make
WORKDIR /opt
RUN git clone git://git.savannah.nongnu.org/simulavr.git \
&& cd simulavr \
&& git checkout release-1.1.0 \
&& make python \
&& make build
RUN mkdir run
RUN groupadd simulavr --gid 1000 \
&& useradd simulavr --uid 1000 --gid simulavr \
&& usermod simulavr --append --groups dialout \
&& chown -R simulavr:simulavr /opt/*
USER simulavr
ENV PYTHONPATH=/opt/simulavr/build/pysimulavr/
VOLUME ["/opt/printer_data/run"]
ENTRYPOINT ["klipper/scripts/avrsim.py"]
CMD ["-p", "/opt/printer_data/run/simulavr.tty", "/opt/klipper/out/klipper.elf"]