'Deploy an editable CLI application python package in Docker
I am trying to deploy an editable CLI python package in the docker.
My package is successfully built in the docker and when I execute docker run greet-docker greet --help it shows the help message with the subcommand.
When I execute the docker run greet-docker greet say sam it should echo Hi sam but it shows the help message with the subcommand.
What did I miss!!
My code
├── tests
├── __init__
├── pyproject.toml
├── Dockerfile
├── requirements.py
├── setup.py
└── src
├── __init__.py
└── greetings.py
greetings.py
@click.group()
def main():
pass
@click.command()
@click.argument('name')
def say(name):
print(f'Hi {name}')
main.add_command(say)
if __name__ == '__main__':
main()
setup.py
package_dir={"": "src"},
packages=setuptools.find_packages(where="src"),
python_requires=">=3.6",
include_package_data=True,
entry_points={
'console_scripts': [
'greet= greetings:main'
]
}
Dockerfile
FROM python:3.6
RUN mkdir /app
COPY . /app
COPY requirements.txt /app/requirements.txt
WORKDIR /app
RUN pip install -r /app/requirements.txt
ENV PYTHONPATH=/app
RUN pip install --editable .
ENTRYPOINT [ "greet", "--help" ]
requirements.txt
click
Solution 1:[1]
This took me almost a day to figure out. Remove the ENTRYPOINT [ "greet", "--help" ] from the docker file. Whatever command we run in the editable gets overwritten by the ENTRYPOINT.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Ana |
