This commit is contained in:
asmigiel 2025-01-04 21:22:58 +01:00
parent 11205e114b
commit 4d09f79a30
4 changed files with 48 additions and 27 deletions

View File

@ -1,11 +1,12 @@
FROM gitea/gitea:1.14.5
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 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
WORKDIR /app
USER 1000:1000
COPY run.sh ./
ENV GITEA_CUSTOM=/var/lib/gitea/custom
RUN chmod +x ./run.sh
ENTRYPOINT ["./run.sh"]
CMD ["/usr/local/bin/run.sh"]

0
conf/app.ini Normal file
View File

View File

@ -10,3 +10,6 @@ setup:
build:
docker:
web: Dockerfile
run:
web: /usr/local/bin/run.sh

53
run.sh
View File

@ -1,27 +1,44 @@
#!/bin/bash
echo $APP_URL
echo DATABASE_URL
echo $DATABASE_URL
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:]]*"`
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 = $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
printf "[server]\nHTTP_PORT = $PORT;\n" > /var/lib/gitea/custom/conf/app.ini
printf "DOMAIN = $HEROKU_APP_DEFAULT_DOMAIN_NAME\n" >> /var/lib/gitea/custom/conf/app.ini
printf "\n[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
/usr/local/bin/gitea web -port $PORT
#
#echo $APP_URL
#echo DATABASE_URL
#echo $DATABASE_URL
#
#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:]]*"`
#
#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 = $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