diff --git a/Dockerfile b/Dockerfile index ee8b760..735fe35 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,18 +2,16 @@ FROM gitea/gitea:1.14.5-rootless ENV GITEA_CUSTOM=/var/lib/gitea/custom -RUN eval $(echo $DATABASE_URL | sed -e 's/^postgres:\/\///' -e 's/@/ /' -e 's/:/ /' -e 's/\// /') \ - && export DATABASE_HOST=$2 && export DATABASE_USER=$1 && export DATABASE_PASSWORD=$3 && export DATABASE_DB=$5 - -RUN bash -c ' \ - echo "[database]" > app.ini; \ - echo "DB_TYPE = postgres" >> app.ini; \ - echo "HOST = $DATABASE_HOST" >> app.ini; \ - echo "NAME = $DATABASE_DB" >> app.ini; \ - echo "USER = $DATABASE_USER" >> app.ini; \ - echo "PASSWD = $DATABASE_PASSWORD" >> app.ini; \ - echo "SSL_MODE = require" >> app.ini \ -' - - COPY app.ini /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) \ + && sed -i "s|HOST *=.*|HOST = $DATABASE_HOST|" /var/lib/gitea/custom/conf/app.ini \ + && sed -i "s|NAME *=.*|NAME = $DATABASE_NAME|" /var/lib/gitea/custom/conf/app.ini \ + && sed -i "s|USER *=.*|USER = $DATABASE_USER|" /var/lib/gitea/custom/conf/app.ini \ + && sed -i "s|PASSWD *=.*|PASSWD = $DATABASE_PASSWORD|" /var/lib/gitea/custom/conf/app.ini \ + && sed -i "s|SSL_MODE *=.*|SSL_MODE = require|" /var/lib/gitea/custom/conf/app.ini +