Does anyone know why the Docker container would be...
# general
Does anyone know why the Docker container would be picking up python3.10 instead of 3.9, given that inside the container should only be 3.9. This worked a couple months ago before I installed 3.10 as well on my system. I'm guessing there is a conflict between the Python installed in the container vs the one used to bundle the PEX? That seems like the most obvious first step for me to test against tonight, but if so - is this known? Note: Still on 2.9.x in this project
Copy code
FROM nginx/unit:1.26.1-python3.9
COPY backend/apigateway/config.json /docker-entrypoint.d/config.json

COPY backend/apigateway/apigateway.pex /apigateway.pex
RUN PEX_TOOLS=1 /apigateway.pex venv /app
Copy code
16:58:54.10 [ERROR] 1 Exception encountered:

  ProcessExecutionFailure: Process 'Building docker image apigateway-container:latest' failed with exit code 1.

#1 [internal] load build definition from Dockerfile
#1 sha256:dd05a256bf0a700475eee66e2bab7b409dfa252f9d5b9c512a20570645e0a542
#1 transferring dockerfile: 259B done
#1 DONE 0.0s

#2 [internal] load .dockerignore
#2 sha256:61b1ab8a8d14acfdedce93b66af15c72891c34a5899e37ffb9c6f9628f63a840
#2 transferring context: 2B done
#2 DONE 0.0s

#3 [internal] load metadata for <|>
#3 sha256:29341916069df22232847ba48ae4db61f24890c7b9ecbd26801c5739bc6e7b2b
#3 DONE 0.2s

#4 [1/5] FROM <|>
#4 sha256:cc3caab62ea82004335d0ff18f5f40e1ae0b0ee6932679be1c7144e8ad4072f7
#4 DONE 0.0s

#5 [internal] load build context
#5 sha256:f07b09714c1c81e44b9534d3b0fdf55d4bbbd51b1d5d730df0f29b1d51ed34a4
#5 transferring context: 17.83MB 4.6s
#5 transferring context: 20.00MB 5.4s done
#5 DONE 5.4s

#6 [2/5] COPY backend/apigateway/config.json /docker-entrypoint.d/config.json
#6 sha256:8663783c824d8e671e1c968f89cc4d12ba24ea91acd6a8508e756eabd479b8bf

#7 [3/5] COPY backend/apigateway/apigateway.pex /apigateway.pex
#7 sha256:ba50617df623b8c168123d021d61454e8f26c99e35650d16eb3d614370e5bd53

#8 [4/5] RUN PEX_TOOLS=1 /apigateway.pex venv /app
#8 sha256:caaa14b420888270c8c3bff91403db9f760633ee2c61e9340a947bc1761729cb
#8 0.639 /usr/bin/env: 'python3.10': No such file or directory
#8 ERROR: executor failed running [/bin/sh -c PEX_TOOLS=1 /apigateway.pex venv /app]: exit code: 127
 > [4/5] RUN PEX_TOOLS=1 /apigateway.pex venv /app:
executor failed running [/bin/sh -c PEX_TOOLS=1 /apigateway.pex venv /app]: exit code: 127
Forgetting the Docker container, try
head -1 your.pex
on your machine. You'll find an enlightening shebang. You need to be either setting a custom, more flexible shebang (both Pants and Pex have options for this) or explicitly building the PEX file using python 3.9 - there are several ways to do this via Pants or via Pex. I can flesh out details if you get stuck.
Alternatively, you can always explicitly run a PEX with a manually selected interpreter:
/this/python my.pex
👍 1
I'll try this out in a bit and see what the options that work are
As expected, the pex was expecting 3.10 - which I think is what Pants is currently using, which would make sense. Just a surprising error to run into on a project that'd previously been running
Okay, confirmed that the issue was Pants packaging against Python 3.10, and then my container being too old. Actually, amusingly led to a dependency waterfall with my nginx config, dockerfiles, pex, and pex platforms 🤦‍♂️