0
0

More than 1 year has passed since last update.

ラズパイのDockerでpip install cryptographyが失敗する

Posted at

問題

pip install cryptographyが失敗する。
cryptographypoetryの依存ライブラリ。
imageはpython:3.9-slim-buster

解決策

cryptographyがRUSTコンパイラを使用しないバージョンを指定する。かつ依存ライブラリをaptでインストール。
環境変数 CRYPTOGRAPHY_DONT_BUILD_RUSTに何でも良いので値をセットするとRUSTコンパイラを使わなくなる。

Dockerfile

poetryを使ってPythonアプリを動かす例。

FROM python:3.9-slim-buster

ENV PYTHONUNBUFFERED 1
ENV CRYPTOGRAPHY_DONT_BUILD_RUST 1

WORKDIR /src

RUN apt update && apt install --no-install-recommends -y build-essential libffi-dev ca-certificates
python-cffi libssl-dev
RUN pip install cryptography==3.4.1
RUN pip install poetry
RUN mkdir /src/logs


COPY pyproject.toml* poetry.lock* ./
COPY app /src/app
COPY log_conf.yml ./
COPY env.sh ./


RUN poetry config virtualenvs.in-project true
RUN if [ -f pyproject.toml ]; then poetry install; fi

CMD ["poetry", "run", "uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "80", "--reload", "-
-log-config", "log_conf.yml"]
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0