1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/dont-code_ynh.git synced 2024-09-03 18:26:34 +02:00
v0.3.1 & Multi instance & secured mongo access
This commit is contained in:
Gérard Collin 2024-04-04 15:34:07 +02:00 committed by GitHub
commit a6b75ed24c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
15 changed files with 128 additions and 43 deletions

View file

@ -1,6 +1,6 @@
# All available README files by language
- [Read the README in English](README.md)
- [Irakurri README euskaraz](README_eu.md)
- [Lire le README en français](README_fr.md)
- [Le o README en galego](README_gl.md)
- [Leggi il “README” in italiano](README_it.md)

View file

@ -9,7 +9,7 @@ It shall NOT be edited by hand.
[![Install Dont-code Services with YunoHost](https://install-app.yunohost.org/install-with-yunohost.svg)](https://install-app.yunohost.org/?app=dont-code)
*[Read this README is other languages.](./ALL_README.md)*
*[Read this README in other languages.](./ALL_README.md)*
> *This package allows you to install Dont-code Services quickly and simply on a YunoHost server.*
> *If you don't have YunoHost, please consult [the guide](https://yunohost.org/install) to learn how to install it.*
@ -32,7 +32,7 @@ This Yunohost app installs the server part (services + mongo database) needed to
- As well any documents or images uploaded by users will be backed up
**Shipped version:** 0.2.10~ynh7
**Shipped version:** 0.3.1~ynh1
**Demo:** <https://dont-code.net/apps.html>

65
README_eu.md Normal file
View file

@ -0,0 +1,65 @@
<!--
Ohart ongi: README hau automatikoki sortu da <https://github.com/YunoHost/apps/tree/master/tools/readme_generator>ri esker
EZ editatu eskuz.
-->
# Dont-code Services YunoHost-erako
[![Integrazio maila](https://dash.yunohost.org/integration/dont-code.svg)](https://dash.yunohost.org/appci/app/dont-code) ![Funtzionamendu egoera](https://ci-apps.yunohost.org/ci/badges/dont-code.status.svg) ![Mantentze egoera](https://ci-apps.yunohost.org/ci/badges/dont-code.maintain.svg)
[![Instalatu Dont-code Services YunoHost-ekin](https://install-app.yunohost.org/install-with-yunohost.svg)](https://install-app.yunohost.org/?app=dont-code)
*[Irakurri README hau beste hizkuntzatan.](./ALL_README.md)*
> *Pakete honek Dont-code Services YunoHost zerbitzari batean azkar eta zailtasunik gabe instalatzea ahalbidetzen dizu.*
> *YunoHost ez baduzu, kontsultatu [gida](https://yunohost.org/install) nola instalatu ikasteko.*
## Aurreikuspena
Dont-code is a low-code / no-code platform letting user create their own applications based on complete feature sets developed by IT.
You can find more information here: https://dont-code.net
This Yunohost app installs the server part (services + mongo database) needed to run the dont-code applications.
### Features
- Thanks to the Powerful [Builders](https://dont-code.net/ide-ui) and [Previewers](https://dont-code.net/ide-ui), a user can directly design its application and immediately see the result
- One only needs to describe its application by filling sentences prepared by the platform.
- By default it provides support for images, currency, text, numbers, countries, links.
- Multiple plugins allow you to list, edit, make reports, call services, save to database, save in browser, and so on...
- Plugins can be developed by any IT team
- Projects and all user's data are backuped up as part of the Yunohost backup process
- As well any documents or images uploaded by users will be backed up
**Paketatutako bertsioa:** 0.3.1~ynh1
**Demoa:** <https://dont-code.net/apps.html>
## Pantaila-argazkiak
![Dont-code Services(r)en pantaila-argazkia](./doc/screenshots/previewer.gif)
![Dont-code Services(r)en pantaila-argazkia](./doc/screenshots/ide.gif)
## Dokumentazioa eta baliabideak
- Aplikazioaren webgune ofiziala: <https://dont-code.net>
- Erabiltzaileen dokumentazio ofiziala: <https://dont-code.net/news.html>
- Administratzaileen dokumentazio ofiziala: <https://dont-code.net/developers.html>
- Jatorrizko aplikazioaren kode-gordailua: <https://github.com/dont-code>
- YunoHost Denda: <https://apps.yunohost.org/app/dont-code>
- Eman errore baten berri: <https://github.com/YunoHost-Apps/dont-code_ynh/issues>
## Garatzaileentzako informazioa
Bidali `pull request`a [`testing` abarrera](https://github.com/YunoHost-Apps/dont-code_ynh/tree/testing).
`testing` abarra probatzeko, ondorengoa egin:
```bash
sudo yunohost app install https://github.com/YunoHost-Apps/dont-code_ynh/tree/testing --debug
edo
sudo yunohost app upgrade dont-code -u https://github.com/YunoHost-Apps/dont-code_ynh/tree/testing --debug
```
**Informazio gehiago aplikazioaren paketatzeari buruz:** <https://yunohost.org/packaging_apps>

View file

@ -32,7 +32,7 @@ This Yunohost app installs the server part (services + mongo database) needed to
- As well any documents or images uploaded by users will be backed up
**Version incluse:** 0.2.10~ynh7
**Version incluse:** 0.3.1~ynh1
**Démo:** <https://dont-code.net/apps.html>

View file

@ -32,7 +32,7 @@ This Yunohost app installs the server part (services + mongo database) needed to
- As well any documents or images uploaded by users will be backed up
**Versión proporcionada:** 0.2.10~ynh7
**Versión proporcionada:** 0.3.1~ynh1
**Demo:** <https://dont-code.net/apps.html>

View file

@ -1,9 +1,7 @@
quarkus_http_host=127.0.0.1
quarkus_mongodb_projects_connection_string=mongodb://localhost:27017
projects_database_name=dontCodeProjects
quarkus_mongodb_data_connection_string=mongodb://localhost:27017
data_database_name=dontCodeData
quarkus_mongodb_projects_connection_string=mongodb://__DB_USER__:__DB_PWD__@localhost:27017/?authSource=dontCode__TENANT__Projects
projects_database_name=dontCode__TENANT__Projects
quarkus_mongodb_data_connection_string=mongodb://__DB_USER__:__DB_PWD__@localhost:27017/?authSource=dontCode__TENANT__Data
data_database_name=dontCode__TENANT__Data
document_directory=__DOCUMENT_DIR__
document_external_url=__DOCUMENT_URL__

View file

@ -50,11 +50,4 @@ location __PATH__/ {
client_max_body_size 15M;
}
location __PATH__/demo_project {
proxy_pass http://localhost:__PORT_PROJECT__/project;
proxy_set_header Host $host;
proxy_set_header DbName "dontCodeDemoProjects";
proxy_read_timeout 86400s;
proxy_send_timeout 86400s;
}
}

View file

@ -7,7 +7,7 @@ name = "Dont-code Services"
description.en = "Install services and databases needed to support Dont-code platform"
description.fr = "Installe les services et base de données nécessaires pour utiliser la plateforme Dont-code"
version = "0.2.10~ynh7"
version = "0.3.1~ynh1"
maintainers = ["Dont-code Team"]
@ -22,7 +22,7 @@ code = "https://github.com/dont-code"
[integration]
yunohost = ">= 11.0.0"
architectures = "all"
multi_instance = false
multi_instance = true
ldap = false
sso = false
disk = "50M"
@ -39,6 +39,12 @@ ram.runtime = "400M"
type = "path"
default = "/dont-code"
[install.tenant]
ask.en = "The name of the tenant these services will support. This configures database name to use. Can be empty if non necessary."
ask.fr = "Le nom du tenant associé a ces services. Permet de configurer une base de donnée séparée. Peut-être vide si non nécessaire."
type = "string"
optional = true
[install.public_key]
ask.en = "SSH Public key to allow service updates as part of delivery process, leave empty to disable."
ask.fr = "Clef publique SSH permettant la mise à jour des services via une deploiement automatique, inactif si non renseigné."
@ -51,8 +57,8 @@ ram.runtime = "400M"
[resources]
[resources.sources.main]
url = "https://github.com/dont-code/release/releases/download/v0.2.10/dont-code-release-runners.zip"
sha256 = "f20bfa0423d48015a3507b0555d30d57fa594657a4bca55ad869fca8fbad125d"
url = "https://github.com/dont-code/release/releases/download/v0.3.1/dont-code-release-runners.zip"
sha256 = "b69361f5383c904e30d551efd7a64cc155459af6a25e32fd5ca41633bcfb3658"
in_subdir = false
autoupdate.strategy = "latest_github_release"
autoupdate.asset = "dont-code-release-runners.zip"

View file

@ -10,7 +10,7 @@ mongo_version=6.0
SERVICES_LIST=(ide preview project data)
# List of Mongo databases to manage
MONGO_DB_LIST=(dontCodeProjects dontCodeDemoProjects dontCodeData dontCodeTestProjects)
MONGO_DB_LIST=(Projects Data)
# The list of port in the same order than the list of services
PORT_LIST=("$port_ide" "$port_preview" "$port_project" "$port_data")

View file

@ -63,11 +63,11 @@ fi
ynh_print_info --message="Backing up the Mongo databases..."
for db_name in "${MONGO_DB_LIST[@]}"; do
ynh_mongo_dump_db --database=$db_name > ./dump-${db_name}.bson
ynh_mongo_dump_db --database="dontCode$tenant$db_name" > ./dump-dontCode${tenant}${db_name}.bson
done
#=================================================
# END OF SCRIPT
#=================================================
ynh_print_info --message="Backup script completed for $app. (YunoHost will then actually copy those files to the archive)."
ynh_print_info --message="Backup script completed for $app with tenant $tenant. (YunoHost will then actually copy those files to the archive)."

View file

@ -46,6 +46,13 @@ chown -R $app:www-data "$data_dir"
#=================================================
ynh_script_progression --message="Adding a configuration file..." --weight=1
# The .env needs db_user and db_password
new_db_pwd=$(ynh_string_random) # Generate a random password
db_pwd="${db_pwd:-$new_db_pwd}"
db_user=$(ynh_sanitize_dbid --db_name="${app}")
ynh_app_setting_set --app="$app" --key=db_user --value="$db_user"
ynh_add_config --template=".env" --destination="$install_dir/.env"
chmod 400 "$install_dir/.env"
@ -82,12 +89,9 @@ ynh_install_mongo --mongo_version=$mongo_version
#=================================================
ynh_script_progression --message="Creating the Mongo databases..." --weight=1
db_user=$(ynh_sanitize_dbid --db_name="${app}")
ynh_app_setting_set --app="$app" --key=db_user --value="$db_user"
# We should probably enable databases to the user, but for now, we connect through admin
# No need to create other databases: Mongo creates them on the fly
ynh_mongo_setup_db --db_user="$db_user" --db_name="${MONGO_DB_LIST[0]}"
for db_name in "${MONGO_DB_LIST[@]}"; do
ynh_mongo_setup_db --db_user="$db_user" --db_pwd="$db_pwd" --db_name="dontCode$tenant${db_name}"
done
#=================================================
# SYSTEM CONFIGURATION

View file

@ -36,7 +36,7 @@ ynh_remove_logrotate
# Remove a database if it exists, along with the associated user
for db_name in "${MONGO_DB_LIST[@]}"; do
ynh_mongo_remove_db --db_user=$db_user --db_name=$db_name
ynh_mongo_remove_db --db_user=$db_user --db_name="dontCode$tenant$db_name"
done
# Remove mongo itself if not used anymore

View file

@ -64,10 +64,9 @@ ynh_install_mongo --mongo_version=$mongo_version
#=================================================
ynh_script_progression --message="Restoring the Mongo databases..." --weight=1
ynh_mongo_setup_db --db_user=$db_user --db_name=${MONGO_DB_LIST[0]} --db_pwd=$db_pwd
for db_name in "${MONGO_DB_LIST[@]}"; do
ynh_mongo_restore_db --database="$db_name" < "./dump-${db_name}.bson"
ynh_mongo_setup_db --db_user="$db_user" --db_pwd="$db_pwd" --db_name="dontCode$tenant${db_name}"
ynh_mongo_restore_db --database="dontCode$tenant$db_name" < "./dump-dontCode${tenant}${db_name}.bson"
done
#=================================================

View file

@ -34,6 +34,16 @@ if [ -z "${public_key+x}" ]; then
ynh_app_setting_set --app="$app" --key=public_key --value="$public_key"
fi
# Set default tenant to empty if needed
if [ -z "${tenant+x}" ]; then
tenant=""
ynh_app_setting_set --app="$app" --key=tenant --value="$tenant"
fi
# The .env needs db_password
new_db_pwd=$(ynh_string_random) # Generate a random password
db_pwd="${db_pwd:-$new_db_pwd}"
if [[ -n "${document_path:-}" ]]; then
# Renamed setting key
document_dir="$document_path"
@ -66,7 +76,7 @@ if [[ -n "${html_path:-}" ]]; then
fi
# Regenerate the .env file if the document_url was incorrectly set before
# Recalculate the document_url if it was incorrectly set before
correct_document_url=$(append_uri "https://${domain}${path}" "docs")
if [ "$correct_document_url" != "$document_url" ]; then
ynh_script_progression --message="Updading url for documents" --weight=1
@ -74,13 +84,6 @@ if [ "$correct_document_url" != "$document_url" ]; then
document_url=$correct_document_url
ynh_app_setting_set --app=$app --key=document_url --value=$document_url
ynh_add_config --template=".env" --destination="$install_dir/.env"
# FIXME: this should be handled by the core in the future
# You may need to use chmod 600 instead of 400,
# for example if the app is expected to be able to modify its own config
chmod 400 "$install_dir/.env"
chown $app:$app "$install_dir/.env"
fi
#=================================================
@ -92,6 +95,16 @@ if [ "$upgrade_type" == "UPGRADE_APP" ]; then
# Download, check integrity, uncompress and patch the source from app.src
ynh_setup_source --dest_dir="$install_dir" --full_replace=1 --keep ".env .ssh/authorized_keys restart_services.sh"
# Always update .env
ynh_add_config --template=".env" --destination="$install_dir/.env"
# FIXME: this should be handled by the core in the future
# You may need to use chmod 600 instead of 400,
# for example if the app is expected to be able to modify its own config
chmod 400 "$install_dir/.env"
chown $app:$app "$install_dir/.env"
fi
chmod -R o-rwx "$install_dir"
@ -124,6 +137,11 @@ ynh_script_progression --message="Upgrading MongoDB..." --weight=1
# Install the required version of Mongo
ynh_install_mongo --mongo_version=$mongo_version
# We are now assigning the user to the database, so update the user's rights
for db_name in "${MONGO_DB_LIST[@]}"; do
ynh_mongo_setup_db --db_user="$db_user" --db_pwd="$db_pwd" --db_name="dontCode$tenant${db_name}"
done
#=================================================
# REAPPLY SYSTEM CONFIGURATIONS
#=================================================

View file

@ -5,10 +5,12 @@ test_format = 1.0
[default]
args.public_key = ""
args.tenant = "Test"
# -------------------------------
# Commits to test upgrade from
# -------------------------------
test_upgrade_from.7852cc4bf44ff20ee51fe35f3f53dc105e0f6d79.name= "2023-01-07 - Added Ssh support for dev."
test_upgrade_from.e89eebdac9f59202202d07972e274ebe6fc7c51c.name= "Before Manifest v2."
test_upgrade_from.13b9ba1eb3ccad38329ee2c7dadad00c18fe5e83.name= "Before switching to multi_instance."