• Ian Stuart's picture

    Pip install from git in Docker

    Ian Stuart / March 27, 2019
  • Following on from my article about pip installing development code, I thought I'd also share the various ways of installing from a get server.

    Installing from a GitLab commit-point

    • You may need to have a deploy token, or username & password for the repo
    • You need to have set up the setup code in the repo being installed

    In the Dockerfile, install from the commit SHA code:

        RUN pip install -e git+https://[user:credentials@]githost.example.com/group/project@commit-sha#egg=project
    

    Installing from a known branch or tag

    Once a plugin is mature, it will have a release tag and/or master branch. Personally, I prefer to install service-level code from a tag rather than the HEAD of the master branch (as that may move)

        RUN pip install -e git+https://[user:credentials@]githost.example.com/group/project@tag#egg=project
    

    Installing some extensions from a set of many

    Sometimes we only want to install just a few extensions from a larger distribution set.

    Something like this will help:

        WORKDIR /srv/
        RUN git clone -b '<point>' --single-branch --depth 1 https://[user:credentials@]githost.example.com/group/project
        RUN pip install -e /srv/project/funky_extension_43
    

    where <point> can be a commit SHA, a branch name, or even a tag