From 9b2bc481d0bfdea1b9cac689efbc3ad27bfe7d4f Mon Sep 17 00:00:00 2001 From: Valentin Lab Date: Wed, 23 Jan 2019 15:23:35 +0100 Subject: [PATCH] new: [gitea] new charm --- gitea/hooks/init | 100 ++++++++++++++++++ gitea/hooks/postgres_database-relation-joined | 47 ++++++++ gitea/hooks/pre_deploy | 8 ++ gitea/hooks/web_proxy-relation-joined | 11 ++ gitea/lib/common | 22 ++++ gitea/metadata.yml | 38 +++++++ 6 files changed, 226 insertions(+) create mode 100755 gitea/hooks/init create mode 100755 gitea/hooks/postgres_database-relation-joined create mode 100755 gitea/hooks/pre_deploy create mode 100755 gitea/hooks/web_proxy-relation-joined create mode 100644 gitea/lib/common create mode 100644 gitea/metadata.yml diff --git a/gitea/hooks/init b/gitea/hooks/init new file mode 100755 index 0000000..a768bcb --- /dev/null +++ b/gitea/hooks/init @@ -0,0 +1,100 @@ +#!/bin/bash + +## Init is run on host +## For now it is run every time the script is launched, but +## it should be launched only once after build. + +## Accessible variables are: +## - SERVICE_NAME Name of current service +## - DOCKER_BASE_IMAGE Base image from which this service might be built if any +## - SERVICE_DATASTORE Location on host of the DATASTORE of this service +## - SERVICE_CONFIGSTORE Location on host of the CONFIGSTORE of this service + + +set -e + +. lib/common + +mkdir -p "$(dirname "$SERVICE_DATASTORE$CONFIG_FILE")" +cat < "$SERVICE_DATASTORE$CONFIG_FILE" + +APP_NAME = Gitea: Git with a cup of tea +RUN_MODE = prod +RUN_USER = git + +[repository] +ROOT = /data/git/repositories + +[repository.local] +LOCAL_COPY_PATH = /data/gitea/tmp/local-repo + +[repository.upload] +TEMP_PATH = /data/gitea/uploads + +[server] +APP_DATA_PATH = /data/gitea +SSH_DOMAIN = localhost +HTTP_PORT = 3000 +ROOT_URL = http://$SERVICE_NAME:3000/ +DISABLE_SSH = false +SSH_PORT = 5022 +LFS_CONTENT_PATH = /data/git/lfs +DOMAIN = localhost +LFS_START_SERVER = true +LFS_JWT_SECRET = j5N_xbVaT12B6qMM5Zc2jy0gSJPOAxGICGKio0Q8Ygo +OFFLINE_MODE = false + +[database] +PATH = /data/gitea/gitea.db +DB_TYPE = sqlite3 +HOST = postgres +NAME = gitea +USER = root +PASSWD = +SSL_MODE = disable + +[indexer] +ISSUE_INDEXER_PATH = /data/gitea/indexers/issues.bleve + +[session] +PROVIDER_CONFIG = /data/gitea/sessions +PROVIDER = file + +[picture] +AVATAR_UPLOAD_PATH = /data/gitea/avatars +DISABLE_GRAVATAR = false +ENABLE_FEDERATED_AVATAR = true + +[attachment] +PATH = /data/gitea/attachments + +[log] +ROOT_PATH = /data/gitea/log +MODE = file +LEVEL = Info + +[security] +INSTALL_LOCK = true +SECRET_KEY = ZmxgxfSNZZgMEm3MJW1Nn6BfWqSuats7MIHQvgGD2AwIH2Vdx1L77yw569bWJXPI +INTERNAL_TOKEN = eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJuYmYiOjE1NDgyNDE1OTR9.1Uu3crRVkqamIL5U2axcRJh-HEEZzMLbrLvHlhgTv0g + +[service] +DISABLE_REGISTRATION = false +REQUIRE_SIGNIN_VIEW = false +REGISTER_EMAIL_CONFIRM = false +ENABLE_NOTIFY_MAIL = false +ALLOW_ONLY_EXTERNAL_REGISTRATION = false +ENABLE_CAPTCHA = false +DEFAULT_KEEP_EMAIL_PRIVATE = false +DEFAULT_ALLOW_CREATE_ORGANIZATION = true +DEFAULT_ENABLE_TIMETRACKING = true +NO_REPLY_ADDRESS = noreply.example.org + +[mailer] +ENABLED = false + +[openid] +ENABLE_OPENID_SIGNIN = false +ENABLE_OPENID_SIGNUP = false +EOF + diff --git a/gitea/hooks/postgres_database-relation-joined b/gitea/hooks/postgres_database-relation-joined new file mode 100755 index 0000000..1f4ce2a --- /dev/null +++ b/gitea/hooks/postgres_database-relation-joined @@ -0,0 +1,47 @@ +#!/bin/bash + +set -e + +PASSWORD="$(relation-get password)" +DBUSER="$(relation-get user)" +DBNAME="$(relation-get dbname)" + +. lib/common + + +control=$(printf "%s\0" "$DBUSER" "$DBNAME" "$PASSWORD" | md5_compat) + +## Note: we don't use environment variable as it will be ignored if +## $CONFIG_FILE is found. So better modify directly the config file. +# config-add "\ +# services: +# $MASTER_BASE_SERVICE_NAME: +# environment: +# - DB_TYPE=postgres +# - DB_HOST=$MASTER_TARGET_SERVICE_NAME +# - DB_NAME=$DBNAME +# - DB_USER=$USER +# - DB_PASSWD=$PASSWORD +# " + +# ini set database DB_TYPE postgres +# ini set database HOST postgres +# ini set database NAME gitea.mydomain.org +# ini set database USER gitea.mydomain.org +# ini set database PASSWD g61wsLvKj8cF6A1S +# ini set database SSL_MODE disable + +ini merge <" +## XXXvlab: docker uses the 'build' directory or the 'image:' option here. +docker-image: docker.0k.io/gitea +docker-compose: + ports: + - "5022:22" + # environment: + # - USER_UID=1000 + # - USER_GID=1000 +data-resources: + - /data + +# default-options: +# config: | + +uses: + log-rotate: + constraint: recommended + auto: pair + solves: + disk-leak: "/data" + postgres-database: + #constraint: required | recommended | optional + #auto: pair | summon | none ## default: pair + constraint: optional + auto: pair + solves: + database: "main storage" + web-proxy: + #constraint: required | recommended | optional + #auto: pair | summon | none ## default: pair + constraint: recommended + auto: pair + solves: + proxy: "Public access" + default-options: + target: !var-expand ${MASTER_BASE_SERVICE_NAME}:3000