Hey all, I'm trying to build a docker image for a ...
# general
c
Hey all, I'm trying to build a docker image for a python module and am having some issues. In the past we had a massive Dockerfile, but I'm hoping I can use a python distribution to make things much easier. Here are some details about my project. Relevant project structure:
Copy code
├── 3rdparty
├── pants.toml
└── docker
    ├── ci
    ├── gather
    │   ├── BUILD
    │   ├── Dockerfile
└── src
    ├── python
    │   ├── gather
    │   │   ├── gather_folder1
    │   │   ├── gather_folder2
    │   │   ├── gather_folder3
    │   │   ├── __main__.py
    │   │   ├── gather_cli.py
    │   │   ├── BUILD
    │   │   ├── VERSION
Here is my src/python/gather/BUILD file:
Copy code
python_sources()

python_distribution(
    name = 'gather_dist',
    dependencies=[
        "src/python/gather:gather",
    ],
    repositories=[
        "@gitlab",
    ],
    provides=python_artifact(
        name="gather",
        version=env("VERSION"),
        classifiers=[
            "Programming Language :: Python :: 3.11",
        ]
    ),
    entry_points={
        "console_scripts": {"gather": "gather.gather_cli:main"},
    },
    wheel_config_settings={"--global-option": ["--python-tag", "py311"]},
)

resource(
    name="py_typed",
    source="py.typed",
)
Here is my docker/gather/BUILD file:
Copy code
docker_image(
    name="gather",
    dependencies=["src/python/gather:gather"],
)
I'd like my docker build to take my python distribution and create an entrypoint where it's specified in the BUILD file. I've read through this document and I know that I CAN use a python distribution in my docker build, but I don't know how/what that looks like. From seeing the examples using a PEX binary it seems like given our project so far, we should be able to create a Dockerfile that's just a couple lines. I've seen lots of examples that use a PEX binary but none that use a python distribution. Any help here would be greatly appreciated!