From 181ddd958a3518be0b722ac3d2d45dd3c6cb89d4 Mon Sep 17 00:00:00 2001 From: awieczarek Date: Sun, 20 Oct 2024 14:56:26 +0200 Subject: [PATCH] New postgres solution --- Dockerfile | 24 ++++-------------------- config.sh | 18 ++++++++++++++++++ 2 files changed, 22 insertions(+), 20 deletions(-) create mode 100644 config.sh diff --git a/Dockerfile b/Dockerfile index 5709c57..82d509b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,25 +1,9 @@ FROM gitea/gitea:1.14.5-rootless -ENV GITEA_CUSTOM=/var/lib/gitea/custom +RUN chmod a+rwx /var/lib/gitea/custom/conf/app.ini -RUN DATABASE_USER=$(echo $DATABASE_URL | cut -d ':' -f 2 | cut -d '/' -f 3) \ - && DATABASE_PASSWORD=$(echo $DATABASE_URL | cut -d ':' -f 3 | cut -d '@' -f 1) \ - && DATABASE_HOST=$(echo $DATABASE_URL | cut -d '@' -f 2 | cut -d ':' -f 1) \ - && DATABASE_PORT=$(echo $DATABASE_URL | cut -d ':' -f 4 | cut -d '/' -f 1) \ - && DATABASE_NAME=$(echo $DATABASE_URL | cut -d '/' -f 4) \ - && export GITEA__database__USER=$DATABASE_USER \ - && export GITEA__database__PASSWD=$DATABASE_PASSWORD \ - && export GITEA__database__HOST=$DATABASE_HOST \ - && export GITEA__database__NAME=$DATABASE_NAME \ - && export GITEA__database__DB_TYPE=postgres \ - && export GITEA__database__SSL_MODE=require +COPY entrypoint.sh /usr/local/bin/entrypoint.sh -ENV GITEA__database__USER=$DATABASE_USER \ - GITEA__database__PASSWD=$DATABASE_PASSWORD \ - GITEA__database__HOST=$DATABASE_HOST \ - GITEA__database__NAME=$DATABASE_NAME \ - GITEA__database__DB_TYPE=postgres \ - GITEA__database__SSL_MODE=require - -COPY app.ini /var/lib/gitea/custom/conf/app.ini +RUN chmod +x /usr/local/bin/entrypoint.sh +ENTRYPOINT ["/usr/local/bin/entrypoint.sh"] diff --git a/config.sh b/config.sh new file mode 100644 index 0000000..82bc8db --- /dev/null +++ b/config.sh @@ -0,0 +1,18 @@ +#!/bin/bash + +# Extract values from DATABASE_URL +DATABASE_USER=$(echo $DATABASE_URL | cut -d ':' -f 2 | cut -d '/' -f 3) +DATABASE_PASSWORD=$(echo $DATABASE_URL | cut -d ':' -f 3 | cut -d '@' -f 1) +DATABASE_HOST=$(echo $DATABASE_URL | cut -d '@' -f 2 | cut -d ':' -f 1) +DATABASE_PORT=$(echo $DATABASE_URL | cut -d ':' -f 4 | cut -d '/' -f 1) +DATABASE_NAME=$(echo $DATABASE_URL | cut -d '/' -f 4) + +# Export the extracted variables as environment variables +export GITEA__database__USER=$DATABASE_USER +export GITEA__database__PASSWD=$DATABASE_PASSWORD +export GITEA__database__HOST=$DATABASE_HOST +export GITEA__database__NAME=$DATABASE_NAME +export GITEA__database__DB_TYPE=postgres +export GITEA__database__SSL_MODE=require + +/usr/local/bin/gitea web -port $PORT