Closed Blackfishbox closed 3 years ago
Hmm, yeah looks like both rasterio and pylibmc need gcc on arm64, and I don't have enough arm experience to get gcc working.
But here's a workaround modification to docker/Dockerfile
that seems to work:
Before the pip commands, install the problem packages from debian's repos:
RUN set -e && \
apt-get update && \
apt-get install -y --no-install-recommends \
python3-rasterio python3-pylibmc
Add the debian python packages to python's path
ENV PYTHONPATH="/usr/lib/python3/dist-packages:${PYTHONPATH}"
Replace all mentions of the pinned dependency file requirements.txt
with the non-pinned file requirements.in
COPY requirements.in /app/requirements.in
RUN pip install \
--no-index \
--no-cache-dir \
--disable-pip-version-check \
--find-links=/root/wheels \
uwsgi regex && \
pip install --no-cache-dir --disable-pip-version-check -r /app/requirements.in && \
rm -rf /root/.cache/pip/* && \
rm root/wheels/* && \
rm /app/requirements.in
So the full Dockerfile would look like this:
# Container for packages that need to be built from source but have massive dev dependencies.
FROM python:3.7.9-slim-buster as builder
RUN set -e && \
apt-get update && \
apt-get install -y --no-install-recommends \
gcc \
python3.7-dev
RUN pip wheel --wheel-dir=/root/wheels uwsgi==2.0.19.1 && \
pip wheel --wheel-dir=/root/wheels regex==2020.11.13
# The actual container.
FROM python:3.7.9-slim-buster
RUN set -e && \
apt-get update && \
apt-get install -y --no-install-recommends \
nginx \
memcached \
python3-rasterio \
python3-pylibmc \
supervisor && \
rm -rf /var/lib/apt/lists/*
ENV PYTHONPATH="/usr/lib/python3/dist-packages:${PYTHONPATH}"
COPY --from=builder /root/wheels /root/wheels
COPY requirements.in /app/requirements.in
RUN pip install \
--no-index \
--no-cache-dir \
--disable-pip-version-check \
--find-links=/root/wheels \
uwsgi regex && \
pip install --no-cache-dir --disable-pip-version-check -r /app/requirements.in && \
rm -rf /root/.cache/pip/* && \
rm root/wheels/* && \
rm /app/requirements.in
WORKDIR /app
COPY . /app/
RUN echo > /etc/nginx/sites-available/default && \
cp /app/docker/nginx.conf /etc/nginx/conf.d/nginx.conf && \
cp /app/docker/supervisord.conf /etc/supervisor/conf.d/supervisord.conf
CMD ["sh", "/app/docker/run.sh"]
EXPOSE 5000
ENV CURL_CA_BUNDLE=/etc/ssl/certs/ca-certificates.crt
It's a bit hacky and might not work long term, but seems to pass tests!
Wow, thank you very much for your quick reply and the workaround! It works now! :)
Hi, I'm trying to run "make build" on a Raspberry Pi 4 with Rasperry OS 64bit (aarch64 / arm64) or (as an alternative) tried "docker buildx --platform linux/arm64" on a Windows 10 64bit machine. Both however don't succed and throw an error when trying to install the requirements.txt As far as I understand it, it seems like rasterio causes the problem, because there is no arm64 wheel version. Could you somehow provide a workaround or installation instructions without docker (maybe I can locally install and compile rasterio)?