ancient-rose-27306
08/25/2022, 8:19 PMpex_binary()
with following definition:
pex_binary(
name="greeter_server",
entry_point="greeter_server.py:main",
)
It builds fine and I am able to use it on my local machine. Moving a step ahead, I am building a docker_image()
with this pex:
docker_image(
name="docker-server",
dependencies=[":greeter_server"],
)
and the contents of Dockerfile are:
FROM python:3.7
RUN mkdir /app
WORKDIR /app
COPY src.server/greeter_server.pex /app/
EXPOSE 50051
CMD ["/app/greeter_server.pex"]
The Docker build works fine too but when I do docker run -it docker-server
, I end up in an error and the pex doesn’t execute:
(pants) [root@9a5752857756 pants-training]# docker run -it docker-server
Failed to find compatible interpreter on path /usr/local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin.
Examined the following interpreters:
1.) /usr/local/bin/python3.7 CPython==3.7.13
2.) /usr/bin/python3.9 CPython==3.9.2
No interpreter compatible with the requested constraints was found:
A distribution for grpcio could not be resolved for /usr/local/bin/python3.7.
Found 1 distribution for grpcio that do not apply:
1.) The wheel tags for grpcio 1.47.0 are cp37-cp37m-macosx_10_10_x86_64 which do not match the supported tags of /usr/local/bin/python3.7:
cp37-cp37m-manylinux_2_31_x86_64
... 535 more ...
(pants) [root@9a5752857756 pants-training]#
I could provide the platforms
arg for pex_binary()
target but want to understand the reason that pex was working directly but not inside a container on the same machine. Could you please help?hundreds-father-404
08/25/2022, 8:21 PMplatforms
ancient-rose-27306
08/25/2022, 8:23 PMplatforms=['current']
would accomplish what I am trying to do?hundreds-father-404
08/25/2022, 8:23 PMlinux_x86_64-cp-37-cp37m
ancient-rose-27306
08/25/2022, 8:24 PMhundreds-father-404
08/25/2022, 8:31 PMplatforms
allows Pex/pip to be build for foreign platforms. So even though you're building on your mac, you can build it to work with Linuxancient-rose-27306
08/25/2022, 8:33 PMhundreds-father-404
08/25/2022, 8:35 PMplatforms
• Pants copies that PEX into the Docker image, which will be Linux because it's Docker
• When you run that Docker image, it will thus be Linux and will need a Linux-compatible Pexancient-rose-27306
08/25/2022, 8:36 PMpackage
goal doesn’t run inside a container.