From 4c8501c36934f835d9a261d72561774a0558fd3b Mon Sep 17 00:00:00 2001 From: Sheaza Date: Mon, 28 Oct 2024 21:17:14 +0100 Subject: [PATCH] done 2.2 --- .gitignore | 2 ++ Dockerfile | 12 ++++++++++++ conf/app.ini | 0 heroku.yml | 9 +++++++++ run.sh | 13 +++++++++++++ 5 files changed, 36 insertions(+) create mode 100644 .gitignore create mode 100644 Dockerfile create mode 100644 conf/app.ini create mode 100644 heroku.yml create mode 100644 run.sh diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..5f7def2 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +/venv +.idea \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..70cb844 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,12 @@ +FROM gitea/gitea:1.14.5-rootless +ARG DATABASE_URL +ENV DATABASE_URL=${DATABASE_URL} +COPY --chown=root:root run.sh /usr/local/bin/ +ADD ../heroku-gitea/conf/ /var/lib/gitea/custom/conf/ +USER root +RUN chmod 755 /usr/local/bin/run.sh +RUN chmod a+rwx /var/lib/gitea/custom/conf/app.ini + +USER 1000:1000 + +CMD ["/usr/local/bin/run.sh"] \ No newline at end of file diff --git a/conf/app.ini b/conf/app.ini new file mode 100644 index 0000000..e69de29 diff --git a/heroku.yml b/heroku.yml new file mode 100644 index 0000000..78bdffe --- /dev/null +++ b/heroku.yml @@ -0,0 +1,9 @@ +setup: + addons: + - plan: heroku-postgresql + as: DATABASE +build: + docker: + web: Dockerfile +run: + web: /usr/local/bin/run.sh \ No newline at end of file diff --git a/run.sh b/run.sh new file mode 100644 index 0000000..63ee5d3 --- /dev/null +++ b/run.sh @@ -0,0 +1,13 @@ +HOST=`echo $DATABASE_URL | grep -o "@.*/" | sed 's/.$//' | cut -c 2-` +NAME=`echo $DATABASE_URL | grep -o "/[[:alnum:]]*$" | cut -c 2-` +USER=`echo $DATABASE_URL | grep -o "//[[:alnum:]]*:" | grep -o "[[:alnum:]]*"` +PASSWD=`echo $DATABASE_URL | grep -o ":[[:alnum:]]*@" | grep -o "[[:alnum:]]*"` +printf "[server]\nHTTP_PORT = $PORT;\n" > /var/lib/gitea/custom/conf/app.ini +printf "[database]\nDB_TYPE = postgres;\n" >> /var/lib/gitea/custom/conf/app.ini +printf "NAME = $NAME;\n" >> /var/lib/gitea/custom/conf/app.ini +printf "HOST = $HOST;\n" >> /var/lib/gitea/custom/conf/app.ini +printf "USER = $USER;\n" >> /var/lib/gitea/custom/conf/app.ini +printf "PASSWD = $PASSWD;\n" >> /var/lib/gitea/custom/conf/app.ini +printf "SSL_MODE = require ;\n" >> /var/lib/gitea/custom/conf/app.ini +cat /var/lib/gitea/custom/conf/app.ini +/usr/local/bin/gitea web -port $PORT \ No newline at end of file