Deploy to Heroku
This commit is contained in:
parent
f0e4ac1948
commit
62b07630b7
@ -4,7 +4,6 @@ WORKDIR /app
|
|||||||
|
|
||||||
COPY run.sh ./
|
COPY run.sh ./
|
||||||
|
|
||||||
# ENV GITEA_CUSTOM=/var/lib/gitea/custom
|
|
||||||
|
|
||||||
RUN chmod +x ./run.sh
|
RUN chmod +x ./run.sh
|
||||||
|
|
||||||
|
1
app_url.txt
Normal file
1
app_url.txt
Normal file
@ -0,0 +1 @@
|
|||||||
|
https://s464951-gitea-451bd4d0ed7a.herokuapp.com/
|
22
deploy.sh
22
deploy.sh
@ -3,30 +3,16 @@
|
|||||||
# App name
|
# App name
|
||||||
APP_NAME=s464951-gitea
|
APP_NAME=s464951-gitea
|
||||||
|
|
||||||
WEB_URL=$(heroku create --stack container --region eu $APP_NAME --json | jq -r '.web_url')
|
heroku create --stack container --region eu $APP_NAME --json
|
||||||
echo $WEB_URL > heroku-app.txt
|
APP_URL=$(heroku info -s | grep web_url | cut -d= -f2)
|
||||||
|
|
||||||
|
echo $APP_URL > app_url.txt
|
||||||
|
|
||||||
# Add Heroku Postgres add-on
|
|
||||||
heroku addons:create heroku-postgresql:essential-0 --app $APP_NAME
|
heroku addons:create heroku-postgresql:essential-0 --app $APP_NAME
|
||||||
|
|
||||||
|
|
||||||
#while true; do
|
|
||||||
# ADDON_STATUS=$(heroku addons:info heroku-postgresql --app $APP_NAME | grep 'State:' | awk '{print $2}')
|
|
||||||
# echo "Postgres add-on state: $ADDON_STATUS"
|
|
||||||
#
|
|
||||||
# if [ "$ADDON_STATUS" == "created" ]; then
|
|
||||||
# echo "Heroku Postgres add-on is ready!"
|
|
||||||
# break
|
|
||||||
# fi
|
|
||||||
#
|
|
||||||
# echo "Waiting for Postgres add-on to be ready..."
|
|
||||||
# sleep 5
|
|
||||||
#done
|
|
||||||
|
|
||||||
echo "Waiting for Heroku Postgres to be fully provisioned..."
|
echo "Waiting for Heroku Postgres to be fully provisioned..."
|
||||||
heroku pg:wait --app $APP_NAME
|
heroku pg:wait --app $APP_NAME
|
||||||
|
|
||||||
echo $DATABASE_URL
|
|
||||||
# Push to Heroku
|
# Push to Heroku
|
||||||
heroku git:remote --app $APP_NAME
|
heroku git:remote --app $APP_NAME
|
||||||
git add .
|
git add .
|
||||||
|
45
run.sh
45
run.sh
@ -1,32 +1,27 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
# Database type
|
echo APP_URL:
|
||||||
DB_TYPE=postgres
|
echo $APP_URL
|
||||||
|
echo DATABASE_URL:
|
||||||
|
echo $DATABASE_URL
|
||||||
|
|
||||||
# SSL mode
|
HOST=`echo $DATABASE_URL | grep -o "@.*/" | sed 's/.$//' | cut -c 2-`
|
||||||
SSL_MODE=require
|
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:]]*"`
|
||||||
|
|
||||||
# Extract database credentials from 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 "Invalid DATABASE_URL: $DATABASE_URL"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Get app url
|
|
||||||
FILE=/app/heroku-app.txt
|
|
||||||
ROOT_URL=$(cat $FILE)
|
|
||||||
|
|
||||||
# Custom configuration
|
|
||||||
mkdir -p /var/lib/gitea/custom/conf
|
mkdir -p /var/lib/gitea/custom/conf
|
||||||
|
|
||||||
# Add custom configuration
|
echo "[server]" > /var/lib/gitea/custom/conf/app.ini
|
||||||
printf "[server]\nROOT_URL = $ROOT_URL\n" > /var/lib/gitea/custom/conf/app.ini
|
echo "ROOT_URL = $APP_URL" >> /var/lib/gitea/custom/conf/app.ini
|
||||||
printf "[database]\nDB_TYPE = $DB_TYPE\nHOST = $HOST\nNAME = $NAME\nUSER = $USER\nPASSWD = $PASSWD\nSSL_MODE = $SSL_MODE\n" >> /var/lib/gitea/custom/conf/app.ini
|
|
||||||
|
|
||||||
# Start Gitea
|
echo "[database]" >> /var/lib/gitea/custom/conf/app.ini
|
||||||
/usr/local/bin/gitea web -port $PORT
|
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
|
||||||
|
|
||||||
|
cat /var/lib/gitea/custom/conf/app.ini
|
||||||
|
/usr/local/bin/gitea web --port $PORT
|
Loading…
Reference in New Issue
Block a user