commit 7a7cbddb84ff09978ac7aca932f21b26d8998fa0 Author: s464863 Date: Fri Oct 18 22:54:52 2024 +0200 Zadanie 2.2 diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..6573ec0 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,11 @@ +FROM gitea/gitea:1.14.5-rootless + +ARG APP_NAME +ENV APP_NAME=${APP_NAME} + +USER root +WORKDIR /app +COPY script.sh /app/script.sh +RUN chmod +x /app/script.sh + +ENTRYPOINT ./script.sh \ No newline at end of file diff --git a/heroku.yml b/heroku.yml new file mode 100644 index 0000000..fddc434 --- /dev/null +++ b/heroku.yml @@ -0,0 +1,8 @@ +setup: + addons: + - plan: heroku-postgresql:essential-0 +build: + docker: + web: Dockerfile + config: + APP_NAME: "" \ No newline at end of file diff --git a/script.sh b/script.sh new file mode 100644 index 0000000..71dd3ef --- /dev/null +++ b/script.sh @@ -0,0 +1,25 @@ +#!/bin/bash + +DB_TYPE=postgres +DOMAIN="$APP_NAME.herokuapp.com" + +echo $DATABASE_URL +echo $APP_NAME + +# Wydobycie informacji z DATABASE_URL +if [[ $DATABASE_URL =~ ^postgres://([^:]*):([^@]*)@([^:]*):([0-9]+)/([^/]*)$ ]]; then + USER="${BASH_REMATCH[1]}" + PASSWD="${BASH_REMATCH[2]}" + HOST="${BASH_REMATCH[3]}:${BASH_REMATCH[4]}" + NAME="${BASH_REMATCH[5]}" +else + echo "Nieprawidłowy format DATABASE_URL." + exit 1 +fi + +mkdir -p /var/lib/gitea/custom/conf + +printf "[server]\nHTTP_PORT = $PORT;\nDOMAIN = $DOMAIN\n" > /var/lib/gitea/custom/conf/app.ini +printf "[database]\nDB_TYPE = $DB_TYPE\nHOST = $HOST\nNAME = $NAME\nUSER = $USER\nPASSWD = $PASSWD\n" >> /var/lib/gitea/custom/conf/app.ini + +/usr/local/bin/gitea web \ No newline at end of file