-
Notifications
You must be signed in to change notification settings - Fork 23
/
Dockerfile
73 lines (61 loc) · 2.48 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
ARG BUILD_FROM="fredrikbaberg/addon-octoprint-next-amd64:0.4.5"
FROM ${BUILD_FROM} AS octoklipper
RUN echo "Extract Python install" && \
tar -zxf /root/python.tar.gz -C /data/ && \
rm -rf /root/python.tar.gz && \
echo "Add OctoKlipper" && \
pip install ${PIP_FLAGS} "https://github.com/thelastWallE/OctoprintKlipperPlugin/archive/master.zip" && \
echo "Cleanup and archive" && \
find /data/python | grep -E "(__pycache__|\.pyc|\.pyo$)" | xargs rm -rf && \
find /usr/lib/python* | grep -E "(__pycache__|\.pyc|\.pyo$)" | xargs rm -rf && \
rm -rf /root/.cache && \
cd /data && tar -zcf /root/python.tar.gz python && \
rm -rf /data/python
FROM ${BUILD_FROM} AS klipperbase
RUN echo "Get Klipper code" && \
apk add --no-cache git && \
git clone https://github.com/KevinOConnor/klipper /root/klipper
COPY rootfs/root/klipper/.config /root/klipper/.config
FROM ${BUILD_FROM} AS final
ENV PIP_FLAGS="--no-cache-dir --extra-index-url https://www.piwheels.org/simple"
ENV CFLAGS="-fcommon"
COPY --from=klipperbase /root/klipper /root/klipper
RUN echo "Install build dependencies." && \
apk add --no-cache --virtual .build-dependencies-klipper \
build-base \
python2-dev \
python3-dev \
py3-virtualenv \
libffi-dev \
gcc-avr \
freetype-dev \
&& \
echo "Install run dependencies." && \
apk add --no-cache --virtual .run-dependencies-klipper \
python2 \
libffi \
avrdude \
libgpiod \
git \
libpng \
&& \
echo "Setup virtual environment." && \
virtualenv --python=python2.7 /root/klippy-env && \
source /root/klippy-env/bin/activate && \
/root/klippy-env/bin/python -m pip install ${PIP_FLAGS} --upgrade pip && \
echo "Install Klipper" && \
pip install ${PIP_FLAGS} -r /root/klipper/scripts/klippy-requirements.txt && \
echo "Install numpy and matplotlib" && \
/root/klippy-env/bin/python -m pip install ${PIP_FLAGS} numpy matplotlib && \
echo "Compile for Linux MCU" && \
cd /root/klipper && \
make clean && make && \
./scripts/flash-linux.sh && \
echo "Final cleanup" && \
apk del --no-cache .build-dependencies-klipper && \
find /root/klippy-env | grep -E "(__pycache__|\.pyc|\.pyo$)" | xargs rm -rf && \
find /usr/lib/python* | grep -E "(__pycache__|\.pyc|\.pyo$)" | xargs rm -rf && \
rm -rf /root/.cache
COPY --from=octoklipper /root/python.tar.gz /root/python.tar.gz
COPY rootfs/ /
WORKDIR /