Gitea premier jet

This commit is contained in:
Gitouche 2022-05-26 21:00:27 +02:00
parent afd4862172
commit 939d193847
14 changed files with 204 additions and 0 deletions

View File

@ -10,6 +10,15 @@ trigger_framadate:
- changes:
- podman-framadate/*
trigger_gitea:
stage: triggers
trigger:
include: podman-gitea/.gitlab-ci.yml
strategy: depend
rules:
- changes:
- podman-gitea/*
trigger_jitsi:
stage: triggers
trigger:

View File

@ -0,0 +1,24 @@
# sed -n 's/^ - \(.*\)$/\1/p' .gitlab-ci.yml | bash
before_script:
- podman pod exists podman-gitea && podman pod rm --force podman-gitea
- rm -f ~/.config/systemd/user/pod-podman-gitea.service && systemctl --user daemon-reload
- podman volume exists podman-gitea_gitea-data && podman volume rm podman-gitea_gitea-data
- podman volume exists podman-gitea_gitea-pgsql && podman volume rm podman-gitea_gitea-pgsql
gitea:
stage: test
script:
- cd podman-gitea
- GARBAYE_GITEA_POSTGRES_PASSWORD=kejfczEAKjzkejklc GARBAYE_GITEA_ENV_WEBLISTENPORT=18088 ./05_freshinstall.sh
- ./20_enable.sh
- ./30_start.sh && sleep 10
- ./40_stop.sh
- ./70_disable.sh
- ./80_destroy.sh
- podman volume rm podman-gitea_gitea-data
- podman volume rm podman-gitea_gitea-pgsql
tags:
- garbaye
- compute
- podman
- x86_64

27
podman-gitea/05_freshinstall.sh Executable file
View File

@ -0,0 +1,27 @@
#!/usr/bin/env bash
ABSDIR="$( dirname "$(readlink -f -- "$0")" )"
source ${ABSDIR}/../functions.sh
source ${ABSDIR}/vars.sh
ensure_pwd_is_scriptdir
ensure_not_root
ensure_variables_are_defined "$envvars"
if podman volume exists ${dbvolume} ; then
echo "Error : DB volume ${dbvolume} already exists."
echo "Please remove it before a freshinstall, or continue with a standard installation."
exit 1
fi
if podman volume exists ${datavolume} ; then
echo "Error : DATA volume ${datavolume} already exists."
echo "Please remove it before a freshinstall, or continue with a standard installation."
exit 1
fi
podman volume create ${dbvolume}
podman volume create ${datavolume}
${ABSDIR}/10_install.sh

62
podman-gitea/10_install.sh Executable file
View File

@ -0,0 +1,62 @@
#!/usr/bin/env bash
ABSDIR="$( dirname "$(readlink -f -- "$0")" )"
source ${ABSDIR}/../functions.sh
source ${ABSDIR}/vars.sh
ensure_pwd_is_scriptdir
ensure_not_root
ensure_pod_not_exists ${pod_name}
ensure_variables_are_defined "$envvars"
if ! podman volume exists ${dbvolume} ; then
echo "Error : DB volume ${dbvolume} does not exists. Consider running 05_freshinstall.sh if this is the first install."
exit 1
fi
if ! podman volume exists ${datavolume} ; then
echo "Error : DATA volume ${datavolume} does not exists. Consider running 05_freshinstall.sh if this is the first install."
exit 1
fi
cat <<EOT >> .env
APP_NAME=${GARBAYE_GITEA_APPNAME}
GITEA__database__DB_TYPE=postgres
GITEA__database__HOST=db:5432
GITEA__database__NAME=gitea
GITEA__database__PASSWD=${GARBAYE_GITEA_POSTGRES_PASSWORD}
GITEA__database__USER=gitea
GITEA__mailer__ENABLED=true
GITEA__mailer__FROM=${GARBAYE_GITEA_SMTP_FROM}
GITEA__mailer__HOST=${GARBAYE_GITEA_SMTP_SERVER}
GITEA__security__INSTALL_LOCK=true
GITEA__server__DOMAIN=${GARBAYE_GITEA_DOMAIN}
GITEA__server__SSH_DOMAIN=${GARBAYE_GITEA_DOMAIN}
GITEA__server__ROOT_URL="https://${GARBAYE_GITEA_DOMAIN}"
GITEA__server__SSH_PORT=${sshlisten_port}
GITEA__service__DISABLE_REGISTRATION=true
POSTGRES_DB=gitea
POSTGRES_PASSWORD=${GARBAYE_GITEA_POSTGRES_PASSWORD}
POSTGRES_USER=gitea
EOT
export gitea_image
export gitea_version
export postgres_image
export postgres_version
export weblisten_if
export weblisten_port
export sshlisten_if
export sshlisten_port
source ${ABSDIR}/zz_build-images.sh
podman image exists ${gitea_image}:${gitea_version} &&
podman pull ${postgres_image}:${postgres_version} &&
podman-compose --podman-run-args "--env-file .env" up -d &&
echo -n "Waiting for gitea to finish starting " &&
( podman logs -f ${container_name} 2>&1 & ) | grep -q 'NewServer()' &&
echo "OK" &&
podman pod stop ${pod_name} &&
echo Pod built and stopped. &&
shred -u .env

1
podman-gitea/20_enable.sh Symbolic link
View File

@ -0,0 +1 @@
../_podman-common/20_enable_pod.sh

1
podman-gitea/30_start.sh Symbolic link
View File

@ -0,0 +1 @@
../_podman-common/30_start_pod.sh

1
podman-gitea/40_stop.sh Symbolic link
View File

@ -0,0 +1 @@
../_podman-common/40_stop_pod.sh

1
podman-gitea/70_disable.sh Symbolic link
View File

@ -0,0 +1 @@
../_podman-common/70_disable_pod.sh

1
podman-gitea/80_destroy.sh Symbolic link
View File

@ -0,0 +1 @@
../_podman-common/80_destroy_pod.sh

1
podman-gitea/90_prune.sh Symbolic link
View File

@ -0,0 +1 @@
../_podman-common/90_prune_pod.sh

4
podman-gitea/README.md Normal file
View File

@ -0,0 +1,4 @@
To add a user (first admin or registration closed) :
```
podman exec --user 1000 gitea gitea admin user create --admin --username <name> --password <password> --email <email>
```

View File

@ -0,0 +1,22 @@
version: '2'
services:
gitea:
image: "${gitea_image}:${gitea_version}"
container_name: gitea
environment:
- USER_UID=1000
- USER_GID=1000
volumes:
- gitea-data:/data:Z
ports:
- ${weblisten_if}:${weblisten_port}:3000
- ${sshlisten_if}:${sshlisten_port}:22
depends_on:
- db
db:
image: "${postgres_image}:${postgres_version}"
container_name: gitea-db
volumes:
- gitea-pgsql:/var/lib/postgresql/data:Z

26
podman-gitea/vars.sh Normal file
View File

@ -0,0 +1,26 @@
#!/usr/bin/env bash
## vars
gitea_image="localhost/gitea/gitea"
gitea_version='1.16.8'
postgres_image="docker.io/library/postgres"
postgres_version='14'
## default vars : override with ENV var
weblisten_if="${GARBAYE_GITEA_ENV_WEBLISTENIF:-127.0.0.1}"
weblisten_port="${GARBAYE_GITEA_ENV_WEBLISTENPORT:-8088}"
sshlisten_if="${GARBAYE_GITEA_ENV_SSHLISTENIF:-0.0.0.0}"
sshlisten_port="${GARBAYE_GITEA_ENV_SSHLISTENPORT:-22222}"
GARBAYE_GITEA_APPNAME="${GARBAYE_GITEA_ENV_APPNAME:-Garbaye : forge GIT}"
GARBAYE_GITEA_SMTP_FROM="${GARBAYE_GITEA_ENV_SMTP_FROM:-git@garbaye.fr}"
GARBAYE_GITEA_DOMAIN="${GARBAYE_GITEA_ENV_DOMAIN:-git.garbaye.fr}"
## mandatory ENV vars
envvars='GARBAYE_GITEA_POSTGRES_PASSWORD'
## internal vars : do not touch
pod_name='podman-gitea'
service_name="pod-${pod_name}.service"
get_default_iface_ipv4 GARBAYE_GITEA_SMTP_SERVER
upstream_images="${gitea_image} ${postgres_image}"
confvolume='podman-gitea_gitea-config'
datavolume='podman-gitea_gitea-data'
dbvolume='podman-gitea_gitea-pgsql'
container_name='gitea'
db_container_name='gitea-db'

24
podman-gitea/zz_build-images.sh Executable file
View File

@ -0,0 +1,24 @@
#!/usr/bin/env bash
ABSDIR="$( dirname "$(readlink -f -- "$0")" )"
source ${ABSDIR}/../functions.sh
source ${ABSDIR}/vars.sh
ensure_pwd_is_scriptdir
ensure_not_root
buildfolder=/tmp/gitea-$$
if ! podman image exists ${gitea_image}:${gitea_version}; then
mkdir ${buildfolder} &&
curl -sSfL -- "https://dl.gitea.io/gitea/${gitea_version}/gitea-src-${gitea_version}.tar.gz" | tar xz -C ${buildfolder}/ && {
sed_in_place "^FROM golang" "FROM docker.io/library/golang" ${buildfolder}/Dockerfile
sed_in_place "^FROM alpine" "FROM docker.io/library/alpine" ${buildfolder}/Dockerfile
TMPDIR=${HOME} podman image build -t ${gitea_image}:${gitea_version} -f ${buildfolder}/Dockerfile ${buildfolder}
}
rm -rf ${buildfolder}
podman image prune -a -f --filter dangling=true
podman image prune -a -f --filter intermediate=true
podman image rm -f $(podman images -a -q -- docker.io/library/golang)
podman image rm -f $(podman images -a -q -- docker.io/library/alpine)
fi