02/16/2022, 4:39 PM
I'm running into an issue while executing a package goal inside a Docker container where the symlink for the generated virtualenv is not resolveable during the packaging step.
Copy code
#13 155.5 Successfully installed PyYAML-6.0 ansicolors-1.1.8 certifi-2021.10.8 charset-normalizer-2.0.12 fasteners-0.16.3 humbug-0.2.7 idna-3.3 ijson-3.1.4 packaging-21.0 pantsbuild.pants-2.9.0 pex-2.1.61 psutil-5.8.0 pyparsing-3.0.7 requests-2.27.1 setproctitle-1.2.2 setuptools-57.5.0 six-1.16.0 toml-0.10.2 types-PyYAML-5.4.3 types-setuptools-57.0.0 types-toml-0.1.3 typing-extensions- urllib3-1.26.8

#13 155.8 New virtual environment successfully created at /home/app/.cache/pants/setup/bootstrap-Linux-x86_64/2.9.0_py39.

#13 159.8 15:54:39.54 [INFO] Initializing scheduler...

#13 160.0 15:54:39.74 [INFO] Scheduler initialized.

#13 164.7 15:54:44.44 [ERROR] 1 Exception encountered:

#13 164.7 

#13 164.7   Exception: Failed to read link "/home/app/.cache/pants/setup/bootstrap-Linux-x86_64/2.9.0_py39": Absolute symlink: "/home/app/.cache/pants/setup/bootstrap-Linux-x86_64/2.9.0_py39"

#13 164.7 

#13 ERROR: executor failed running [/bin/sh -c poetry install --no-dev && ./pants --no-local-cache package src/bridge:bridge-package && .venv/bin/pip install dist/bridge-*.whl]: exit code: 1
@witty-crayon-22786 do you happen to have any thoughts on ^?


02/16/2022, 6:08 PM
hm, interesting! pants should only try to resolve a symlink when it is located inside of your Pants workspace… the
directory is supposed to be located in your home directory
is the home directory the same as your git checkout in this case…? if so, you’ll probably need to do a bunch of
or `pants_ignore`ing of things
or, alternatively, have the git checkout in a subdirectory of


02/16/2022, 6:36 PM
@witty-crayon-22786 was spot on here, @limited-insurance-37393 I got it working with this little patch:
Copy code
$ docker build -t ol-infra .
[+] Building 104.9s (16/16) FINISHED                                                                                                                                                     
 => [internal] load build definition from Dockerfile                                                                                                                                0.0s
 => => transferring dockerfile: 602B                                                                                                                                                0.0s
 => [internal] load .dockerignore                                                                                                                                                   0.0s
 => => transferring context: 2B                                                                                                                                                     0.0s
 => [internal] load metadata for <|>                                                                                                                  1.1s
 => [auth] library/python:pull token for <|>                                                                                                                       0.0s
 => [stage-1 1/4] FROM <|>                                                    0.0s
 => [internal] load build context                                                                                                                                                   0.1s
 => => transferring context: 133.20kB                                                                                                                                               0.1s
 => CACHED [build 2/7] RUN apt-get update && apt-get install -q -y curl                                                                                                             0.0s
 => CACHED [build 3/7] RUN useradd -m app                                                                                                                                           0.0s
 => [build 4/7] WORKDIR /home/app/workspace                                                                                                                                         0.0s
 => CACHED [stage-1 2/4] RUN useradd -m app                                                                                                                                         0.0s
 => CACHED [stage-1 3/4] WORKDIR /home/app                                                                                                                                          0.0s
 => [build 5/7] RUN pip install --no-cache-dir poetry && poetry config true                                                                                  9.6s
 => [build 6/7] COPY ./ /home/app/workspace                                                                                                                                         0.3s
 => [build 7/7] RUN poetry install --no-dev && ./pants --no-local-cache package src/bridge:bridge-package && .venv/bin/pip install dist/bridge-*.whl                               86.3s 
 => [stage-1 4/4] COPY --from=build /home/app/workspace/.venv/ .venv                                                                                                                2.7s 
 => exporting to image                                                                                                                                                              2.9s 
 => => exporting layers                                                                                                                                                             2.8s 
 => => writing image sha256:302e9afeef0f5617dcaeb3257d9ff53471d2eec39c3d01d92f8afb418569daa9                                                                                        0.0s 
 => => naming to <|>                                                                                                                                         0.0s 
Use 'docker scan' to run Snyk tests against images to find vulnerabilities and learn how to fix them
$ git diff
diff --git a/Dockerfile b/Dockerfile
index b6d48a2..b52debd 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -2,14 +2,14 @@ FROM python:3.9-slim as build
 RUN apt-get update && apt-get install -q -y curl
 RUN useradd -m app
 USER app
-WORKDIR /home/app
+WORKDIR /home/app/workspace
 ENV PATH /bin:/usr/bin/:/usr/local/bin:/home/app/.local/bin
 RUN pip install --no-cache-dir poetry && poetry config true
-COPY ./ .
+COPY ./ /home/app/workspace
 RUN poetry install --no-dev && ./pants --no-local-cache package src/bridge:bridge-package && .venv/bin/pip install dist/bridge-*.whl
 FROM python:3.9-slim
 RUN useradd -m app
 USER app
 WORKDIR /home/app
-COPY --from=build /home/app/.venv/ .venv
+COPY --from=build /home/app/workspace/.venv/ .venv
❤️ 1


02/16/2022, 6:37 PM
Awesome, thanks!
👍 2
You will now be the first person I tag for all Docker related issues I encounter @curved-television-6568 😉
😅 1