stale-nightfall-29801
10/27/2021, 11:27 AMstale-nightfall-29801
10/27/2021, 11:27 AMpython_library(
name = "bar",
sources = ["bar/*.py"]
)
python_tests(
name="test",
sources = ["test/test_*.py"]
)
pex_binary(
name="server",
entry_point="bar/server.py:main"
)
docker_image(
name='docker',
sources=["Dockerfile"]
)
stale-nightfall-29801
10/27/2021, 11:28 AMARG PY_VERSION=3.9
ARG VERSION=${PY_VERSION}-slim-buster
FROM python:${VERSION}
ENTRYPOINT [ "/bin/server" ]
COPY server.pex /bin/server
stale-nightfall-29801
10/27/2021, 11:29 AMcore
foo
bar
stale-nightfall-29801
10/27/2021, 11:30 AMbar
)
• monoreop
◦ bar
▪︎ bar (contains the code)
▪︎ test (contains the tests)
▪︎ Dockerfile
▪︎ BUILDstale-nightfall-29801
10/27/2021, 11:32 AMCOPY failed: file not found in build context or excluded by .dockerignore: stat server.pex: file does not exist
curved-television-6568
10/27/2021, 11:41 AMCOPY bar/server.pex /bin/server
stale-nightfall-29801
10/27/2021, 11:45 AMhundreds-father-404
10/27/2021, 1:05 PM./pants roots
say?stale-nightfall-29801
10/27/2021, 1:11 PM.
core
foo
bar
thirdparty/python
happy-kitchen-89482
10/27/2021, 3:49 PMdocker_image
target onto :server
? It should be inferred, but let's find outstale-nightfall-29801
10/27/2021, 3:51 PMbar
like so:
docker_image(
name='docker',
dependencies=[":bar"],
sources=["Dockerfile"]
)
stale-nightfall-29801
10/27/2021, 3:52 PMbar/server.pex
or server.pex
curved-television-6568
10/27/2021, 5:08 PMhappy-kitchen-89482
10/27/2021, 8:01 PM:server
since the pex is what the docker image consumes. And the server
target should have a dep on :bar
, since that is what it consumes in turn.happy-kitchen-89482
10/27/2021, 8:02 PMhappy-kitchen-89482
10/27/2021, 8:02 PMcurved-television-6568
10/28/2021, 12:03 PMdocker_image
to the pex binary :server
as Benjy suggested, then run ./pants -ldebug package bar:docker
and check for the log that reads "Packages for Docker image: …"
should tell you what the pex binary name is that you can use.stale-nightfall-29801
10/28/2021, 1:34 PMstale-nightfall-29801
10/28/2021, 1:34 PMpex
binary in this:stale-nightfall-29801
10/28/2021, 1:36 PMdocker_image(
name='docker_server',
dependencies=[":bar"],
sources=["Dockerfile"]
)
stale-nightfall-29801
10/28/2021, 1:40 PMcurved-television-6568
10/28/2021, 1:43 PMdependencies=[":bar"],
to dependencies=[":server"]
which is the name of your pex binary target.curved-television-6568
10/28/2021, 1:44 PMcurved-television-6568
10/28/2021, 1:45 PMstale-nightfall-29801
11/01/2021, 9:15 AMcurved-television-6568
11/01/2021, 9:20 AMcurved-television-6568
11/01/2021, 9:26 AM