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 build on raspberry pi required some extra work #13

Open
mmakaay opened this issue Jul 29, 2021 · 2 comments
Open

Docker build on raspberry pi required some extra work #13

mmakaay opened this issue Jul 29, 2021 · 2 comments

Comments

@mmakaay
Copy link

mmakaay commented Jul 29, 2021

Because the python3 cryptography module wasn't available in a ready-to-go package, it needed to be compiled while building the docker image. That compile missed some requirements. I was able to build the container image, by using the following updated line in the Dockerfile:

RUN apk add py3-cryptography py3-paho-mqtt py3-pip gcc rust cargo python3-dev libffi-dev libc-dev linux-headers openssl-dev

Alternatively, I also tried adding a "pip install --upgrade pip" operation in the build (normally the way to get access to the required binary package), but that didn't help on my Raspberry.

@lbschenkel
Copy link
Owner

lbschenkel commented Sep 24, 2021

Sorry for the delay in responding. I am a bit confused about what is going on, because I am running the arm64 container and I am able to build without issues.

I find it suspicious that you're adding Rust to the container since the bridge specifies a py-cryptography version that is lower than the one that requires Rust. I am deliberately avoiding the Rust dependency to simplify the build process. So something's off. Never mind, sorry, I was thinking in terms of the bridge but the HASS add-on installs the latest version available from Alpine. Either way, py3-cryptography installs the precompiled version and there should be no need to have Rust in the container because cryptography should not be built from source. So I'm not quite sure what your box is trying to build.

Can you try again and provide additional logs containing the build errors?

@mmakaay
Copy link
Author

mmakaay commented Sep 24, 2021

Sure thing. Here's a build with the original Dockerfile:

Sending build context to Docker daemon  314.9kB

Step 1/11 : FROM alpine
 ---> 187f426e38b1
Step 2/11 : ENV LANG C.UTF-8
 ---> Using cache
 ---> 858777347a4b
Step 3/11 : RUN apk add py3-cryptography py3-paho-mqtt py3-pip
 ---> Using cache
 ---> 1f4b0611d469
Step 4/11 : COPY setup.py /tmp/build/
 ---> Using cache
 ---> 3aeb6a2e6695
Step 5/11 : COPY broadlink_bridge/ /tmp/build/broadlink_bridge/
 ---> Using cache
 ---> 9df634e5ed75
Step 6/11 : RUN pip3 install /tmp/build     && rm -Rf /tmp/build
 ---> Running in cd250055e10d
Processing /tmp/build
Collecting broadlink==0.17.0
  Downloading broadlink-0.17.0.tar.gz (15 kB)
Collecting cryptography>=3.2
  Downloading cryptography-3.4.8.tar.gz (546 kB)
  Installing build dependencies: started
  Installing build dependencies: finished with status 'error'
�[91m  ERROR: Command errored out with exit status 1:
   command: /usr/bin/python3 /usr/lib/python3.8/site-packages/pip install --ignore-installed --no-user --prefix /tmp/pip-build-env-o8sme2cs/overlay --no-warn-script-location --no-binary :none: --only-binary :none: -i https://pypi.org/simple -- 'setuptools>=40.6.0' wheel 'cffi>=1.12; platform_python_implementation != '"'"'PyPy'"'"'' 'setuptools-rust>=0.11.4'
       cwd: None
  Complete output (72 lines):
  Collecting setuptools>=40.6.0
    Downloading setuptools-58.1.0-py3-none-any.whl (816 kB)
  Collecting wheel
    Downloading wheel-0.37.0-py2.py3-none-any.whl (35 kB)
  Collecting cffi>=1.12
    Downloading cffi-1.14.6.tar.gz (475 kB)
  Collecting setuptools-rust>=0.11.4
    Downloading setuptools_rust-0.12.1-py3-none-any.whl (22 kB)
  Collecting pycparser
    Downloading pycparser-2.20-py2.py3-none-any.whl (112 kB)
  Collecting toml>=0.9.0
    Downloading toml-0.10.2-py2.py3-none-any.whl (16 kB)
  Collecting semantic-version>=2.6.0
    Downloading semantic_version-2.8.5-py2.py3-none-any.whl (15 kB)
  Using legacy setup.py install for cffi, since package 'wheel' is not installed.
  Installing collected packages: setuptools, wheel, pycparser, cffi, toml, semantic-version, setuptools-rust
      Running setup.py install for cffi: started
      Running setup.py install for cffi: finished with status 'error'
      ERROR: Command errored out with exit status 1:
       command: /usr/bin/python3 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-bm00l503/cffi/setup.py'"'"'; __file__='"'"'/tmp/pip-install-bm00l503/cffi/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /tmp/pip-record-k745fk9v/install-record.txt --single-version-externally-managed --prefix /tmp/pip-build-env-o8sme2cs/overlay --compile --install-headers /tmp/pip-build-env-o8sme2cs/overlay/include/python3.8/cffi
           cwd: /tmp/pip-install-bm00l503/cffi/
      Complete output (48 lines):
      unable to execute 'gcc': No such file or directory
      unable to execute 'gcc': No such file or directory
  
          No working compiler found, or bogus compiler options passed to
          the compiler from Python's standard "distutils" module.  See
          the error messages above.  Likely, the problem is not related
          to CFFI but generic to the setup.py of any Python package that
          tries to compile C code.  (Hints: on OS/X 10.8, for errors about
          -mno-fused-madd see http://stackoverflow.com/questions/22313407/
          Otherwise, see https://wiki.python.org/moin/CompLangPython or
          the IRC channel #python on irc.libera.chat.)
  
          Trying to continue anyway.  If you are trying to install CFFI from
          a build done in a different context, you can ignore this warning.
  
      running install
      running build
      running build_py
      creating build
      creating build/lib.linux-armv7l-3.8
      creating build/lib.linux-armv7l-3.8/cffi
      copying cffi/vengine_cpy.py -> build/lib.linux-armv7l-3.8/cffi
      copying cffi/cffi_opcode.py -> build/lib.linux-armv7l-3.8/cffi
      copying cffi/pkgconfig.py -> build/lib.linux-armv7l-3.8/cffi
      copying cffi/__init__.py -> build/lib.linux-armv7l-3.8/cffi
      copying cffi/setuptools_ext.py -> build/lib.linux-armv7l-3.8/cffi
      copying cffi/lock.py -> build/lib.linux-armv7l-3.8/cffi
      copying cffi/backend_ctypes.py -> build/lib.linux-armv7l-3.8/cffi
      copying cffi/vengine_gen.py -> build/lib.linux-armv7l-3.8/cffi
      copying cffi/commontypes.py -> build/lib.linux-armv7l-3.8/cffi
      copying cffi/error.py -> build/lib.linux-armv7l-3.8/cffi
      copying cffi/model.py -> build/lib.linux-armv7l-3.8/cffi
      copying cffi/recompiler.py -> build/lib.linux-armv7l-3.8/cffi
      copying cffi/ffiplatform.py -> build/lib.linux-armv7l-3.8/cffi
      copying cffi/cparser.py -> build/lib.linux-armv7l-3.8/cffi
      copying cffi/api.py -> build/lib.linux-armv7l-3.8/cffi
      copying cffi/verifier.py -> build/lib.linux-armv7l-3.8/cffi
      copying cffi/_cffi_include.h -> build/lib.linux-armv7l-3.8/cffi
      copying cffi/parse_c_type.h -> build/lib.linux-armv7l-3.8/cffi
      copying cffi/_embedding.h -> build/lib.linux-armv7l-3.8/cffi
      copying cffi/_cffi_errors.h -> build/lib.linux-armv7l-3.8/cffi
      running build_ext
      building '_cffi_backend' extension
      creating build/temp.linux-armv7l-3.8
      creating build/temp.linux-armv7l-3.8/c
      gcc -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -fomit-frame-pointer -g -fno-semantic-interposition -fomit-frame-pointer -g -fno-semantic-interposition -fomit-frame-pointer -g -fno-semantic-interposition -DTHREAD_STACK_SIZE=0x100000 -fPIC -I/usr/include/ffi -I/usr/include/libffi -I/usr/include/python3.8 -c c/_cffi_backend.c -o build/temp.linux-armv7l-3.8/c/_cffi_backend.o
      unable to execute 'gcc': No such file or directory
      error: command 'gcc' failed with exit status 1
      ----------------------------------------
  ERROR: Command errored out with exit status 1: /usr/bin/python3 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-bm00l503/cffi/setup.py'"'"'; __file__='"'"'/tmp/pip-install-bm00l503/cffi/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /tmp/pip-record-k745fk9v/install-record.txt --single-version-externally-managed --prefix /tmp/pip-build-env-o8sme2cs/overlay --compile --install-headers /tmp/pip-build-env-o8sme2cs/overlay/include/python3.8/cffi Check the logs for full command output.
  ----------------------------------------
�[0m�[91mERROR: Command errored out with exit status 1: /usr/bin/python3 /usr/lib/python3.8/site-packages/pip install --ignore-installed --no-user --prefix /tmp/pip-build-env-o8sme2cs/overlay --no-warn-script-location --no-binary :none: --only-binary :none: -i https://pypi.org/simple -- 'setuptools>=40.6.0' wheel 'cffi>=1.12; platform_python_implementation != '"'"'PyPy'"'"'' 'setuptools-rust>=0.11.4' Check the logs for full command output.
�[0mThe command '/bin/sh -c pip3 install /tmp/build     && rm -Rf /tmp/build' returned a non-zero code: 1

And here's the output for a modified Dockerfile:

Sending build context to Docker daemon  314.9kB

Step 1/11 : FROM alpine
 ---> 187f426e38b1
Step 2/11 : ENV LANG C.UTF-8
 ---> Using cache
 ---> 858777347a4b
Step 3/11 : RUN apk add py3-cryptography py3-paho-mqtt py3-pip gcc rust cargo python3-dev libffi-dev libc-dev linux-headers openssl-dev
 ---> Using cache
 ---> eefd7bb80ced
Step 4/11 : COPY setup.py /tmp/build/
 ---> de388eb352e8
Step 5/11 : COPY broadlink_bridge/ /tmp/build/broadlink_bridge/
 ---> 26e0763d3869
Step 6/11 : RUN pip3 install /tmp/build     && rm -Rf /tmp/build
 ---> Running in 25d1340c7eb7
Processing /tmp/build
Collecting broadlink==0.17.0
  Downloading broadlink-0.17.0.tar.gz (15 kB)
Collecting cryptography>=3.2
  Downloading cryptography-3.4.8.tar.gz (546 kB)
  Installing build dependencies: started
  Installing build dependencies: finished with status 'done'
  Getting requirements to build wheel: started
  Getting requirements to build wheel: finished with status 'done'
    Preparing wheel metadata: started
    Preparing wheel metadata: finished with status 'done'
Requirement already satisfied: paho-mqtt>=1.4.0 in /usr/lib/python3.8/site-packages (from broadlink-bridge==0.1.8) (1.5.0)
Requirement already satisfied: cffi>=1.12 in /usr/lib/python3.8/site-packages (from cryptography>=3.2->broadlink-bridge==0.1.8) (1.14.0)
Requirement already satisfied: pycparser in /usr/lib/python3.8/site-packages (from cffi>=1.12->cryptography>=3.2->broadlink-bridge==0.1.8) (2.20)
Using legacy setup.py install for broadlink-bridge, since package 'wheel' is not installed.
Using legacy setup.py install for broadlink, since package 'wheel' is not installed.
Building wheels for collected packages: cryptography
  Building wheel for cryptography (PEP 517): started
  Building wheel for cryptography (PEP 517): still running...
  Building wheel for cryptography (PEP 517): still running...
  Building wheel for cryptography (PEP 517): still running...
  Building wheel for cryptography (PEP 517): still running...
  Building wheel for cryptography (PEP 517): finished with status 'done'
  Created wheel for cryptography: filename=cryptography-3.4.8-cp38-cp38-linux_armv7l.whl size=1436328 sha256=5eba87557e1a157a9ebc07967e3faca72ecf542b658e07bc676cc793a0437405
  Stored in directory: /root/.cache/pip/wheels/fa/63/be/9d1a5d62023483a758d539b4e32479e7e384cc60041ea8baee
Successfully built cryptography
Installing collected packages: cryptography, broadlink, broadlink-bridge
  Attempting uninstall: cryptography
    Found existing installation: cryptography 2.9.2
    Uninstalling cryptography-2.9.2:
      Successfully uninstalled cryptography-2.9.2
    Running setup.py install for broadlink: started
    Running setup.py install for broadlink: finished with status 'done'
    Running setup.py install for broadlink-bridge: started
    Running setup.py install for broadlink-bridge: finished with status 'done'
Successfully installed broadlink-0.17.0 broadlink-bridge-0.1.8 cryptography-3.4.8
Removing intermediate container 25d1340c7eb7
 ---> a9913b3a5314
Step 7/11 : RUN mkdir -p /config && touch /config/config.ini
 ---> Running in d2841d00950f
Removing intermediate container d2841d00950f
 ---> eb3dea738621
Step 8/11 : VOLUME [ "/config" ]
 ---> Running in 3871aba2de6e
Removing intermediate container 3871aba2de6e
 ---> 8c43340b8444
Step 9/11 : USER nobody
 ---> Running in 3702d0e6ad1f
Removing intermediate container 3702d0e6ad1f
 ---> ac19f197d807
Step 10/11 : EXPOSE 8765 8780
 ---> Running in b0b323efcd16
Removing intermediate container b0b323efcd16
 ---> 80fb77c52743
Step 11/11 : CMD [ "broadlink-bridge", "/config/config.ini" ]
 ---> Running in ce3b78ef9e72
Removing intermediate container ce3b78ef9e72
 ---> 053ad63aa203
Successfully built 053ad63aa203
Successfully tagged mmakaay/broadlink-bridge:latest

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