From ad56dfcbb78506658d6482a231ee80d4114c827e Mon Sep 17 00:00:00 2001 From: Stanislaw Adaszewski Date: Fri, 1 May 2020 21:19:35 +0200 Subject: [PATCH] Further improvements to Gitea recipe --- example/gitea/Fockerfile | 13 +++++++++---- example/gitea/focker-compose.yml | 27 +++++++++++++++++++++------ 2 files changed, 30 insertions(+), 10 deletions(-) diff --git a/example/gitea/Fockerfile b/example/gitea/Fockerfile index 0a8b083..4797ae1 100644 --- a/example/gitea/Fockerfile +++ b/example/gitea/Fockerfile @@ -38,11 +38,16 @@ steps: - ASSUME_ALWAYS_YES=yes pkg remove gmake go - ASSUME_ALWAYS_YES=yes pkg autoremove - run: - - mkdir -p /var/db/gitea + - ASSUME_ALWAYS_YES=yes pkg install py27-crudini + - run: + - export GITEA_CONF=/usr/local/etc/gitea/conf/app.ini + - crudini --set --inplace $GITEA_CONF oauth2 JWT_SECRET `gitea generate secret JWT_SECRET` + - crudini --set --inplace $GITEA_CONF security INTERNAL_TOKEN `gitea generate secret INTERNAL_TOKEN` + - crudini --set --inplace $GITEA_CONF security SECRET_KEY `gitea generate secret SECRET_KEY` + - crudini --set --inplace $GITEA_CONF service DISABLE_REGISTRATION true + - chown root:git $GITEA_CONF + - chmod 640 $GITEA_CONF - sysrc sshd_enable=NO - sysrc gitea_enable=YES - sysrc sendmail_enable=NONE - sysrc syslogd_flags="-ss" - - sed -i -e 's/DISABLE_REGISTRATION[ \t]*=[ \t]*false/DISABLE_REGISTRATION = true/g' /usr/local/etc/gitea/conf/app.ini - - chown root:git /usr/local/etc/gitea/conf/app.ini - - chmod 640 /usr/local/etc/gitea/conf/app.ini diff --git a/example/gitea/focker-compose.yml b/example/gitea/focker-compose.yml index 328910b..3ee6a21 100644 --- a/example/gitea/focker-compose.yml +++ b/example/gitea/focker-compose.yml @@ -11,20 +11,35 @@ jails: gitea: meta: domains: - - 1101.ch - - www.1101.ch + - xyz.com + - www.xyz.com image: gitea-latest mounts: gitea-data: /var/db/gitea ip4.addr: 127.0.8.1 exec.start: | + export GITEA_CONF=/usr/local/etc/gitea/conf/app.ini && \ chown git:git /var/db/gitea && \ - sed -i -e 's/127.0.0.1/127.0.8.1/g' /usr/local/etc/gitea/conf/app.ini && \ - sed -i -e 's/ChangeMeBeforeRunning/J#NNOWn377ijsmfjmw54594702239ydhofh494j/g' /usr/local/etc/gitea/conf/app.ini && \ + sed -i -e 's/127.0.0.1/127.0.8.1/g' $GITEA_CONF && \ + sed -i -e 's/localhost/xyz.com/g' $GITEA_CONF && \ + crudini --set --inplace $GITEA_CONF server ROOT_URL https://xyz.com && \ + crudini --set --inplace $GITEA_CONF server DISABLE_SSH true && \ + export SECRET_CONF=/var/db/gitea/focker-secrets.ini && \ + if [ ! -f $SECRET_CONF ]; then + touch $SECRET_CONF && \ + chown root:git $SECRET_CONF && \ + chmod 640 $SECRET_CONF && \ + crudini --set --inplace $SECRET_CONF oauth2 JWT_SECRET `gitea generate secret JWT_SECRET` && \ + crudini --set --inplace $SECRET_CONF security INTERNAL_TOKEN `gitea generate secret INTERNAL_TOKEN` && \ + crudini --set --inplace $SECRET_CONF security SECRET_KEY `gitea generate secret SECRET_KEY`; \ + fi && \ if [ ! -f /var/db/gitea/gitea.db ]; then \ - su git -c 'gitea migrate -c /usr/local/etc/gitea/conf/app.ini' && \ - su git -c 'gitea admin -c /usr/local/etc/gitea/conf/app.ini create-user --username admin1 --password "AdminAdmin1+" --email "invaliduser@nonexistentdomain.com"'; \ + su git -c 'gitea migrate -c $GITEA_CONF' && \ + su git -c 'gitea admin -c $GITEA_CONF create-user --username admin1 --password "AdminAdmin1+" --email "invaliduser@nonexistentdomain.com" --admin'; \ fi && \ + crudini --set --inplace $GITEA_CONF oauth2 JWT_SECRET `crudini --get $SECRET_CONF oauth2 JWT_SECRET` && \ + crudini --set --inplace $GITEA_CONF security INTERNAL_TOKEN `crudini --get $SECRET_CONF security INTERNAL_TOKEN` && \ + crudini --set --inplace $GITEA_CONF security SECRET_KEY `crudini --get $SECRET_CONF security SECRET_KEY` && \ /bin/sh /etc/rc certbot-gitea: