Im installing pipenv in my docker:
RUN pip install pipenv
RUN cd /my/app/path/ && pipenv install
RUN cd /my/app/path/ && pipenv shell
The direct answer to this question is to not use shell
, but rather run
:
CMD ["pipenv", "run", "python", "my/app.py"]
If you need more flexibility, you could also pipenv run sh init.sh
, which would create a shell initialized with all the pipenv
environment variables.
I actually prefer the approach C. Sweet mentions. If you can get away with prebuilding your virtual environment and simply copying it over (setting PIPENV_VENV_IN_PROJECT
then using a nested FROM
followed by COPY --from=builder-image
), you don't need python
nor pipenv
nor pipenv
dependencies in your final container. This greatly reduces the size of the final image.
Dockerfile
:
WORKDIR /etc/service/
CMD ["sh", "/etc/service/init.sh"]
init.sh
:
source /etc/service/my/.venv/bin/activate
python my/app.py