feat: enable gitea service and mv vars to separate script
parent
6115e734e6
commit
0dac5121fd
|
@ -18,11 +18,9 @@ services:
|
|||
environment:
|
||||
- POSTGRES_PASSWORD=password
|
||||
|
||||
# gitea:
|
||||
# image: gitea/gitea:1.16.5
|
||||
# container_name: hostea-dash-gitea
|
||||
# # network_mode: host
|
||||
# restart: always
|
||||
gitea:
|
||||
image: gitea/gitea:1.16.5
|
||||
container_name: hostea-dash-gitea
|
||||
|
||||
smtp:
|
||||
image: maildev/maildev:latest
|
||||
|
|
|
@ -0,0 +1,166 @@
|
|||
readonly GITEA_PID_FILE=./tmp/gitea.pid
|
||||
readonly SERVER_PID_FILE=./tmp/gitea.pid
|
||||
|
||||
readonly DASHBOARD_URL="http://localhost:8000"
|
||||
readonly GITEA_URL="http://localhost:3000"
|
||||
|
||||
|
||||
readonly DASHBOARD_OIDC_DISCOVERY_URL="$DASHBOARD_URL/o/.well-known/openid-configuration/"
|
||||
|
||||
readonly DASHBOARD_ADMIN_USERNAME=root
|
||||
readonly DASHBOARD_ADMIN_PASSWORD=supercomplicatedpassword
|
||||
readonly DASHBOARD_ADMIN_EMAIL="$DASHBOARD_ADMIN_USERNAME@dash.example.org"
|
||||
readonly DASHBOARD_OIDC_APP_NAME=hostea-gitea
|
||||
|
||||
readonly GITEA_ROOT_USERNAME=root
|
||||
readonly GITEA_ROOT_EMAIL="$GITEA_ROOT_USERNAME@example.org"
|
||||
readonly GITEA_ROOT_PASSOWRD=supercomplicatedpassword
|
||||
readonly GITEA_HOSTEA_SSO_NAME=hostea-sso
|
||||
readonly GITEA_OIDC_CALLBACK="$GITEA_URL/user/oauth2/$GITEA_HOSTEA_SSO_NAME/callback"
|
||||
|
||||
readonly GITEA_HOSTEA_USERNAME=hostea
|
||||
readonly GITEA_HOSTEA_PASSWORD=supercomplicatedpassword
|
||||
readonly GITEA_HOSTEA_EMAIL="$GITEA_HOSTEA_USERNAME@example.org"
|
||||
readonly GITEA_HOSTEA_SUPPORT_REPO="support"
|
||||
|
||||
readonly HOSTEA_CUSTOMER_USERNAME=batman
|
||||
readonly HOSTEA_CUSTOMER_PASSWORD=supercomplicatedpassword
|
||||
readonly HOSTEA_CUSTOMER_EMAIL="$HOSTEA_CUSTOMER_USERNAME@example.org"
|
||||
|
||||
if [ -z ${CI+x} ];
|
||||
then
|
||||
MAILDEV_URL="http://localhost:1080"
|
||||
else
|
||||
MAILDEV_URL="http://smtp:1080"
|
||||
fi
|
||||
|
||||
OIDC_CLIENT_ID=""
|
||||
OIDC_CLIENT_SECRET=""
|
||||
|
||||
wait_for_env() {
|
||||
curl $DASHBOARD_URL || true
|
||||
python -m integration \
|
||||
check_env $GITEA_URL $DASHBOARD_URL $MAILDEV_URL
|
||||
}
|
||||
|
||||
# create OIDC app on Hostea Dashboard
|
||||
oidc_dashboard_init() {
|
||||
python -m integration \
|
||||
hostea register \
|
||||
$DASHBOARD_ADMIN_USERNAME $DASHBOARD_ADMIN_PASSWORD \
|
||||
$DASHBOARD_ADMIN_EMAIL \
|
||||
$DASHBOARD_URL \
|
||||
$MAILDEV_URL
|
||||
|
||||
resp=$(python manage.py create_oidc \
|
||||
$DASHBOARD_OIDC_APP_NAME $DASHBOARD_ADMIN_USERNAME \
|
||||
$GITEA_OIDC_CALLBACK)
|
||||
OIDC_CLIENT_ID=$(echo $resp | cut -d ":" -f 2 | cut -d " " -f 2)
|
||||
OIDC_CLIENT_SECRET=$(echo $resp | cut -d ":" -f 3 | cut -d " " -f 2)
|
||||
}
|
||||
|
||||
# register root user on Gitea to simulate Hoste admin and integrate SSO
|
||||
gitea_root(){
|
||||
python -m integration \
|
||||
gitea install \
|
||||
$GITEA_ROOT_USERNAME $GITEA_ROOT_PASSOWRD \
|
||||
$GITEA_ROOT_EMAIL \
|
||||
$GITEA_URL
|
||||
python -m integration \
|
||||
gitea register \
|
||||
$GITEA_ROOT_USERNAME $GITEA_ROOT_PASSOWRD \
|
||||
$GITEA_ROOT_EMAIL \
|
||||
$GITEA_URL
|
||||
python -m integration \
|
||||
gitea login \
|
||||
$GITEA_ROOT_USERNAME $GITEA_ROOT_PASSOWRD \
|
||||
$GITEA_ROOT_EMAIL \
|
||||
$GITEA_URL
|
||||
python -m integration \
|
||||
gitea install_sso \
|
||||
$GITEA_ROOT_USERNAME $GITEA_ROOT_PASSOWRD \
|
||||
$GITEA_ROOT_EMAIL \
|
||||
$GITEA_URL \
|
||||
$GITEA_HOSTEA_SSO_NAME \
|
||||
$OIDC_CLIENT_ID $OIDC_CLIENT_SECRET \
|
||||
$DASHBOARD_OIDC_DISCOVERY_URL
|
||||
}
|
||||
|
||||
|
||||
# register user "Hostea" on Gitea and create support repository
|
||||
support_repo_init() {
|
||||
python -m integration \
|
||||
gitea register \
|
||||
$GITEA_HOSTEA_USERNAME $GITEA_HOSTEA_PASSWORD \
|
||||
$GITEA_HOSTEA_EMAIL \
|
||||
$GITEA_URL
|
||||
python -m integration \
|
||||
gitea login \
|
||||
$GITEA_HOSTEA_USERNAME $GITEA_HOSTEA_PASSWORD \
|
||||
$GITEA_HOSTEA_EMAIL \
|
||||
$GITEA_URL
|
||||
python -m integration \
|
||||
gitea create_repo \
|
||||
$GITEA_HOSTEA_USERNAME $GITEA_HOSTEA_PASSWORD \
|
||||
$GITEA_HOSTEA_EMAIL \
|
||||
$GITEA_URL \
|
||||
$GITEA_HOSTEA_SUPPORT_REPO
|
||||
}
|
||||
|
||||
# Create user on Hostea to simulate a Hostea customer
|
||||
hostea_customer_simulation() {
|
||||
python -m integration \
|
||||
hostea register \
|
||||
$HOSTEA_CUSTOMER_USERNAME $HOSTEA_CUSTOMER_PASSWORD \
|
||||
$HOSTEA_CUSTOMER_EMAIL \
|
||||
$DASHBOARD_URL \
|
||||
$MAILDEV_URL
|
||||
python -m integration \
|
||||
hostea login \
|
||||
$HOSTEA_CUSTOMER_USERNAME $HOSTEA_CUSTOMER_PASSWORD \
|
||||
$HOSTEA_CUSTOMER_EMAIL $DASHBOARD_URL
|
||||
python -m integration \
|
||||
hostea support \
|
||||
$HOSTEA_CUSTOMER_USERNAME $HOSTEA_CUSTOMER_PASSWORD \
|
||||
$HOSTEA_CUSTOMER_EMAIL \
|
||||
$DASHBOARD_URL \
|
||||
$GITEA_URL \
|
||||
$GITEA_HOSTEA_USERNAME $GITEA_HOSTEA_SUPPORT_REPO
|
||||
}
|
||||
|
||||
gitea(){
|
||||
readonly BIN=tmp/gitea/bin/gitea
|
||||
readonly SOURCE="https://github.com/go-gitea/gitea/releases/download/v1.16.5/gitea-1.16.5-linux-amd64"
|
||||
readonly CONFIG_FILE=gitea/app.ini
|
||||
|
||||
mkdir -p tmp/gitea/bin || true
|
||||
|
||||
for dir in repos db lfs log
|
||||
do
|
||||
rm -rf tmp/gitea/$dir || true
|
||||
mkdir -p tmp/gitea/$dir || true
|
||||
done
|
||||
|
||||
if [ ! -e $BIN ];
|
||||
then
|
||||
wget --quiet --output-document=$BIN $SOURCE
|
||||
chmod +x $BIN
|
||||
fi
|
||||
|
||||
nohup $BIN --config $CONFIG_FILE web > /dev/null 2>&1 &
|
||||
GITEA_PID=$!
|
||||
echo $GITEA_PID > $GITEA_PID_FILE
|
||||
}
|
||||
|
||||
setup_env() {
|
||||
mkdir tmp/ || true
|
||||
nohup python manage.py runserver > /dev/null 2>&1 &
|
||||
SERVER_PID=$!
|
||||
echo $SERVER_PID > $SERVER_PID_FILE
|
||||
gitea
|
||||
}
|
||||
|
||||
teardown_env() {
|
||||
kill $(cat $GITEA_PID_FILE)
|
||||
kill $(cat $SERVER_PID_FILE)
|
||||
}
|
|
@ -2,173 +2,7 @@
|
|||
|
||||
set -Exeuo pipefail
|
||||
|
||||
readonly GITEA_PID_FILE=./tmp/gitea.pid
|
||||
readonly SERVER_PID_FILE=./tmp/gitea.pid
|
||||
|
||||
readonly DASHBOARD_URL="http://localhost:8000"
|
||||
readonly GITEA_URL="http://localhost:3000"
|
||||
|
||||
|
||||
readonly DASHBOARD_OIDC_DISCOVERY_URL="$DASHBOARD_URL/o/.well-known/openid-configuration/"
|
||||
|
||||
readonly DASHBOARD_ADMIN_USERNAME=root
|
||||
readonly DASHBOARD_ADMIN_PASSWORD=supercomplicatedpassword
|
||||
readonly DASHBOARD_ADMIN_EMAIL="$DASHBOARD_ADMIN_USERNAME@dash.example.org"
|
||||
readonly DASHBOARD_OIDC_APP_NAME=hostea-gitea
|
||||
|
||||
readonly GITEA_ROOT_USERNAME=root
|
||||
readonly GITEA_ROOT_EMAIL="$GITEA_ROOT_USERNAME@example.org"
|
||||
readonly GITEA_ROOT_PASSOWRD=supercomplicatedpassword
|
||||
readonly GITEA_HOSTEA_SSO_NAME=hostea-sso
|
||||
readonly GITEA_OIDC_CALLBACK="$GITEA_URL/user/oauth2/$GITEA_HOSTEA_SSO_NAME/callback"
|
||||
|
||||
readonly GITEA_HOSTEA_USERNAME=hostea
|
||||
readonly GITEA_HOSTEA_PASSWORD=supercomplicatedpassword
|
||||
readonly GITEA_HOSTEA_EMAIL="$GITEA_HOSTEA_USERNAME@example.org"
|
||||
readonly GITEA_HOSTEA_SUPPORT_REPO="support"
|
||||
|
||||
readonly HOSTEA_CUSTOMER_USERNAME=batman
|
||||
readonly HOSTEA_CUSTOMER_PASSWORD=supercomplicatedpassword
|
||||
readonly HOSTEA_CUSTOMER_EMAIL="$HOSTEA_CUSTOMER_USERNAME@example.org"
|
||||
|
||||
|
||||
if [ -z ${CI+x} ];
|
||||
then
|
||||
MAILDEV_URL="http://localhost:1080"
|
||||
else
|
||||
MAILDEV_URL="http://smtp:1080"
|
||||
fi
|
||||
|
||||
OIDC_CLIENT_ID=""
|
||||
OIDC_CLIENT_SECRET=""
|
||||
|
||||
wait_for_env() {
|
||||
curl $DASHBOARD_URL || true
|
||||
python -m integration \
|
||||
check_env $GITEA_URL $DASHBOARD_URL $MAILDEV_URL
|
||||
}
|
||||
|
||||
# create OIDC app on Hostea Dashboard
|
||||
oidc_dashboard_init() {
|
||||
python -m integration \
|
||||
hostea register \
|
||||
$DASHBOARD_ADMIN_USERNAME $DASHBOARD_ADMIN_PASSWORD \
|
||||
$DASHBOARD_ADMIN_EMAIL \
|
||||
$DASHBOARD_URL \
|
||||
$MAILDEV_URL
|
||||
|
||||
resp=$(python manage.py create_oidc \
|
||||
$DASHBOARD_OIDC_APP_NAME $DASHBOARD_ADMIN_USERNAME \
|
||||
$GITEA_OIDC_CALLBACK)
|
||||
OIDC_CLIENT_ID=$(echo $resp | cut -d ":" -f 2 | cut -d " " -f 2)
|
||||
OIDC_CLIENT_SECRET=$(echo $resp | cut -d ":" -f 3 | cut -d " " -f 2)
|
||||
}
|
||||
|
||||
# register root user on Gitea to simulate Hoste admin and integrate SSO
|
||||
gitea_root(){
|
||||
python -m integration \
|
||||
gitea install \
|
||||
$GITEA_ROOT_USERNAME $GITEA_ROOT_PASSOWRD \
|
||||
$GITEA_ROOT_EMAIL \
|
||||
$GITEA_URL
|
||||
python -m integration \
|
||||
gitea register \
|
||||
$GITEA_ROOT_USERNAME $GITEA_ROOT_PASSOWRD \
|
||||
$GITEA_ROOT_EMAIL \
|
||||
$GITEA_URL
|
||||
python -m integration \
|
||||
gitea login \
|
||||
$GITEA_ROOT_USERNAME $GITEA_ROOT_PASSOWRD \
|
||||
$GITEA_ROOT_EMAIL \
|
||||
$GITEA_URL
|
||||
python -m integration \
|
||||
gitea install_sso \
|
||||
$GITEA_ROOT_USERNAME $GITEA_ROOT_PASSOWRD \
|
||||
$GITEA_ROOT_EMAIL \
|
||||
$GITEA_URL \
|
||||
$GITEA_HOSTEA_SSO_NAME \
|
||||
$OIDC_CLIENT_ID $OIDC_CLIENT_SECRET \
|
||||
$DASHBOARD_OIDC_DISCOVERY_URL
|
||||
}
|
||||
|
||||
|
||||
# register user "Hostea" on Gitea and create support repository
|
||||
support_repo_init() {
|
||||
python -m integration \
|
||||
gitea register \
|
||||
$GITEA_HOSTEA_USERNAME $GITEA_HOSTEA_PASSWORD \
|
||||
$GITEA_HOSTEA_EMAIL \
|
||||
$GITEA_URL
|
||||
python -m integration \
|
||||
gitea login \
|
||||
$GITEA_HOSTEA_USERNAME $GITEA_HOSTEA_PASSWORD \
|
||||
$GITEA_HOSTEA_EMAIL \
|
||||
$GITEA_URL
|
||||
python -m integration \
|
||||
gitea create_repo \
|
||||
$GITEA_HOSTEA_USERNAME $GITEA_HOSTEA_PASSWORD \
|
||||
$GITEA_HOSTEA_EMAIL \
|
||||
$GITEA_URL \
|
||||
$GITEA_HOSTEA_SUPPORT_REPO
|
||||
}
|
||||
|
||||
# Create user on Hostea to simulate a Hostea customer
|
||||
hostea_customer_simulation() {
|
||||
python -m integration \
|
||||
hostea register \
|
||||
$HOSTEA_CUSTOMER_USERNAME $HOSTEA_CUSTOMER_PASSWORD \
|
||||
$HOSTEA_CUSTOMER_EMAIL \
|
||||
$DASHBOARD_URL \
|
||||
$MAILDEV_URL
|
||||
python -m integration \
|
||||
hostea login \
|
||||
$HOSTEA_CUSTOMER_USERNAME $HOSTEA_CUSTOMER_PASSWORD \
|
||||
$HOSTEA_CUSTOMER_EMAIL $DASHBOARD_URL
|
||||
python -m integration \
|
||||
hostea support \
|
||||
$HOSTEA_CUSTOMER_USERNAME $HOSTEA_CUSTOMER_PASSWORD \
|
||||
$HOSTEA_CUSTOMER_EMAIL \
|
||||
$DASHBOARD_URL \
|
||||
$GITEA_URL \
|
||||
$GITEA_HOSTEA_USERNAME $GITEA_HOSTEA_SUPPORT_REPO
|
||||
}
|
||||
|
||||
gitea(){
|
||||
readonly BIN=tmp/gitea/bin/gitea
|
||||
readonly SOURCE="https://github.com/go-gitea/gitea/releases/download/v1.16.5/gitea-1.16.5-linux-amd64"
|
||||
readonly CONFIG_FILE=gitea/app.ini
|
||||
|
||||
mkdir -p tmp/gitea/bin || true
|
||||
|
||||
for dir in repos db lfs log
|
||||
do
|
||||
rm -rf tmp/gitea/$dir || true
|
||||
mkdir -p tmp/gitea/$dir || true
|
||||
done
|
||||
|
||||
if [ ! -e $BIN ];
|
||||
then
|
||||
wget --quiet --output-document=$BIN $SOURCE
|
||||
chmod +x $BIN
|
||||
fi
|
||||
|
||||
nohup $BIN --config $CONFIG_FILE web > /dev/null 2>&1 &
|
||||
GITEA_PID=$!
|
||||
echo $GITEA_PID > $GITEA_PID_FILE
|
||||
}
|
||||
|
||||
setup_env() {
|
||||
mkdir tmp/ || true
|
||||
nohup python manage.py runserver > /dev/null 2>&1 &
|
||||
SERVER_PID=$!
|
||||
echo $SERVER_PID > $SERVER_PID_FILE
|
||||
gitea
|
||||
}
|
||||
|
||||
teardown_env() {
|
||||
kill $(cat $GITEA_PID_FILE)
|
||||
kill $(cat $SERVER_PID_FILE)
|
||||
}
|
||||
source integration/lib.sh
|
||||
|
||||
main() {
|
||||
teardown_env || true
|
||||
|
|
Loading…
Reference in New Issue