Repository navigation
Expand file tree
/
Copy pathDockerfile
More file actions
103 lines (73 loc) · 3.45 KB
/
Copy pathDockerfile
File metadata and controls
103 lines (73 loc) · 3.45 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
# syntax=docker.io/docker/dockerfile:1.28.0@sha256:bb22d9815c728170f72750f4e5b0d672e06176142e1d602c7e66c050100b7e5b
# Building wheels for later useage
FROM python:3.13.18-trixie@sha256:51db6babcbd039687e5362a676db5444b5926739abb03b10c8c6a8144872611f AS builder-base
RUN <<eot
apt update
apt install python3-dev pkg-config cmake libdbus-1-dev libgirepository1.0-dev -y --no-install-recommends
rm -rf /var/lib/apt/lists/*
eot
RUN curl --proto '=https' --tlsv1.2 https://sh.rustup.rs -sSf | sh -s -- --default-toolchain stable -y --profile=minimal \
&& rm -rf /root/.rustup/tmp
ENV PATH="/root/.cargo/bin:${PATH}"
# used for building wheels out of requirements.txt
FROM builder-base AS w-builder
ARG TARGETOS
ARG TARGETARCH
ARG TARGETVARIANT
ARG REQUIREMENTS_FILE=requirements.txt
COPY ${REQUIREMENTS_FILE} ./
ARG CARGO_NET_GIT_FETCH_WITH_CLI=true
ARG RUSTFLAGS=" -C lto=no"
RUN --mount=type=bind,source=./wheelhouse/,target=/oldwheels <<eot
export CARGO_BUILD_TARGET="$(rustc -vV | sed -n 's|host: ||p')"
ARCHDIR=$(find /oldwheels -mindepth 1 -maxdepth 2 -regextype posix-extended -type d -regex ".*/${TARGETOS}_${TARGETARCH}(_${TARGETVARIANT})?$")
pip wheel --no-cache-dir --wheel-dir /wheels --find-links file:////$ARCHDIR/wheels -r ${REQUIREMENTS_FILE}
eot
# && pip wheel --wheel-dir /wheels
# pyaml
FROM scratch AS export-stage
COPY --from=w-builder /wheels ./wheels
# base fhempy will be installed
FROM python:3.13.18-slim-trixie@sha256:e48f59cdba69a3cbd9ed2cf0f348d90d45a8d350d98134cf1070bc106ee9ed90 AS base
RUN apt update && \
apt install dbus python-dbus-dev curl git libgirepository-1.0-1 gir1.2-glib-2.0 -y --no-install-recommends \
&& rm -rf /var/lib/apt/lists/*
COPY requirements.txt ./requirements.txt
ARG TARGETOS
ARG TARGETARCH
ARG TARGETVARIANT
RUN --mount=type=bind,source=./wheelhouse,target=/wheels <<eot
ls /wheels
ARCHDIR=$(find /wheels -mindepth 1 -maxdepth 2 -regextype posix-extended -type d -regex ".*/${TARGETOS}_${TARGETARCH}(_${TARGETVARIANT})?$")
echo ${ARCHDIR}
pip install --no-index --find-links file:////$ARCHDIR/wheels --no-cache -r requirements.txt
eot
# image for fhempy modules (final stage) module will be installed here
FROM base AS runtime
WORKDIR /usr/src/apps
#ARG PKGS=python3-dev
#RUN apt update && \
# apt install $PKGS -y --no-install-recommends \
# && rm -rf /var/lib/apt/lists/*
COPY requirements_mod.txt ./requirements.txt
#ARG CRYPTOGRAPHY_DONT_BUILD_RUST=1
# Disable installing from INDEX
ENV PIP_NO_INDEX=1
# The slim image has no compiler; some modules (e.g. git+ requirements) are built here.
# Build tools are installed temporarily and removed again in the same layer.
ARG BUILD_PKGS="gcc libc6-dev libbluetooth-dev"
RUN --mount=type=bind,source=./wheelhouse/,target=/wheels <<eot
apt update
apt install -y --no-install-recommends $BUILD_PKGS
ARCHDIR=$(find /wheels -mindepth 1 -maxdepth 2 -regextype posix-extended -type d -regex ".*/${TARGETOS}_${TARGETARCH}(_${TARGETVARIANT})?$")
pip install --find-links file:////$ARCHDIR/wheels --no-cache -r requirements.txt
apt-mark manual libbluetooth3
apt purge -y --auto-remove $BUILD_PKGS
rm -rf /var/lib/apt/lists/*
eot
#export RUSTFLAGS=" -C lto=no"
#export CARGO_BUILD_TARGET="$(rustc -vV | sed -n 's|host: ||p')"
COPY src/health-check.sh /health-check.sh
RUN chmod +x /health-check.sh
HEALTHCHECK --interval=50s --timeout=15s --start-period=10s --retries=3 CMD /health-check.sh
CMD [ "fhempy" ]