Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[DOCKER] Docker build failing on arm - cryptography requires Rust #565

Closed
achilleas-k opened this issue Sep 30, 2021 · 5 comments
Closed

Comments

@achilleas-k
Copy link

With the latest Cryptography update (35.0.0), the CRYPTOGRAPHY_DONT_BUILD_RUST env var is ignored and rust is now required to build cryptography. This breaks Docker on arm again, which was originally fixed in #492.

@achilleas-k achilleas-k changed the title [DOCKER] Docker build failing on arm - cryptography requires Rist [DOCKER] Docker build failing on arm - cryptography requires Rust Sep 30, 2021
@cuu508
Copy link
Member

cuu508 commented Sep 30, 2021

Thanks for the report!

Pinning cryptography==3.4.8 would work but is of course not ideal.

I tried installing rust first:

apt-get install build-essential libssl-dev libffi-dev python3-dev cargo

And then installing cryptography. This works but takes more than 5 minutes (I'm experimenting on rPi), so also not great.

It would be best if we could get pip to use binary wheels.

@cuu508
Copy link
Member

cuu508 commented Sep 30, 2021

Filed an issue (more like a support request) in the cryptography repo: pyca/cryptography#6342

@cuu508
Copy link
Member

cuu508 commented Sep 30, 2021

OK, so cryptography does not provide (and don't plan to provide) 32-bit arm wheels.

Healthchecks needs the fido2 library for WebAuthn support.
fido2 really needs cryptography – it's used throughout the library.
And, starting from version 35, cryptography really needs rust.

There is https://www.piwheels.org/ – a wheel repository for Raspberry Pi. I tested it out:

$ docker run -it python:3.9-slim-buster bash
root@d110ba87afb0:/# echo "[global]
> extra-index-url=https://www.piwheels.org/simple
> " > /etc/pip.conf
root@d110ba87afb0:/# pip install cryptography
Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple
Collecting cryptography
  Downloading https://www.piwheels.org/simple/cryptography/cryptography-35.0.0-cp39-cp39-linux_armv7l.whl (2.6 MB)
     |████████████████████████████████| 2.6 MB 1.4 MB/s 
Collecting cffi>=1.12
  Downloading https://www.piwheels.org/simple/cffi/cffi-1.14.6-cp39-cp39-linux_armv7l.whl (369 kB)
     |████████████████████████████████| 369 kB 545 kB/s 
Collecting pycparser
  Downloading https://www.piwheels.org/simple/pycparser/pycparser-2.20-py2.py3-none-any.whl (112 kB)
     |████████████████████████████████| 112 kB 544 kB/s 
Installing collected packages: pycparser, cffi, cryptography
Successfully installed cffi-1.14.6 cryptography-35.0.0 pycparser-2.20
WARNING: Running pip as the 'root' user can result in broken permissions and conflicting behaviour with the system package manager. It is recommended to use a virtual environment instead: https://pip.pypa.io/warnings/venv
root@d110ba87afb0:/# 

But I'm not sure what to do with the Dockerfile. It seems wrong to add the piwheels repository for all architectures.

@achilleas-k
Copy link
Author

achilleas-k commented Sep 30, 2021

But I'm not sure what to do with the Dockerfile. It seems wrong to add the piwheels repository for all architectures.

I know what you mean. Probably makes more sense to build it from source instead and take the 5 min build time.
Could do a multi-step build where the first container builds cryptography to speed up rebuilds and updates without rebuilding cryptography.

@cuu508
Copy link
Member

cuu508 commented Oct 13, 2021

I updated the Dockerfile to use the prebuilt wheels from piwheels.org but only if the architecture is armhf:

RUN \
    if [ `dpkg --print-architecture` = "armhf" ]; then \
    printf "[global]\nextra-index-url=https://www.piwheels.org/simple\n" > /etc/pip.conf ; \
    fi

The alternative of installing rust and building cryptography from source is problematic on armhf – see #568.

pschmitt added a commit to pschmitt/pkp that referenced this issue Nov 2, 2021
umbynos added a commit to arduino/imgtool-packing that referenced this issue Feb 10, 2022
umbynos added a commit to arduino/imgtool-packing that referenced this issue Feb 10, 2022
umbynos added a commit to arduino/imgtool-packing that referenced this issue Feb 10, 2022
umbynos added a commit to arduino/imgtool-packing that referenced this issue Feb 11, 2022
0009 is used to patch cryptography version used because of: healthchecks/healthchecks#565
umbynos added a commit to arduino/imgtool-packing that referenced this issue Feb 16, 2022
0009 is used to patch cryptography version used because of: healthchecks/healthchecks#565
umbynos added a commit to arduino/imgtool-packing that referenced this issue Feb 16, 2022
0009 is used to patch cryptography version used because of: healthchecks/healthchecks#565
umbynos added a commit to arduino/imgtool-packing that referenced this issue Feb 18, 2022
* Update README.md

* add license, the same used in imgtool repo

* add patches, apply them on top of 1.8.0

0009 is used to patch cryptography version used because of: healthchecks/healthchecks#565

* [WIP] add first draft of release wf

[TODO] remove hardcoded version and use ${GITHUB_REF/refs\/tags\//}

add bash as default shell to find zip on win

use 7zip on win to archive, zip is not installed by default

remove ${{ github.workspace }} from win, it does not get expanded correctly

* fix mac archive being corrupted

tar in macos is not working correctly on the ghactions hosted runners actions/runner-images#2619

* add build using qemu and crosscompile with docker containers

* fix path of volume binding, without the absolute path the volume is empty

* fix permission problem: dist dir is created in the container with different user/grp

* try to fix armv6 and v7

* install all qemu platforms, the build time does not increase

* use version 4.2 of pyinstaller [it has the bootloader 🎉 for Linux-32-arm] pyinstaller/pyinstaller#6532 (comment)

* use arm32v5 instead of arm32v6 as target arch. Debian is not available for armv6.
arm32v6 arch should be able to run arm32v5 binaries

* test for pyinstaller guys

* bring back runner version because of glibc too recent

* try to run file produced by pyinstaller

* fix imgtool not starting. imgtool has to be run from `scripts/` folder and not from `imgtool/` one. Otherwise it will pick up the wrong main.py

* use `env.PROJECT_NAME`

* finalize CI: add correct trigger, create-release step, step names & cleanup

* Apply suggestions from code review

Co-authored-by: per1234 <accounts@perglass.com>

* better organize the print output

Co-authored-by: per1234 <accounts@perglass.com>

* use env vars to factor out path strings

Co-authored-by: per1234 <accounts@perglass.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants