pyenv / pyenv-installer

This tool is used to install `pyenv` and friends.
MIT License
3.96k stars 428 forks source link

How to add this into a Dockerfile #98

Closed escorciav closed 4 years ago

escorciav commented 4 years ago

Hi guys,

I want to add pyenv into a 3rdparty project using Docker. Do you mind to gimme a hand?

Thanks in advance!

P.D. I know that it's not the principle solution, but I'm not familiar with the 3rdparty project and only know the basics of Docker. I do use Unix, but not very familiar with ubuntu (distro used in the Dockerfile of the project 😓)

escorciav commented 4 years ago

I found this Dockerfile, but it looks a bit old.

escorciav commented 4 years ago

this might be a better starting point

robnagler commented 4 years ago

@escorciav some tips on Docker:

  1. Write a single script, e.g. build.sh
  2. Test it by running docker interactively, e.g. docker run -it -v $PWD:/vagrant <image> bash
  3. Use a very simple Dockerfile to build, once you have debugged the script, e.g.
    FROM <image>
    USER root
    ADD . /vagrant
    RUN build.sh

Note that I use /vagrant here, because I work primary in VMs. We use the same scripts to build Vagrant boxes.

escorciav commented 4 years ago

Thanks for getting back.... based on the repo that I mentioned above, I used the snipped below in my Dockerfile. It did the job for me:

ENV PYENV_ROOT="/data/.pyenv" \
    PATH="/data/.pyenv/bin:/data/.pyenv/shims:$PATH"

RUN mkdir -p /data

WORKDIR /data

RUN curl -L https://github.com/pyenv/pyenv-installer/raw/master/bin/pyenv-installer | bash

RUN pyenv update \
    && pyenv install 3.6.8 \
    && pyenv virtualenv 3.6.8 general \
    && pyenv global general

I let the image building... 🤞 the other packages (build by cmake) will find the appropriate Python.h.

escorciav commented 4 years ago

Closing the issue as it looks out of the scope of this repo. Sorry about that.

Stay safe and healthy!

joshfriend commented 4 years ago

No worries! Thank's for posting your solution :)

escorciav commented 4 years ago

Minor update the snippet above likely built my image successfully (opencv, and other gazzilion of dependencies 😅 ).

I only have an issue with a particular dependency (decord) where the Dockerfile is trying to do python setup.py install --user. Even in that case pyenv pointed towards setuptools documentation for alternatives on how to build it 👏 . I skipped it as I don't plan to use that for the time being.