|  | 
|  | 1 | +# | 
|  | 2 | +# Contributed by: James E. King III (@jeking3) <jking@apache.org> | 
|  | 3 | +# | 
|  | 4 | +# This Dockerfile creates an Ubuntu Xenial build environment | 
|  | 5 | +# that can run the same test suite as Travis CI. | 
|  | 6 | +# | 
|  | 7 | + | 
|  | 8 | +FROM ubuntu:xenial | 
|  | 9 | +MAINTAINER James E. King III <jking@apache.org> | 
|  | 10 | +ENV CONTAINER_USER=user | 
|  | 11 | +ENV DEBIAN_FRONTEND noninteractive | 
|  | 12 | + | 
|  | 13 | +RUN apt-get update && \ | 
|  | 14 | +    apt-get install -y --no-install-recommends \ | 
|  | 15 | +      add-apt-key \ | 
|  | 16 | +      apt \ | 
|  | 17 | +      apt-transport-https \ | 
|  | 18 | +      apt-utils \ | 
|  | 19 | +      ca-certificates \ | 
|  | 20 | +      curl \ | 
|  | 21 | +      git \ | 
|  | 22 | +      net-tools \ | 
|  | 23 | +      openssh-client \ | 
|  | 24 | +      sudo \ | 
|  | 25 | +      vim \ | 
|  | 26 | +      wget | 
|  | 27 | + | 
|  | 28 | +RUN add-apt-key -v 6A755776 -k keyserver.ubuntu.com && \ | 
|  | 29 | +    echo "deb http://ppa.launchpad.net/deadsnakes/ppa/ubuntu xenial main" >> /etc/apt/sources.list && \ | 
|  | 30 | +    apt-get update && \ | 
|  | 31 | +    apt-get install -y --install-recommends python2.7 python3.4 python3.5 python3.6 python3.7 && \ | 
|  | 32 | +    update-alternatives --install /usr/bin/python3 python3 /usr/bin/python2.7 27 && \ | 
|  | 33 | +    update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.4 34 && \ | 
|  | 34 | +    update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.5 35 && \ | 
|  | 35 | +    update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.6 36 && \ | 
|  | 36 | +    update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.7 37 | 
|  | 37 | + | 
|  | 38 | +RUN curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py && \ | 
|  | 39 | +    python3 get-pip.py && \ | 
|  | 40 | +    pip3 install tox | 
|  | 41 | + | 
|  | 42 | +# Clean up | 
|  | 43 | +RUN rm -rf /var/cache/apt/* && \ | 
|  | 44 | +    rm -rf /var/lib/apt/lists/* && \ | 
|  | 45 | +    rm -rf /tmp/* && \ | 
|  | 46 | +    rm -rf /var/tmp/* | 
|  | 47 | + | 
|  | 48 | +################################################################# | 
|  | 49 | +# Build as a regular user | 
|  | 50 | +# Credit: https://github.com/delcypher/docker-ubuntu-cxx-dev/blob/master/Dockerfile | 
|  | 51 | +# License: None specified at time of import | 
|  | 52 | +# Add non-root user for container but give it sudo access. | 
|  | 53 | +# Password is the same as the username | 
|  | 54 | +RUN useradd -m ${CONTAINER_USER} && \ | 
|  | 55 | +    echo ${CONTAINER_USER}:${CONTAINER_USER} | chpasswd && \ | 
|  | 56 | +    echo "${CONTAINER_USER}  ALL=(root) ALL" >> /etc/sudoers | 
|  | 57 | +RUN chsh --shell /bin/bash ${CONTAINER_USER} | 
|  | 58 | +USER ${CONTAINER_USER} | 
|  | 59 | +################################################################# | 
|  | 60 | + | 
|  | 61 | +# The test suite will not tolerate running against a branch that isn't "master", so | 
|  | 62 | +# check out the project to a well-known location that can be used by the test suite. | 
|  | 63 | +# This has the added benefit of protecting the local repo fed into the container | 
|  | 64 | +# as a volume from getting destroyed by a bug exposed by the test suite. :) | 
|  | 65 | +ENV TRAVIS=ON | 
|  | 66 | +RUN git clone --recursive https://github.com/gitpython-developers/GitPython.git /home/${CONTAINER_USER}/testrepo && \ | 
|  | 67 | +    cd /home/${CONTAINER_USER}/testrepo && \ | 
|  | 68 | +    ./init-tests-after-clone.sh | 
|  | 69 | +ENV GIT_PYTHON_TEST_GIT_REPO_BASE=/home/${CONTAINER_USER}/testrepo | 
|  | 70 | +ENV TRAVIS= | 
|  | 71 | + | 
|  | 72 | +# Ensure any local pip installations get on the path | 
|  | 73 | +ENV PATH=/home/${CONTAINER_USER}/.local/bin:${PATH} | 
|  | 74 | + | 
|  | 75 | +# Set the global default git user to be someone non-descript | 
|  | 76 | +RUN git config --global user.email ci@gitpython.org && \ | 
|  | 77 | +    git config --global user.name "GitPython CI User" | 
|  | 78 | + | 
0 commit comments