From a637e065009684ddeb8a4661ff5c2f7b18b4e899 Mon Sep 17 00:00:00 2001 From: korzepadawid Date: Sun, 15 Dec 2024 13:21:40 +0100 Subject: [PATCH] tmp --- Dockerfile | 12 +++++++----- config-script.sh | 39 +++++++++++++++++++++++++++++++++++++++ heroku.yaml | 22 ++++------------------ link.txt | 1 + 4 files changed, 51 insertions(+), 23 deletions(-) create mode 100755 config-script.sh create mode 100644 link.txt diff --git a/Dockerfile b/Dockerfile index 205c3fe..85ed34d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,10 +1,12 @@ -FROM gitea/gitea:1.14.5-rootless +FROM gitea/gitea:1.14.5 -WORKDIR /var/lib/gitea +WORKDIR /app -USER gitea +COPY link.txt ./ +COPY config-script.sh ./ -EXPOSE 3000 +ENV GITEA_CUSTOM=/var/lib/gitea/custom -CMD ["/usr/local/bin/gitea", "web"] +RUN chmod +x ./configr-script.sh +ENTRYPOINT ["./config-script.sh"] diff --git a/config-script.sh b/config-script.sh new file mode 100755 index 0000000..d65b3e4 --- /dev/null +++ b/config-script.sh @@ -0,0 +1,39 @@ +#!/bin/bash + +if [ -n "$HEROKU_APP_DEFAULT_DOMAIN_NAME" ]; then + APP_URL="https://${HEROKU_APP_DEFAULT_DOMAIN_NAME}" +else + if [ -f /app/link.txt ]; then + APP_URL=$(cat /app/link.txt) + else + echo "Neither HEROKU_APP_DEFAULT_DOMAIN_NAME nor /app/link.txt is available. Exiting." + exit 1 + fi +fi + +echo $APP_URL + +if [[ $DATABASE_URL =~ ^postgres://([^:]+):([^@]+)@([^:]+):([0-9]+)/([^/]+)$ ]]; then + DB_USER="${BASH_REMATCH[1]}" + DB_PASS="${BASH_REMATCH[2]}" + DB_HOST="${BASH_REMATCH[3]}:${BASH_REMATCH[4]}" + DB_NAME="${BASH_REMATCH[5]}" +else + echo "DATABASE_URL parse error" + exit 1 +fi + +mkdir -p /var/lib/gitea/custom/conf + +echo "[server]" > /var/lib/gitea/custom/conf/app.ini +echo "ROOT_URL = $APP_URL" >> /var/lib/gitea/custom/conf/app.ini + +echo "[database]" >> /var/lib/gitea/custom/conf/app.ini +echo "DB_TYPE = postgres" >> /var/lib/gitea/custom/conf/app.ini +echo "HOST = $DB_HOST" >> /var/lib/gitea/custom/conf/app.ini +echo "NAME = $DB_NAME" >> /var/lib/gitea/custom/conf/app.ini +echo "USER = $DB_USER" >> /var/lib/gitea/custom/conf/app.ini +echo "PASSWD = $DB_PASS" >> /var/lib/gitea/custom/conf/app.ini +echo "SSL_MODE = require" >> /var/lib/gitea/custom/conf/app.ini + +/usr/local/bin/gitea web --port $PORT diff --git a/heroku.yaml b/heroku.yaml index b80dc2f..37265c2 100644 --- a/heroku.yaml +++ b/heroku.yaml @@ -1,21 +1,7 @@ +setup: + addons: + - plan: heroku-postgresql + as: DATABASE build: docker: web: Dockerfile - -run: - web: | - /bin/su-exec gitea /usr/local/bin/gitea web - -setup: - addons: - - plan: heroku-postgresql - as: DATABASE - -env: - GITEA__database__DB_TYPE: postgres - GITEA__database__HOST: ${DATABASE_HOST} - GITEA__database__NAME: ${DATABASE_NAME} - GITEA__database__USER: ${DATABASE_USER} - GITEA__database__PASSWD: ${DATABASE_PASSWORD} - - PORT: 3000 diff --git a/link.txt b/link.txt new file mode 100644 index 0000000..f69be06 --- /dev/null +++ b/link.txt @@ -0,0 +1 @@ +https://infinite-refuge-66589-9c2e431bbb89.herokuapp.com/