-
-
Notifications
You must be signed in to change notification settings - Fork 103
Expand file tree
/
Copy pathDockerfile.trixie
More file actions
136 lines (120 loc) · 7.24 KB
/
Copy pathDockerfile.trixie
File metadata and controls
136 lines (120 loc) · 7.24 KB
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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
# Build for raspberry pi
# docker buildx build --platform linux/arm/v7 --progress=plain -t theyosh/terrariumpi:4.0.0 -f Dockerfile --push .
# build sispmctl 4.14
FROM gcc:14-trixie AS sispmctl_builder
ARG SISPMCTL_VERSION="4.12"
WORKDIR /sispmctl
RUN apt-get -o Acquire::ForceIPv4=true update \
&& apt-get -o Acquire::ForceIPv4=true install -y --no-install-recommends libusb-dev \
&& wget https://sourceforge.net/projects/sispmctl/files/sispmctl/sispmctl-${SISPMCTL_VERSION}/sispmctl-${SISPMCTL_VERSION}.tar.gz/download -O sispmctl-${SISPMCTL_VERSION}.tar.gz \
&& tar zxvf sispmctl-${SISPMCTL_VERSION}.tar.gz --strip 1 \
&& ./configure \
&& make \
&& make install
# python builder, help keep image small
FROM python:3.13-trixie AS python_builder
ENV PIP_DEFAULT_TIMEOUT=100 \
# Allow statements and log messages to immediately appear
PYTHONUNBUFFERED=1 \
# disable a pip version check to reduce run-time & log-spam
PIP_DISABLE_PIP_VERSION_CHECK=1 \
# cache is useless in docker image, so disable to reduce image size
PIP_NO_CACHE_DIR=1 \
# do not create __pycache__/ files
PYTHONDONTWRITEBYTECODE=1
ENV PATH="/opt/venv/bin:$PATH"
RUN python -m venv /opt/venv
COPY contrib/pipes/* /opt/venv/lib/python3.13/site-packages/pipes/
RUN pip install --upgrade pip==24.1.2 && pip install --upgrade wheel==0.43.0
COPY requirements.txt contrib/python3-voltcraft-sem6000.patch.diff contrib/python3-as7331.patch.diff /
RUN apt-get -o Acquire::ForceIPv4=true update \
&& apt-get -o Acquire::ForceIPv4=true install -y --no-install-recommends gnupg libxslt1-dev libxml2-dev \
&& mkdir -p /root/.gnupg/ \
&& chmod 700 /root/.gnupg/ \
&& mkdir -p /etc/crypto-policies/back-ends \
&& echo "[hash_algorithms]\nsha1 = \"always\"" > /etc/crypto-policies/back-ends/sequoia.config \
&& curl -fsSL http://raspbian.raspberrypi.org/raspbian.public.key \
| gpg --dearmor -o /usr/share/keyrings/raspbian-keyring.gpg \
&& echo "deb [signed-by=/usr/share/keyrings/raspbian-keyring.gpg] http://raspbian.raspberrypi.org/raspbian/ trixie main contrib non-free rpi" \
> /etc/apt/sources.list.d/raspberrypi.list \
&& curl -fsSL https://archive.raspberrypi.org/debian/raspberrypi.gpg.key \
| gpg --dearmor -o /usr/share/keyrings/raspbian-archive-keyring.gpg \
&& echo "deb [signed-by=/usr/share/keyrings/raspbian-archive-keyring.gpg] http://archive.raspberrypi.org/debian/ trixie main" \
> /etc/apt/sources.list.d/raspberrypi-archive.list \
&& apt-get -o Acquire::ForceIPv4=true update \
&& apt-get -o Acquire::ForceIPv4=true full-upgrade -y --no-install-recommends \
&& apt-get -o Acquire::ForceIPv4=true install -y --no-install-recommends libasound2-dev libglib2.0-dev libbluetooth-dev make
# requirements are slightly different for docker
# overruling does not work here, pip will exit with non 0 which will stop the build
RUN sed -i 's/paho-mqtt==.*//g' requirements.txt \
&& sed -i 's/icalendar==.*//g' requirements.txt \
&& sed -i 's/git+https:\/\/github.com\/PiSupply\/Bright-Pi//g' requirements.txt \
&& sed -i 's/pony==.*/git+https:\/\/github.com\/ponyorm\/pony/g' requirements.txt \
&& pip install -r requirements.txt --extra-index-url https://www.piwheels.org/simple \
&& find /opt/venv -type d -name "test*" | xargs rm -rf \
&& find /opt/venv -type d -name "__pycache__" | xargs rm -rf \
&& find /opt/venv -type d -name ".git" | xargs rm -rf \
&& find /opt/venv -type f -name "*.pyc" -delete
WORKDIR /TerrariumPI
# Just clone the libraries, ignore docker cache...
RUN git clone https://github.com/ageir/chirp-rpi.git --depth 1 "3rdparty/chirp-rpi" \
&& git clone https://github.com/perryflynn/energenie-connect0r.git --depth 1 "3rdparty/energenie-connect0r" \
&& git clone https://github.com/SequentMicrosystems/relay8-rpi.git --depth 1 "3rdparty/relay8-rpi" \
&& git clone https://github.com/AtlasScientific/Raspberry-Pi-sample-code.git --depth 1 "3rdparty/AtlasScientific" \
&& git clone https://github.com/moormaster/python3-voltcraft-sem6000.git --depth 1 "3rdparty/python3-voltcraft-sem6000" \
&& git clone https://github.com/iorodeo/iorodeo-as7331.git --depth 1 "3rdparty/iorodeo-as7331" \
&& patch -N -s -r /dev/null 3rdparty/python3-voltcraft-sem6000/sem6000/repeat_on_failure_decorator.py < /python3-voltcraft-sem6000.patch.diff >/dev/null \
&& patch -N -u -l -s -r /dev/null 3rdparty/iorodeo-as7331/iorodeo_as7331/iorodeo_as7331.py < /python3-as7331.patch.diff >/dev/null \
&& rm -Rf 3rdparty/Bright-Pi/Documents \
&& find . -type d -name "__pycache__" -exec rm -r {} + \
&& find . -type f -name "*.pyc" -delete \
&& find . -type d -name ".git" -exec rm -r {} +
# Sourcecode cleanup and pre-prep
FROM python:3.13-trixie AS sourcecode
WORKDIR /TerrariumPI
COPY . .
# remove git and 3rdparty dir from code copy to help keep image smaller
# 3rdparty is coming from the builder image
RUN rm -Rf .git 3rdparty gui package*.json postcss.config.js rollup.config.js .env.* html-template.js requirements.txt yarn.lock
# actual image
FROM python:3.13-slim-trixie AS finalimage
ARG GITHUB_SHA="development"
ARG JAVA=""
ENV PIP_DEFAULT_TIMEOUT=100 \
# Allow statements and log messages to immediately appear
PYTHONUNBUFFERED=1 \
# disable a pip version check to reduce run-time & log-spam
PIP_DISABLE_PIP_VERSION_CHECK=1 \
# cache is useless in docker image, so disable to reduce image size
PIP_NO_CACHE_DIR=1 \
# do not create __pycache__/ files
PYTHONDONTWRITEBYTECODE=1
ENV DEBIAN_FRONTEND=noninteractive
ENV PATH="/opt/venv/bin:$PATH"
COPY --from=sispmctl_builder /usr/local/lib/libsispmctl* /usr/local/lib/.
COPY --from=sispmctl_builder /usr/local/bin/sispmctl /usr/local/bin/sispmctl
COPY --from=python_builder /usr/share/keyrings /usr/share/keyrings
COPY --from=python_builder /etc/crypto-policies/back-ends /etc/crypto-policies/back-ends
COPY --from=python_builder /etc/apt /etc/apt
COPY --from=python_builder /opt/venv /opt/venv
COPY --from=python_builder /TerrariumPI/3rdparty /TerrariumPI/3rdparty
COPY --from=sourcecode /TerrariumPI /TerrariumPI
RUN rm /usr/local/lib/libsispmctl.so /usr/local/lib/libsispmctl.so.0 \
&& ln -s /usr/local/lib/libsispmctl.so.0.2.2 /usr/local/lib/libsispmctl.so \
&& ln -s /usr/local/lib/libsispmctl.so.0.2.2 /usr/local/lib/libsispmctl.so.0 \
&& ldconfig
RUN apt-get -o Acquire::ForceIPv4=true update \
&& apt-get -o Acquire::ForceIPv4=true full-upgrade -y --no-install-recommends \
&& apt-get -o Acquire::ForceIPv4=true install -y --no-install-recommends netcat-openbsd procps bluez pigpio ffmpeg libopenexr-3-1-30 liblapack3 libatlas3-base libssl1.0.2 libwebpdemux2 libftdi1-2 libxslt1.1 chrony libopenblas0 libgfortran5 raspi-utils rpicam-apps-core \
&& apt-get --purge autoremove -y \
&& apt-get autoclean
RUN apt-get -o Acquire::ForceIPv4=true install -y --no-install-recommends sudo ${JAVA} \
&& rm -rf /var/lib/apt/lists/* \
&& find /var/log/ -type f -delete \
&& find /var/cache/ -type f -delete
WORKDIR /TerrariumPI
# Set git version in a temp file
RUN echo "${GITHUB_SHA}" > .gitversion && echo '[ ! -z "$TERM" -a -r /TerrariumPI/motd.sh ] && /TerrariumPI/motd.sh' >> /etc/bash.bashrc
HEALTHCHECK --interval=180s --timeout=5s --start-period=120s CMD python contrib/docker_health.py
ENTRYPOINT ["/bin/bash", "/TerrariumPI/run.sh"]
CMD ["/opt/venv/bin/python", "/TerrariumPI/terrariumPI.py"]