33# when building multiarch using buildx, then try this:
44# https://github.com/docker/buildx/issues/495#issuecomment-761562905
55
6- FROM python:3.8-buster AS base
6+ FROM python:3.8-slim- buster AS base
77
88ENV LANG C.UTF-8
99ENV LC_ALL C.UTF-8
1010
1111
1212FROM base AS requirements
1313
14- ARG BUILDX_QEMU_ENV
15- RUN apt-get update && \
16- apt-get install -y lsb-release rustc libssl-dev libffi-dev python3-venv && \
17- apt-get clean && \
18- rm -rf /var/lib/apt-/lists/*
14+ # On linux/arm/v7 the cryptography package has no binary wheel, so we need its build
15+ # dependencies. For rust, install the latest from rustup to avoid issues.
16+ ARG TARGETPLATFORM
17+ RUN if [ "${TARGETPLATFORM}" = "linux/arm/v7" ]; then \
18+ apt-get update && \
19+ apt-get install -y lsb-release curl g++ pkg-config libssl-dev libffi-dev && \
20+ \
21+ (curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | bash -s -- -y) \
22+ fi
23+ ENV PATH="/root/.cargo/bin:${PATH}"
1924
20- # This nonsense is required for this reason:
21- # https://github.com/JonasAlfredsson/docker-nginx-certbot/issues/30
22-
23- RUN pip install --no-cache-dir wheel setuptools-rust && \
24- if [ "${BUILDX_QEMU_ENV}" = "true" -a "$(getconf LONG_BIT)" = "32" ]; then \
25- pip install --no-cache-dir cryptography==3.3.2; \
26- fi && \
27- pip install --no-cache-dir poetry
2825
2926COPY pyproject.toml ./
30- RUN poetry export -o /requirements.txt && \
27+ RUN pip install --no-cache-dir poetry && \
28+ poetry export -o /requirements.txt && \
3129 mkdir -p /home/mqtt_io && \
3230 python -m venv /home/mqtt_io/venv && \
3331 /home/mqtt_io/venv/bin/pip install wheel
@@ -41,8 +39,8 @@ WORKDIR /home/mqtt_io
4139
4240COPY --from=requirements --chown=mqtt_io /home/mqtt_io/venv ./venv
4341COPY --from=requirements /requirements.txt ./
44- RUN venv/bin/python -m pip install --upgrade pip
45- RUN venv/bin/pip install -r requirements.txt
42+ RUN venv/bin/python -m pip install --no-cache-dir -- upgrade pip
43+ RUN venv/bin/pip install --no-cache-dir - r requirements.txt
4644
4745COPY --chown=mqtt_io mqtt_io mqtt_io
4846
0 commit comments