Skip to content

Demo app does not build due to pip error #440

@nextrevision

Description

@nextrevision

Description

After a fresh clone of the repo, running the provided demo app with docker compose --profile dev up results in a quick failure when it tries to install pip in the docker build process.

faro-web-sdk/demo $ docker compose --profile demo up
[+] Building 4.3s (7/41)                                                                                                                                    docker:default
 => [demo internal] load build definition from Dockerfile                                                                                                             0.0s
 16 ENV PYTHONUNBUFFERED=1
 => => transferring dockerfile: 5.29kB                                                                                                                                0.0s
 => [demo internal] load .dockerignore                                                                                                                                0.0s
 => => transferring context: 423B                                                                                                                                     0.0s
 => [demo internal] load metadata for docker.io/library/node:18-alpine                                                                                                0.0s
 => [demo internal] load build context                                                                                                                                0.1s
 => => transferring context: 750.70kB                                                                                                                                 0.1s
 => [demo  1/37] FROM docker.io/library/node:18-alpine                                                                                                                0.0s
 => CACHED [demo  2/37] RUN apk add --update --no-cache python3 make build-base && ln -sf python3 /usr/bin/python                                                     0.0s
 => ERROR [demo  3/37] RUN python3 -m ensurepip                                                                                                                       4.2s
------
 > [demo  3/37] RUN python3 -m ensurepip:
4.109 error: externally-managed-environment
4.109
4.109 × This environment is externally managed
4.109 ╰─>
4.109     The system-wide python installation should be maintained using the system
4.109     package manager (apk) only.
4.109
4.109     If the package in question is not packaged already (and hence installable via
4.109     "apk add py3-somepackage"), please consider installing it inside a virtual
4.109     environment, e.g.:
4.109
4.109     python3 -m venv /path/to/venv
4.109     . /path/to/venv/bin/activate
4.109     pip install mypackage
4.109
4.109     To exit the virtual environment, run:
4.109
4.109     deactivate
4.109
4.109     The virtual environment is not deleted, and can be re-entered by re-sourcing
4.109     the activate file.
4.109
4.109     To automatically manage virtual environments, consider using pipx (from the
4.109     pipx package).
4.109
4.109 note: If you believe this is a mistake, please contact your Python installation or OS distribution provider. You can override this, at the risk of breaking your Python installation or OS, by passing --break-system-packages.
4.109 hint: See PEP 668 for the detailed specification.
4.191 Traceback (most recent call last):
4.191   File "<frozen runpy>", line 198, in _run_module_as_main
4.191   File "<frozen runpy>", line 88, in _run_code
4.191   File "/usr/lib/python3.11/ensurepip/__main__.py", line 5, in <module>
4.191     sys.exit(ensurepip._main())
4.192              ^^^^^^^^^^^^^^^^^
4.192   File "/usr/lib/python3.11/ensurepip/__init__.py", line 286, in _main
4.192     return _bootstrap(
4.192            ^^^^^^^^^^^
4.192   File "/usr/lib/python3.11/ensurepip/__init__.py", line 202, in _bootstrap
4.192     return _run_pip([*args, *_PACKAGE_NAMES], additional_paths)
4.192            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
4.192   File "/usr/lib/python3.11/ensurepip/__init__.py", line 103, in _run_pip
4.193     return subprocess.run(cmd, check=True).returncode
4.193            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
4.193   File "/usr/lib/python3.11/subprocess.py", line 571, in run
4.193     raise CalledProcessError(retcode, process.args,
4.193 subprocess.CalledProcessError: Command '['/usr/bin/python3', '-W', 'ignore::DeprecationWarning', '-c', '\nimport runpy\nimport sys\nsys.path = [\'/tmp/tmpqgc83lld/setuptools-65.5.0-py3-none-any.whl\', \'/tmp/tmpqgc83lld/pip-23.2.1-py3-none-any.whl\'] + sys.path\nsys.argv[1:] = [\'install\', \'--no-cache-dir\', \'--no-index\', \'--find-links\', \'/tmp/tmpqgc83lld\', \'setuptools\', \'pip\']\nrunpy.run_module("pip", run_name="__main__", alter_sys=True)\n']' returned non-zero exit status 1.
------
failed to solve: process "/bin/sh -c python3 -m ensurepip" did not complete successfully: exit code: 1

Steps to reproduce

  1. Clone the repo at the latest version.
  2. Change to the demo directory.
  3. Run the documented command: docker compose --profile demo up (optional -d).

Expected behavior

The build completes and the demo service is started.

Actual behavior

The docker build fails.

Environment

  • SDK version: c6d5cd070b441699850763af34f75ea219a5c0a9 (main)
  • SDK instrumentations: N/A
  • Device type: N/A
  • Device name: N/A
  • OS: MacOS
  • Browser: N/A

Docker Version

$ docker version
Client:
 Version:           24.0.2-rd
 API version:       1.43
 Go version:        go1.20.4
 Git commit:        e63f5fa
 Built:             Fri May 26 16:39:47 2023
 OS/Arch:           darwin/amd64
 Context:           default

Server: Docker Desktop 4.25.2 (129061)
 Engine:
  Version:          24.0.6
  API version:      1.43 (minimum version 1.12)
  Go version:       go1.20.7
  Git commit:       1a79695
  Built:            Mon Sep  4 12:32:16 2023
  OS/Arch:          linux/amd64
  Experimental:     false
 containerd:
  Version:          1.6.22
  GitCommit:        8165feabfdfe38c65b599c4993d227328c231fca
 runc:
  Version:          1.1.8
  GitCommit:        v1.1.8-0-g82f18fe
 docker-init:
  Version:          0.19.0
  GitCommit:        de40ad0

Resolution

To get this working, I changed the Dockerfile in the root of the directory with this patch:

diff --git a/Dockerfile b/Dockerfile
index d174acf..06dc591 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -14,9 +14,8 @@ ARG DEMO_WORKSPACE_PATH

 # Install Python in order to be able to build the native modules
 ENV PYTHONUNBUFFERED=1
-RUN apk add --update --no-cache python3 make build-base && ln -sf python3 /usr/bin/python
-RUN python3 -m ensurepip
-RUN pip3 install --no-cache --upgrade pip setuptools
+RUN apk add --update --no-cache python3 py3-pip make build-base && ln -sf python3 /usr/bin/python
+RUN pip3 install --no-cache --upgrade --break-system-packages pip setuptools

 # Set the workspace path
 WORKDIR ${DEMO_WORKSPACE_PATH}

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugReport a bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions