alpine failed to install cryptography

Introduction to alpine

Alpine Linux is a community-developed lightweight Linux distribution for security applications.
In short, many dockers are developed based on alpine. Because alpine is very small, only 5.5M, compared to centos, redhat, ubantu, etc., it is too small. Of course, it does not have many toolkits, and the simplest gcc does not. However, it has a built-in apk tool management package. If you want to know more, you can Baidu relevant information.

Introduction to cryptography

Cryptography is a development package that provides cryptographic primitives and recipes for Python developers .
To put it simply, our various encryption and decryption are basically completed through this development kit.
Use case 1: When the WeChat applet logs in to obtain the login information, it will use cryptography to decrypt it.
Use case 2: python channels use cryptography

question:

Baidu does not have a suitable answer in a circle, go to the official website, the FAQ given by the official website is also wrong. Finally, I found the solution given by the big guy on git.
The reason is that the rust version number built into alpine is too low. At least rust>1.45 is required, but the official website prompts 1.41.

specific solutions

Because we use alpine to create the smallest instance container based on docker, here is a docker RUN:

ENV PATH="/root/.cargo/bin:${PATH}"

RUN curl https://static.rust-lang.org/rustup/dist/x86_64-unknown-linux-musl/rustup-init --output /tmp/rustup-init \
    && chmod +x /tmp/rustup-init \
    && /tmp/rustup-init -y \
    && pip install --no-cache-dir cryptography \
    && rustup self uninstall -y
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7

Others can rely on the official website to solve. For example, several packages that must be installed apk add --no-cache xxx

Tags: alpine failed to install cryptography

alpine cryptography python docker alpine linux

Related: alpine failed to install cryptography