From 0a6e0e335e29f9c34bb01e11730af7f962d022c8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oriol=20Canad=C3=A9s?= <83498869+oriolcanadesin2@users.noreply.github.com> Date: Tue, 18 Jul 2023 15:33:26 +0200 Subject: [PATCH 1/2] Update README.md Fix Accumulator Server Dockerfile configuration --- test/functionalTest/README.md | 43 +++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/test/functionalTest/README.md b/test/functionalTest/README.md index 97b91b5f21..04b19dc493 100644 --- a/test/functionalTest/README.md +++ b/test/functionalTest/README.md @@ -62,6 +62,49 @@ CMD ["--port", "1028", "--url", "/accumulate", "--host", "0.0.0.0", "-v"] **Important note**: copy the accumulator-server.py to the same directory in which Dockerfile is, before running your `docker build` command. +**Probably error**: If during the building of docker image you get a similar error: +``` + > [5/8] RUN pip install Flask==2.3.0 #2.0.2: +#0 0.446 error: externally-managed-environment +#0 0.446 +#0 0.446 × This environment is externally managed +#0 0.446 ╰─> To install Python packages system-wide, try apt install +#0 0.446 python3-xyz, where xyz is the package you are trying to +#0 0.446 install. +#0 0.446 +#0 0.446 If you wish to install a non-Debian-packaged Python package, +#0 0.446 create a virtual environment using python3 -m venv path/to/venv. +#0 0.446 Then use path/to/venv/bin/python and path/to/venv/bin/pip. Make +#0 0.446 sure you have python3-full installed. +#0 0.446 +#0 0.446 If you wish to install a non-Debian packaged Python application, +#0 0.446 it may be easiest to use pipx install xyz, which will manage a +#0 0.446 virtual environment for you. Make sure you have pipx installed. +#0 0.446 +#0 0.446 See /usr/share/doc/python3.11/README.venv for more information. +#0 0.446 +#0 0.446 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. +#0 0.446 hint: See PEP 668 for the detailed specification. +``` +This is produced by the current Dockerfile configuration because tis behavior is specific to the Debian-based container we are using. If you get this error, just change the Dockerfile for: +``` +FROM debian:stable +RUN apt-get update -y +RUN apt-get install -y python3 python3-venv python3-pip + +# Create a virtual environment +RUN python3 -m venv /venv +ENV PATH="/venv/bin:$PATH" + +# Install required packages within the virtual environment +RUN pip install Flask==2.0.2 paho-mqtt==1.6.1 + +COPY . /app +WORKDIR /app +ENTRYPOINT [ "python3", "./accumulator-server.py"] +CMD ["--port", "1028", "--url", "/accumulate", "--host", "0.0.0.0", "-v"] +``` + Once build (let's say with name 'accum') you can run it with: ``` From 6ab6f448061caa85280220b658d91500f26e679d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oriol=20Canad=C3=A9s?= <83498869+oriolcanadesin2@users.noreply.github.com> Date: Mon, 7 Aug 2023 07:59:12 +0200 Subject: [PATCH 2/2] Update README.md --- test/functionalTest/README.md | 42 ++--------------------------------- 1 file changed, 2 insertions(+), 40 deletions(-) diff --git a/test/functionalTest/README.md b/test/functionalTest/README.md index 04b19dc493..be195dbce6 100644 --- a/test/functionalTest/README.md +++ b/test/functionalTest/README.md @@ -47,46 +47,6 @@ accumulator-server.py -u You can use the following Dockerfile to build the accumulator: -``` -FROM debian:stable -RUN apt-get update -y -RUN apt-get install -y python3 -RUN apt-get install -y python3-pip -RUN pip install Flask==2.0.2 -RUN pip install paho-mqtt==1.6.1 -COPY . /app -WORKDIR /app -ENTRYPOINT [ "python3", "./accumulator-server.py"] -CMD ["--port", "1028", "--url", "/accumulate", "--host", "0.0.0.0", "-v"] -``` - -**Important note**: copy the accumulator-server.py to the same directory in which Dockerfile is, before running your `docker build` command. - -**Probably error**: If during the building of docker image you get a similar error: -``` - > [5/8] RUN pip install Flask==2.3.0 #2.0.2: -#0 0.446 error: externally-managed-environment -#0 0.446 -#0 0.446 × This environment is externally managed -#0 0.446 ╰─> To install Python packages system-wide, try apt install -#0 0.446 python3-xyz, where xyz is the package you are trying to -#0 0.446 install. -#0 0.446 -#0 0.446 If you wish to install a non-Debian-packaged Python package, -#0 0.446 create a virtual environment using python3 -m venv path/to/venv. -#0 0.446 Then use path/to/venv/bin/python and path/to/venv/bin/pip. Make -#0 0.446 sure you have python3-full installed. -#0 0.446 -#0 0.446 If you wish to install a non-Debian packaged Python application, -#0 0.446 it may be easiest to use pipx install xyz, which will manage a -#0 0.446 virtual environment for you. Make sure you have pipx installed. -#0 0.446 -#0 0.446 See /usr/share/doc/python3.11/README.venv for more information. -#0 0.446 -#0 0.446 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. -#0 0.446 hint: See PEP 668 for the detailed specification. -``` -This is produced by the current Dockerfile configuration because tis behavior is specific to the Debian-based container we are using. If you get this error, just change the Dockerfile for: ``` FROM debian:stable RUN apt-get update -y @@ -105,6 +65,8 @@ ENTRYPOINT [ "python3", "./accumulator-server.py"] CMD ["--port", "1028", "--url", "/accumulate", "--host", "0.0.0.0", "-v"] ``` +**Important note**: copy the accumulator-server.py to the same directory in which Dockerfile is, before running your `docker build` command. + Once build (let's say with name 'accum') you can run it with: ```