From 6da0421b8132a67915308c4ab17d7464b6359317 Mon Sep 17 00:00:00 2001 From: Saejin Mahlau-Heinert Date: Fri, 18 Sep 2020 14:03:18 -0400 Subject: [PATCH] Update Dockerfile for better compatibility This includes: - Installing more recent Gradle - Running setup commands in a bash login shell - Pinning the Poetry version - a few other minor tweaks --- Dockerfile | 32 +++++++++++++++++++++----------- 1 file changed, 21 insertions(+), 11 deletions(-) diff --git a/Dockerfile b/Dockerfile index 8da311d..e0a5ea7 100644 --- a/Dockerfile +++ b/Dockerfile @@ -9,10 +9,7 @@ ENV PROJECT_DIR=/project/ # Expecting volume mount at ENV GATORGRADER_DIR=/root/.local/share/ -# Set Python version -ARG PYTHON_VERSION='3.8.5' - -# Configure environment variables for Python +# Configure environment variables ENV PYTHONUNBUFFERED=1 \ # Prevent Python from creating .pyc files PYTHONDONTWRITEBYTECODE=1 \ @@ -36,10 +33,15 @@ ENV PYTHONUNBUFFERED=1 \ # Specify the paths for using requirements and virtual environments; # this is where the requirements + virtual environment will live PYSETUP_PATH="/opt/pysetup" \ - VENV_PATH="/opt/pysetup/.venv" + VENV_PATH="/opt/pysetup/.venv" \ + # Specify the version of Gradle + GRADLE_VERSION=5.4.1 \ + # Specify the home directory of Gradle + GRADLE_HOME="/opt/gradle-5.4.1" # Pre-pend Poetry's home and the .venv directory to PATH -ENV PATH="$POETRY_HOME/bin:$VENV_PATH/bin:$PATH:" +# Pre-pend Gradle's bin to PATH +ENV PATH="$POETRY_HOME/bin:$VENV_PATH/bin:$GRADLE_HOME/bin:$PATH" # Define the project directory as the working directory WORKDIR ${PROJECT_DIR} @@ -47,18 +49,21 @@ WORKDIR ${PROJECT_DIR} # Specify shared volume storage in the container VOLUME ${PROJECT_DIR} ${GATORGRADER_DIR} -# hadolint ignore=DL3008,DL3013,DL3015,DL3016,DL3018,DL3028 -RUN set -ex && echo "Installing Packages with apt-get..." \ +# Tell Docker to use a bash login shell for RUN commands +SHELL ["/bin/bash", "--login", "-c"] + +# hadolint ignore=DL3008,DL3013,DL3016,DL3018,DL3028 +RUN set -e && echo "Installing Packages with apt-get..." \ && export DEBIAN_FRONTEND=noninteractive \ && apt-get update \ - && apt-get -y install --no-install-recommends bash git ruby openjdk-11-jdk gradle npm \ + && apt-get -y install --no-install-recommends ruby openjdk-11-jdk npm \ && apt-get clean \ && rm -rf /var/lib/apt/lists/* \ && echo "Installing Pandoc..." \ && wget -O /pandoc.tar.gz https://github.com/jgm/pandoc/releases/download/2.10.1/pandoc-2.10.1-linux-amd64.tar.gz \ && tar -C /usr --strip-components 1 -xzvf /pandoc.tar.gz && rm /pandoc.tar.gz \ && echo "Testing Pandoc..." \ - && /usr/bin/pandoc --version \ + && pandoc --version \ && echo "Installing Markdown Linter called mdl..." \ && gem install mdl \ && echo "Installing HTML Linter called htmlhint..." \ @@ -69,12 +74,17 @@ RUN set -ex && echo "Installing Packages with apt-get..." \ && echo "Testing Pip..." && pip --version \ && echo "Installing Poetry..." \ && wget -O /get-poetry.py https://raw.githubusercontent.com/sdispater/poetry/master/get-poetry.py \ - && python /get-poetry.py && rm /get-poetry.py \ + && python /get-poetry.py --version $POETRY_VERSION && rm /get-poetry.py \ + && source $POETRY_HOME/env \ && echo "Testing Poetry..." && poetry --version \ && echo "Installing Pipenv..." \ && pip install pipenv \ && echo "Testing Pipenv..." && pipenv --version \ + && echo "Installing Gradle..." \ + && wget -O /gradle-bin.zip "https://services.gradle.org/distributions/gradle-${GRADLE_VERSION}-bin.zip" \ + && unzip /gradle-bin.zip -d /opt && rm /gradle-bin.zip \ && echo "Configuring Gradle..." \ + && export PATH="$GRADLE_HOME/bin:$PATH" \ && mkdir -p /root/.gradle/ \ && echo "org.gradle.daemon=true" >> /root/.gradle/gradle.properties \ && echo "systemProp.org.gradle.internal.launcher.welcomeMessageEnabled=false" >> /root/.gradle/gradle.properties \