This is an automated email from the ASF dual-hosted git repository. brondsem pushed a commit to branch db/8489 in repository https://gitbox.apache.org/repos/asf/allura.git
commit 480daebd5ec7679ebb84df0c9cbf1ac20d1b9037 Author: Dave Brondsema <[email protected]> AuthorDate: Fri Jan 13 13:29:16 2023 -0500 [#8489] allow docker image to build with parameterized python version --- Allura/docs/getting_started/installation.rst | 4 ++++ Dockerfile | 13 +++++++++---- scripts/init-docker-dev.sh | 6 +++--- 3 files changed, 16 insertions(+), 7 deletions(-) diff --git a/Allura/docs/getting_started/installation.rst b/Allura/docs/getting_started/installation.rst index e0b3df4f5..c680d93f9 100644 --- a/Allura/docs/getting_started/installation.rst +++ b/Allura/docs/getting_started/installation.rst @@ -65,6 +65,10 @@ Build/fetch all required images: docker-compose build +.. note:: + + You can override the python version by adding :code:`--build-arg PY_VERSION=3.8` for example. + Python and JS package setup (and first containers started): .. code-block:: bash diff --git a/Dockerfile b/Dockerfile index 2b2a9c0c7..07519cb95 100644 --- a/Dockerfile +++ b/Dockerfile @@ -17,8 +17,10 @@ FROM ubuntu:18.04 +ARG PY_VERSION=3.7 + # Ubunutu 18.04's latest python is 3.6 (and Ubuntu 20.04's is 3.8) -# In order to get python3.7, we must add the deadsnakes apt repo, and install 3.7 specifically +# In order to get a different python, we must add the deadsnakes apt repo, and install a specific version RUN apt-get update \ && apt-get install software-properties-common -y --no-install-recommends \ && add-apt-repository ppa:deadsnakes/ppa -y \ @@ -29,9 +31,9 @@ RUN apt-get upgrade -y git RUN DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ git-core \ - python3.7 \ - python3.7-venv \ - python3.7-dev \ + python$PY_VERSION \ + python$PY_VERSION-venv \ + python$PY_VERSION-dev \ gcc \ libmagic1 \ libssl-dev \ @@ -49,6 +51,9 @@ RUN DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ sudo \ && rm -rf /var/lib/apt/lists/* +# save env var, so init-docker-dev.sh can use it +ENV PYTHON_EXE=python$PY_VERSION + # up-to-date version of node & npm RUN curl --silent --location https://deb.nodesource.com/setup_10.x | sudo bash - && \ DEBIAN_FRONTEND=noninteractive apt-get install --yes --no-install-recommends nodejs diff --git a/scripts/init-docker-dev.sh b/scripts/init-docker-dev.sh index 325d09ff4..39001c1f0 100755 --- a/scripts/init-docker-dev.sh +++ b/scripts/init-docker-dev.sh @@ -40,16 +40,16 @@ cp /allura/Allura/allura/public/nf/favicon.ico /allura-data/www-misc/favicon.ico rm -rf /allura-data/virtualenv if [ ! -e /allura-data/virtualenv ]; then echo -e "Creating virtualenv\n" - python3.7 -m venv /allura-data/virtualenv + PYTHON_EXE="${PYTHON_EXE:-python3.7}" # should always be set from Dockerfile, but set default value just in case + $PYTHON_EXE -m venv /allura-data/virtualenv /allura-data/virtualenv/bin/pip install -U pip /allura-data/virtualenv/bin/pip install -U wheel curl https://raw.githubusercontent.com/reviewboard/pysvn-installer/master/install.py | /allura-data/virtualenv/bin/python echo # just a new line fi -source /allura-data/virtualenv/bin/activate echo -e "Installing python packages\n" -pip install -q -r requirements.txt +/allura-data/virtualenv/bin/pip install -q -r requirements.txt /allura/rebuild-all.bash echo
