From 53df38fb2b1ff395753b12c497bae82c8f0c1919 Mon Sep 17 00:00:00 2001 From: Keegan Witt Date: Wed, 16 Aug 2023 11:14:28 -0400 Subject: [PATCH] Ensure directories in .gradle are created by gradle user (closes #255) --- jdk11-alpine/Dockerfile | 9 +++++++-- jdk11-focal/Dockerfile | 9 +++++++-- jdk11/Dockerfile | 9 +++++++-- jdk17-alpine/Dockerfile | 9 +++++++-- jdk17-focal-graal/Dockerfile | 15 +++++++++------ jdk17-focal/Dockerfile | 9 +++++++-- jdk17-graal/Dockerfile | 15 +++++++++------ jdk17/Dockerfile | 9 +++++++-- jdk20-alpine/Dockerfile | 9 +++++++-- jdk20-graal/Dockerfile | 15 +++++++++------ jdk20/Dockerfile | 9 +++++++-- jdk8-focal/Dockerfile | 9 +++++++-- jdk8/Dockerfile | 9 +++++++-- 13 files changed, 97 insertions(+), 38 deletions(-) diff --git a/jdk11-alpine/Dockerfile b/jdk11-alpine/Dockerfile index 65d8a82f..5aca3131 100644 --- a/jdk11-alpine/Dockerfile +++ b/jdk11-alpine/Dockerfile @@ -45,7 +45,12 @@ RUN set -o errexit -o nounset \ && unzip gradle.zip \ && rm gradle.zip \ && mv "gradle-${GRADLE_VERSION}" "${GRADLE_HOME}/" \ - && ln -s "${GRADLE_HOME}/bin/gradle" /usr/bin/gradle \ - \ + && ln -s "${GRADLE_HOME}/bin/gradle" /usr/bin/gradle + +USER gradle + +RUN set -o errexit -o nounset \ && echo "Testing Gradle installation" \ && gradle --version + +USER root diff --git a/jdk11-focal/Dockerfile b/jdk11-focal/Dockerfile index 384b44e4..1d48a132 100644 --- a/jdk11-focal/Dockerfile +++ b/jdk11-focal/Dockerfile @@ -52,7 +52,12 @@ RUN set -o errexit -o nounset \ && unzip gradle.zip \ && rm gradle.zip \ && mv "gradle-${GRADLE_VERSION}" "${GRADLE_HOME}/" \ - && ln --symbolic "${GRADLE_HOME}/bin/gradle" /usr/bin/gradle \ - \ + && ln --symbolic "${GRADLE_HOME}/bin/gradle" /usr/bin/gradle + +USER gradle + +RUN set -o errexit -o nounset \ && echo "Testing Gradle installation" \ && gradle --version + +USER root diff --git a/jdk11/Dockerfile b/jdk11/Dockerfile index 4590a8f3..74f18776 100644 --- a/jdk11/Dockerfile +++ b/jdk11/Dockerfile @@ -52,7 +52,12 @@ RUN set -o errexit -o nounset \ && unzip gradle.zip \ && rm gradle.zip \ && mv "gradle-${GRADLE_VERSION}" "${GRADLE_HOME}/" \ - && ln --symbolic "${GRADLE_HOME}/bin/gradle" /usr/bin/gradle \ - \ + && ln --symbolic "${GRADLE_HOME}/bin/gradle" /usr/bin/gradle + +USER gradle + +RUN set -o errexit -o nounset \ && echo "Testing Gradle installation" \ && gradle --version + +USER root diff --git a/jdk17-alpine/Dockerfile b/jdk17-alpine/Dockerfile index d4f62bca..0e358471 100644 --- a/jdk17-alpine/Dockerfile +++ b/jdk17-alpine/Dockerfile @@ -45,7 +45,12 @@ RUN set -o errexit -o nounset \ && unzip gradle.zip \ && rm gradle.zip \ && mv "gradle-${GRADLE_VERSION}" "${GRADLE_HOME}/" \ - && ln -s "${GRADLE_HOME}/bin/gradle" /usr/bin/gradle \ - \ + && ln -s "${GRADLE_HOME}/bin/gradle" /usr/bin/gradle + +USER gradle + +RUN set -o errexit -o nounset \ && echo "Testing Gradle installation" \ && gradle --version + +USER root diff --git a/jdk17-focal-graal/Dockerfile b/jdk17-focal-graal/Dockerfile index 91e099a0..89b31a81 100644 --- a/jdk17-focal-graal/Dockerfile +++ b/jdk17-focal-graal/Dockerfile @@ -9,6 +9,7 @@ RUN set -o errexit -o nounset \ && groupadd --system --gid 1000 gradle \ && useradd --system --gid gradle --uid 1000 --shell /bin/bash --create-home gradle \ && mkdir /home/gradle/.gradle \ + && chown --recursive gradle:gradle /home/gradle \ \ && echo "Symlinking root Gradle cache to gradle Gradle cache" \ && ln --symbolic /home/gradle/.gradle /root/.gradle @@ -96,10 +97,12 @@ RUN set -o errexit -o nounset \ && unzip gradle.zip \ && rm gradle.zip \ && mv "gradle-${GRADLE_VERSION}" "${GRADLE_HOME}/" \ - && ln --symbolic "${GRADLE_HOME}/bin/gradle" /usr/bin/gradle \ - \ + && ln --symbolic "${GRADLE_HOME}/bin/gradle" /usr/bin/gradle + +USER gradle + +RUN set -o errexit -o nounset \ && echo "Testing Gradle installation" \ - && gradle --version \ - \ - # chown last so that it applies to /home/gradle/.gradle/native - && chown --recursive gradle:gradle /home/gradle + && gradle --version + +USER root diff --git a/jdk17-focal/Dockerfile b/jdk17-focal/Dockerfile index f861fe00..602bb00a 100644 --- a/jdk17-focal/Dockerfile +++ b/jdk17-focal/Dockerfile @@ -52,7 +52,12 @@ RUN set -o errexit -o nounset \ && unzip gradle.zip \ && rm gradle.zip \ && mv "gradle-${GRADLE_VERSION}" "${GRADLE_HOME}/" \ - && ln --symbolic "${GRADLE_HOME}/bin/gradle" /usr/bin/gradle \ - \ + && ln --symbolic "${GRADLE_HOME}/bin/gradle" /usr/bin/gradle + +USER gradle + +RUN set -o errexit -o nounset \ && echo "Testing Gradle installation" \ && gradle --version + +USER root diff --git a/jdk17-graal/Dockerfile b/jdk17-graal/Dockerfile index b3b87449..969d9d85 100644 --- a/jdk17-graal/Dockerfile +++ b/jdk17-graal/Dockerfile @@ -9,6 +9,7 @@ RUN set -o errexit -o nounset \ && groupadd --system --gid 1000 gradle \ && useradd --system --gid gradle --uid 1000 --shell /bin/bash --create-home gradle \ && mkdir /home/gradle/.gradle \ + && chown --recursive gradle:gradle /home/gradle \ \ && echo "Symlinking root Gradle cache to gradle Gradle cache" \ && ln --symbolic /home/gradle/.gradle /root/.gradle @@ -96,10 +97,12 @@ RUN set -o errexit -o nounset \ && unzip gradle.zip \ && rm gradle.zip \ && mv "gradle-${GRADLE_VERSION}" "${GRADLE_HOME}/" \ - && ln --symbolic "${GRADLE_HOME}/bin/gradle" /usr/bin/gradle \ - \ + && ln --symbolic "${GRADLE_HOME}/bin/gradle" /usr/bin/gradle + +USER gradle + +RUN set -o errexit -o nounset \ && echo "Testing Gradle installation" \ - && gradle --version \ - \ - # chown last so that it applies to /home/gradle/.gradle/native - && chown --recursive gradle:gradle /home/gradle + && gradle --version + +USER root diff --git a/jdk17/Dockerfile b/jdk17/Dockerfile index 002ae401..c7ea5cec 100644 --- a/jdk17/Dockerfile +++ b/jdk17/Dockerfile @@ -52,7 +52,12 @@ RUN set -o errexit -o nounset \ && unzip gradle.zip \ && rm gradle.zip \ && mv "gradle-${GRADLE_VERSION}" "${GRADLE_HOME}/" \ - && ln --symbolic "${GRADLE_HOME}/bin/gradle" /usr/bin/gradle \ - \ + && ln --symbolic "${GRADLE_HOME}/bin/gradle" /usr/bin/gradle + +USER gradle + +RUN set -o errexit -o nounset \ && echo "Testing Gradle installation" \ && gradle --version + +USER root diff --git a/jdk20-alpine/Dockerfile b/jdk20-alpine/Dockerfile index 16d6d8e5..d45df564 100644 --- a/jdk20-alpine/Dockerfile +++ b/jdk20-alpine/Dockerfile @@ -45,7 +45,12 @@ RUN set -o errexit -o nounset \ && unzip gradle.zip \ && rm gradle.zip \ && mv "gradle-${GRADLE_VERSION}" "${GRADLE_HOME}/" \ - && ln -s "${GRADLE_HOME}/bin/gradle" /usr/bin/gradle \ - \ + && ln -s "${GRADLE_HOME}/bin/gradle" /usr/bin/gradle + +USER gradle + +RUN set -o errexit -o nounset \ && echo "Testing Gradle installation" \ && gradle --version + +USER root diff --git a/jdk20-graal/Dockerfile b/jdk20-graal/Dockerfile index 379b8339..a30a150a 100644 --- a/jdk20-graal/Dockerfile +++ b/jdk20-graal/Dockerfile @@ -9,6 +9,7 @@ RUN set -o errexit -o nounset \ && groupadd --system --gid 1000 gradle \ && useradd --system --gid gradle --uid 1000 --shell /bin/bash --create-home gradle \ && mkdir /home/gradle/.gradle \ + && chown --recursive gradle:gradle /home/gradle \ \ && echo "Symlinking root Gradle cache to gradle Gradle cache" \ && ln --symbolic /home/gradle/.gradle /root/.gradle @@ -96,10 +97,12 @@ RUN set -o errexit -o nounset \ && unzip gradle.zip \ && rm gradle.zip \ && mv "gradle-${GRADLE_VERSION}" "${GRADLE_HOME}/" \ - && ln --symbolic "${GRADLE_HOME}/bin/gradle" /usr/bin/gradle \ - \ + && ln --symbolic "${GRADLE_HOME}/bin/gradle" /usr/bin/gradle + +USER gradle + +RUN set -o errexit -o nounset \ && echo "Testing Gradle installation" \ - && gradle --version \ - \ - # chown last so that it applies to /home/gradle/.gradle/native - && chown --recursive gradle:gradle /home/gradle + && gradle --version + +USER root diff --git a/jdk20/Dockerfile b/jdk20/Dockerfile index 67c30516..367487cd 100644 --- a/jdk20/Dockerfile +++ b/jdk20/Dockerfile @@ -52,7 +52,12 @@ RUN set -o errexit -o nounset \ && unzip gradle.zip \ && rm gradle.zip \ && mv "gradle-${GRADLE_VERSION}" "${GRADLE_HOME}/" \ - && ln --symbolic "${GRADLE_HOME}/bin/gradle" /usr/bin/gradle \ - \ + && ln --symbolic "${GRADLE_HOME}/bin/gradle" /usr/bin/gradle + +USER gradle + +RUN set -o errexit -o nounset \ && echo "Testing Gradle installation" \ && gradle --version + +USER root diff --git a/jdk8-focal/Dockerfile b/jdk8-focal/Dockerfile index e541163f..a9734503 100644 --- a/jdk8-focal/Dockerfile +++ b/jdk8-focal/Dockerfile @@ -52,7 +52,12 @@ RUN set -o errexit -o nounset \ && unzip gradle.zip \ && rm gradle.zip \ && mv "gradle-${GRADLE_VERSION}" "${GRADLE_HOME}/" \ - && ln --symbolic "${GRADLE_HOME}/bin/gradle" /usr/bin/gradle \ - \ + && ln --symbolic "${GRADLE_HOME}/bin/gradle" /usr/bin/gradle + +USER gradle + +RUN set -o errexit -o nounset \ && echo "Testing Gradle installation" \ && gradle --version + +USER root diff --git a/jdk8/Dockerfile b/jdk8/Dockerfile index f1ecba96..98e1c123 100644 --- a/jdk8/Dockerfile +++ b/jdk8/Dockerfile @@ -52,7 +52,12 @@ RUN set -o errexit -o nounset \ && unzip gradle.zip \ && rm gradle.zip \ && mv "gradle-${GRADLE_VERSION}" "${GRADLE_HOME}/" \ - && ln --symbolic "${GRADLE_HOME}/bin/gradle" /usr/bin/gradle \ - \ + && ln --symbolic "${GRADLE_HOME}/bin/gradle" /usr/bin/gradle + +USER gradle + +RUN set -o errexit -o nounset \ && echo "Testing Gradle installation" \ && gradle --version + +USER root