git: 2bc2a24eeb4b - 2026Q2 - www/gitlab: automatically generate key for registry to store docker images

From: Matthias Fechner <mfechner_at_FreeBSD.org>
Date: Sat, 06 Jun 2026 06:05:28 UTC
The branch 2026Q2 has been updated by mfechner:

URL: https://cgit.FreeBSD.org/ports/commit/?id=2bc2a24eeb4b14b1ade11fbcb45b626c00711f04

commit 2bc2a24eeb4b14b1ade11fbcb45b626c00711f04
Author:     Matthias Fechner <mfechner@FreeBSD.org>
AuthorDate: 2026-05-24 10:44:36 +0000
Commit:     Matthias Fechner <mfechner@FreeBSD.org>
CommitDate: 2026-06-06 05:40:25 +0000

    www/gitlab: automatically generate key for registry to store docker images
    
    (cherry picked from commit 46a4ec6907a93d8e27d88f667dd1e61254233f52)
---
 www/gitlab/Makefile.common |  2 +-
 www/gitlab/files/gitlab.in | 18 ++++++++++++++++++
 2 files changed, 19 insertions(+), 1 deletion(-)

diff --git a/www/gitlab/Makefile.common b/www/gitlab/Makefile.common
index f568db06dbce..51b3de7ab7c3 100644
--- a/www/gitlab/Makefile.common
+++ b/www/gitlab/Makefile.common
@@ -1,5 +1,5 @@
 GITLAB_VERSION=		19.0.0
-GITLAB_PORTREVISION=	7	# decrease this only if GITLAB_KAS_GRPC_VERSION is upgraded
+GITLAB_PORTREVISION=	8	# decrease this only if GITLAB_KAS_GRPC_VERSION is upgraded
 
 # Git version gitaly should use (from gitlab mirror)
 # Find current tag from Makefile and .gitlab-ci.yaml
diff --git a/www/gitlab/files/gitlab.in b/www/gitlab/files/gitlab.in
index b38c8d7c3a11..9abc63747bde 100644
--- a/www/gitlab/files/gitlab.in
+++ b/www/gitlab/files/gitlab.in
@@ -192,6 +192,9 @@ gitlab_init(){
     fi
   fi
 
+  # Generate gitlab registry key
+  generate_registry_key
+
   # Switch to the app_user if it is not he/she who is running the script.
   if [ "$USER" != "$app_user" ]; then
     # Regenerate the Gemfile.lock for all related products
@@ -217,6 +220,21 @@ gitlab_init(){
   check_pids
 }
 
+## Generate keys used for gitlab registry
+generate_registry_key() {
+  if [ ! -f "${app_root}/config/registry.key" ]; then
+    echo "GitLab Registry Key missing. Generating..."
+    openssl req -nodes -newkey rsa:4096 \
+	    -keyout "${app_root}/config/registry.key" \
+	    -out "${app_root}/config/registry.crt" \
+	    -x509 -days 3650 \
+	    -subj "/CN=gitlab-issuer"
+    chown git:git "${app_root}/config/registry.key" "${app_root}/config/registry.crt"
+    chmod 600 "${app_root}/config/registry.key"
+    chmod 644 "${app_root}/config/registry.crt"
+  fi
+}
+
 ## Called when we have started the two processes and are waiting for their pid files.
 wait_for_pids(){
   # We are sleeping a bit here mostly because sidekiq is slow at writing its pid