This commit is contained in:
Adam Stelmaszyk 2025-01-21 12:43:48 +01:00
commit cbc0919749
7 changed files with 66 additions and 0 deletions

BIN
.DS_Store vendored Normal file

Binary file not shown.

12
Dockerfile Normal file
View File

@ -0,0 +1,12 @@
FROM gitea/gitea:1.14.5-rootless
ADD conf/ /var/lib/gitea/custom/conf/
WORKDIR /app
COPY run.sh ./
USER root
RUN chmod +x ./run.sh
ENTRYPOINT ["./run.sh"]

2
README.md Normal file
View File

@ -0,0 +1,2 @@
# heroku zadanie - ćwiczenia nr.2
To run app use ```sh init.sh```

0
conf/app.ini Normal file
View File

8
heroku.yml Normal file
View File

@ -0,0 +1,8 @@
setup:
addons:
- plan: heroku-postgresql
as: DATABASE
build:
docker:
web: Dockerfile

25
init.sh Executable file
View File

@ -0,0 +1,25 @@
APP_NAME=gitea-adam-stelm
# Remove old app
heroku apps:destroy --app $APP_NAME --confirm $APP_NAME
# Init repo
git init
heroku create --stack container --region eu $APP_NAME --json
# Build postgresgl and wait for setup
heroku addons:create heroku-postgresql:essential-0 --app $APP_NAME
heroku pg:wait --app $APP_NAME
heroku config:get DATABASE_URL -a $APP_NAME
heroku config:set HEROKU_URL=$(heroku info -s | grep web_url | cut -d= -f2)
# Publish app
heroku git:remote --app $APP_NAME
git add .
git commit -m "init"
git push heroku master
# Open app
heroku open --app $APP_NAME

19
run.sh Normal file
View File

@ -0,0 +1,19 @@
ROOT_URL=`echo $HEROKU_URL`
echo "[server]" > /var/lib/gitea/custom/conf/app.ini
echo "ROOT_URL = $ROOT_URL" >> /var/lib/gitea/custom/conf/app.ini
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:]]*"`
echo "[database]" >> /var/lib/gitea/custom/conf/app.ini
echo "DB_TYPE = postgres" >> /var/lib/gitea/custom/conf/app.ini
echo "HOST = $HOST" >> /var/lib/gitea/custom/conf/app.ini
echo "NAME = $NAME" >> /var/lib/gitea/custom/conf/app.ini
echo "USER = $USER" >> /var/lib/gitea/custom/conf/app.ini
echo "PASSWD = $PASSWD" >> /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