From 9756ea5d0e827bb1e8abb205bac939d159265d62 Mon Sep 17 00:00:00 2001 From: Lexie Malina Date: Mon, 9 Dec 2024 09:53:30 -0600 Subject: [PATCH] GH-2303 Migrate Docker images to Ubuntu and Eclipse Temurin and change user/group id (Refs #2288) * Add .dockerignore to help improve container image cache hits when building locally. * POSIX Shell compatibility in preparation for future Alpine based images. * Add Dockerfile migration warning and change user and group id to 977. * Use Ubuntu Noble with Eclipe Temurin based images for build and run This is a migration point between the deprecated `openjdk` images and proposed change to using Alpine based images. --- .dockerignore | 17 +++++++++++++++++ Dockerfile | 38 ++++++++++++++++++++++---------------- entrypoint.sh | 22 ++++++++++++++++++---- 3 files changed, 57 insertions(+), 20 deletions(-) create mode 100644 .dockerignore diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 000000000..ce3fcede7 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,17 @@ +# Per developer files +build/ +.idea/ +.gradle/ +.kotlin/ + +# Dockerfile related files do not need to be included +Dockerfile +docker-compose.yml +.env + +# Not used in running application +reposilite-site +reposilite-test +reposilite-plugins +.github/ +.codecov.yml diff --git a/Dockerfile b/Dockerfile index 6da75680b..eda4521fc 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,15 +1,15 @@ +# syntax=docker.io/docker/dockerfile:1.7-labs + # Build stage -FROM openjdk:21-slim AS build -COPY . /home/reposilite-build +FROM eclipse-temurin:21-jdk-noble AS build +COPY --exclude=entrypoint.sh . /home/reposilite-build WORKDIR /home/reposilite-build -RUN \ - rm -rf reposilite-frontend/node_modules -RUN \ - apt-get update; apt-get install -y curl -RUN \ - export GRADLE_OPTS="-Djdk.lang.Process.launchMechanism=vfork" && \ - chmod +x gradlew && \ - bash gradlew :reposilite-backend:shadowJar --no-daemon --stacktrace + +# The below line will show an Error in some IDE's, It is valid Dockerfile. +RUN --mount=type=cache,target=/root/.gradle <&2 + printf "\033[1;31mAfter 3.6.0 docker installations with user id of 999 will no longer work.\033[0m\n" 1>&2 + printf "\033[1;31mFor more information see: https://github.com/dzikoysk/reposilite/issues/2288\033[0m\n" 1>&2 + printf "\033[1;31mIF YOU DOWNGRADE PAST THIS POINT \"Hic sunt dracones\"\033[0m\n" 1>&2 + fi + # GH-1634: support custom user and group ids - GROUP_ID="${PGID:-999}" + GROUP_ID="${PGID:-977}" if ! grep -q "^reposilite" /etc/group; then addgroup --gid "$GROUP_ID" reposilite; fi - USER_ID="${PUID:-999}" + USER_ID="${PUID:-977}" if ! grep "^reposilite" /etc/passwd; then adduser --system -uid "$USER_ID" --ingroup reposilite --shell /bin/sh reposilite;