Hi, I have a simple question. Why <the dockerfile ...
# general
l
Hi, I have a simple question. Why the dockerfile in the pants's example-docker copy pex file from
src.python.hello_world
and not
dist/src.python.hello_world
? If my understanding is correct, pants package will generate pex file to
dist
directory. Thank you.
g
All the building happens in a sandbox.
dist
is only used when you package to "leave" Pants. For the most part, the path in the sandbox is the same as it is inside
dist
though.
l
@gorgeous-winter-99296 Thank you for the answer. So if I have this CI workflow:
Copy code
- name: Build package
        run: |
          pants --changed-since="${{ env.REFERENCE_COMMIT }}" --changed-dependents=transitive package
- name: Build and push image
      uses: docker/build-push-action@v4
      with:
        file: ${{ inputs.dockerfile }}
and the entry point to my code is in
src/python/hello_world
, should I use the same content as the dockerfile in that pants' example repository above? i.e. use
Copy code
COPY src.python.hello_world/main.pex /bin
and not
Copy code
COPY dist/src.python.hello_world/main.pex /bin
g
Since the docker build happens outside pants, you'd read from
dist
. Just remember that the pex file may not exist since you're applying filtering.
l
I see! I'll remove the filter for the package and read the pex file from
dist
. The build and push process is something handled by another team so I cannot really use pants to do it. Thank you very much for the answer!