Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tips on deploying a CLI inside the container #622

Closed
francescobianca opened this issue Jan 31, 2022 · 2 comments
Closed

Tips on deploying a CLI inside the container #622

francescobianca opened this issue Jan 31, 2022 · 2 comments

Comments

@francescobianca
Copy link

Hi,
I have developed my CLI and locally everything is ok. Now I would like to deploy it via docker container. However, I can't get the .rc file for auto-complete to work (I don't want to source file.rc every time inside the container). Do you have experience with this?

System Information

  • Cement Version: Cement Framework 3.0.6
  • Python Version: Python 3.9.10
  • Operating System and Version: Platform Linux-5.13.0-1028-oem-x86_64-with

Example

Docker file:

FROM python:3.9-alpine
LABEL MAINTAINER=
ENV PS1=

WORKDIR /src
COPY . /src

RUN apk add --no-cache bash
SHELL ["/bin/bash", "-c"]

RUN pip install --no-cache-dir -r requirements.txt \
    && python setup.py install \
    && source file.rc

WORKDIR /

ENTRYPOINT ["/bin/bash"]

I started the container like this:

$ docker run -it --rm my_image

But autocomplete is not active. I have to manually launch:

$ source src/file.rc

This mechanism is not the best in the usability of the application. Suggestions?

Thanks in advance

@derks
Copy link
Member

derks commented Jan 31, 2022

@francescobianca would you mind sharing your autocomplete config (or an example of it)? Wouldn't mind adding this to the docs.

@derks derks reopened this Jan 31, 2022
@francescobianca
Copy link
Author

Hi @derks no problem,

I defined an .rc file in the root of the project. Something similar to this.

To have it automatically launch inside the container:

FROM python:3.9-alpine
LABEL MAINTAINER="..."
ENV PS1="\[\e[0;33m\]|> ... <| \[\e[1;35m\]\W\[\e[0m\] \[\e[0m\]# "

WORKDIR /src
COPY . /src

RUN apk add --no-cache bash
SHELL ["/bin/bash", "-c"]

RUN pip install --no-cache-dir -r requirements.txt \
    && python setup.py install \
    && echo "source /src/file.rc" >> ~/.bashrc

WORKDIR /

CMD ["/bin/bash"]

LABEL ...

And the container run:

$ docker run -it --rm my_image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants