1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/bonfire_ynh.git synced 2024-09-03 18:16:01 +02:00

Merge pull request #9 from bonfire-networks/use-release

Use precompiled release
This commit is contained in:
lapineige 2024-04-16 21:03:06 +00:00 committed by GitHub
commit d80e0c6629
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 63 additions and 39 deletions

View file

@ -1,3 +1,4 @@
MIX_ENV=prod
FLAVOUR=classic
@ -82,3 +83,9 @@ GITHUB_TOKEN=
TX_TOKEN=
## END OF SECRETS ##
ENABLE_IMAGE_VIX=1
# enable these two if deps fetching is failing
# HEX_HTTP_CONCURRENCY=1
# HEX_HTTP_TIMEOUT=120

View file

@ -7,9 +7,8 @@ Type=simple
User=__APP__
Group=__APP__
WorkingDirectory=__INSTALL_DIR__/
Environment=NODE_ENV=production
Environment="__YNH_NODE_LOAD_PATH__"
ExecStart=just cmd __INSTALL_DIR__/_build/prod/rel/bonfire/bin/bonfire start daemon
EnvironmentFile=__INSTALL_DIR__/.env
ExecStart=__INSTALL_DIR__/bin/bonfire start daemon
StandardOutput=append:/var/log/__APP__/__APP__.log
StandardError=inherit

View file

@ -50,7 +50,7 @@ ram.runtime = "500M"
ask.fr = "Choisissez la langue de l'application"
type = "select"
choices = ["fr", "en"]
default = "fr"
default = "en"
[install.admin]
type = "user"
@ -91,8 +91,18 @@ ram.runtime = "500M"
[resources.sources]
[resources.sources.main]
url = "https://github.com/bonfire-networks/bonfire-app/archive/184bbda72efbdddbdd94afb4b3790591414b5cbe.tar.gz"
sha256 = "60b49d30549b9eb0b7308e82fcd7697d4d12d2722dbd53fdb6fe563f1e399059"
# TODO: multiple architectures
url = "https://github.com/bonfire-networks/bonfire-app/releases/download/v0.9.10-beta.61/bonfire-classic-amd64-debian-bullseye.tar.gz"
sha256 = "8bc36f1c10e63659d0a286d82b5fd38233f545e7100fb03e63db4b0de7b6fe8d"
autoupdate.strategy = "latest_github_release"
[resources.sources.deps_install]
url = "https://github.com/bonfire-networks/bonfire-app/raw/a57ad00dd18bfe558fc398938f19c92b48c60ff6/deps-debian.sh"
sha256 = "56624dc90719e2182f8116e63d9784079ce47e19892410f37ce5aa3de2a22b57"
format = "script"
rename = "deps-debian.sh"
extract = false
[resources.ports]
@ -106,20 +116,20 @@ ram.runtime = "500M"
[resources.apt]
packages = "erlang-dev erlang-parsetools erlang-os-mon erlang-tools erlang-xmerl postgresql npm node-postcss"
packages = "postgresql"
##### (this part is optional and corresponds to the legacy ynh_install_extra_app_dependencies helper)
### Yarn dependency (correct version)
extras.yarn.repo = "deb https://dl.yarnpkg.com/debian/ stable main"
extras.yarn.key = "https://dl.yarnpkg.com/debian/pubkey.gpg"
extras.yarn.packages = ["yarn"]
# extras.yarn.repo = "deb https://dl.yarnpkg.com/debian/ stable main"
# extras.yarn.key = "https://dl.yarnpkg.com/debian/pubkey.gpg"
# extras.yarn.packages = ["yarn"]
### Elixir 13 dependency - instead of v15 for now
extras.elixir13.repo = "deb https://packages.erlang-solutions.com/debian bullseye contrib"
extras.elixir13.key = "https://packages.erlang-solutions.com/debian/erlang_solutions.asc"
extras.elixir13.packages = ["elixir"]
# extras.elixir13.repo = "deb https://packages.erlang-solutions.com/debian bullseye contrib"
# extras.elixir13.key = "https://packages.erlang-solutions.com/debian/erlang_solutions.asc"
# extras.elixir13.packages = ["elixir"]
### Elixir 15 dependency
# Bulleyes comes with v1.10 instead of v1.15 that is required
# ynh_install_extra_app_dependencies --repo="https://packages.erlang-solutions.com/debian bullseye contrib" --package="elixir-lang" --key='https://packages.erlang-solutions.com/debian/erlang_solutions.asc'
@ -138,9 +148,9 @@ ram.runtime = "500M"
# TODO : this is unsafe and should be dealt with in a better way.
# There is currently no proper way to install it simply on Debian 11 https://github.com/casey/just#packages
# only works for x86, we need to switch to the other option with makedeb package ?
extras.just.repo = "deb https://proget.makedeb.org prebuilt-mpr bullseye"
extras.just.key = "https://proget.makedeb.org/debian-feeds/prebuilt-mpr.pub"
extras.just.packages = ["just"]
# extras.just.repo = "deb https://proget.makedeb.org prebuilt-mpr bullseye"
# extras.just.key = "https://proget.makedeb.org/debian-feeds/prebuilt-mpr.pub"
# extras.just.packages = ["just"]
[resources.database]

View file

@ -9,24 +9,31 @@
source _common.sh
source /usr/share/yunohost/helpers
#=================================================
# INSTALL DEPENDENCIES
#=================================================
ynh_script_progression --message="Installing nodejs..."
ynh_exec_warn_less ynh_install_nodejs --nodejs_version=$nodejs_version
ynh_use_nodejs
#=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE
#=================================================
ynh_script_progression --message="Setting up source files..." --weight=1
# Download deps install script
ynh_setup_source --source_id=deps_install --dest_dir="$install_dir"
# Download, check integrity, uncompress and patch the source from app.src
ynh_setup_source --dest_dir="$install_dir"
chmod -R o-rwx "$install_dir"
chown -R $app:www-data "$install_dir"
chmod +x "$install_dir/deps-debian.sh"
ls -la "$install_dir"
#=================================================
# INSTALL DEPENDENCIES
#=================================================
ynh_script_progression --message="Installing dependencies..."
ynh_exec_warn_less "HOME=$install_dir $install_dir/deps-debian.sh"
# ynh_exec_warn_less ynh_install_nodejs --nodejs_version=$nodejs_version
# ynh_use_nodejs
#=================================================
# NGINX CONFIGURATION
@ -55,36 +62,36 @@ ynh_store_file_checksum --file="$install_dir/.env"
chmod 400 "$install_dir/.env"
chown $app:$app "$install_dir/.env"
#=================================================
# SPECIFIC SETUP
#=================================================
source $install_dir/.env
export WITH_DOCKER=no # or source .env ? # Using this for now
export TERM=linux # why is that not defined ?
export TERMINFO=/etc/terminfo
export PATH="$PATH:$install_dir/.local/share/mise/shims"
ynh_script_progression --message="Configuring Bonfire release..." --weight=1
ynh_script_progression --message="Preparing Bonfire release..." --weight=1
cd $install_dir
#ynh_exec_warn_less ynh_exec_as $app -s $SHELL -lc "mise plugin add erlang https://github.com/asdf-vm/asdf-erlang.git" # add erlang as source
#ynh_exec_warn_less ynh_exec_as $app -s $SHELL -lc "mise install" # install Elixir
ynh_exec_warn_less ynh_exec_as $app -s $SHELL -lc "WITH_DOCKER=no $ynh_node_load_PATH mix local.hex --force" # install Hex in non-interractive way
ynh_exec_warn_less ynh_exec_as $app -s $SHELL -lc "WITH_DOCKER=no $ynh_node_load_PATH just config-basic"
#ynh_exec_warn_less ynh_exec_as $app -s $SHELL -lc "WITH_DOCKER=no $ynh_node_load_PATH just mix bonfire.deps .update"
# ynh_exec_warn_less ynh_exec_as $app -s $SHELL -lc "$ynh_node_load_PATH mix local.hex --force" # install Hex in non-interractive way
### DONT USE GLOBAL NPM INSTALL
# ynh_replace_string --match_string="npm install --global" --replace_string="npm install" --target_file="$install_dir/justfile"
#=================================================
# Building the release
#=================================================
ynh_script_progression --message="Building Bonfire release... (This will take a long time)" --weight=1
export TERM=linux # why is that not defined ?
export TERMINFO=/etc/terminfo
### DONT USE GLOBAL NPM INSTALL
ynh_replace_string --match_string="npm install --global" --replace_string="npm install" --target_file="$install_dir/justfile"
ynh_exec_warn_less ynh_exec_as $app -s $SHELL -lc "WITH_DOCKER=no $ynh_node_load_PATH just rel-build"
# ynh_script_progression --message="Building Bonfire release... (this will take a long time)" --weight=1
# ynh_exec_warn_less ynh_exec_as $app -s $SHELL -lc "WITH_DOCKER=no $ynh_node_load_PATH just config-basic"
#ynh_exec_warn_less ynh_exec_as $app -s $SHELL -lc "WITH_DOCKER=no $ynh_node_load_PATH just mix bonfire.deps.update"
# ynh_exec_warn_less ynh_exec_as $app -s $SHELL -lc "WITH_DOCKER=no $ynh_node_load_PATH just rel-build"
#=================================================
# START SYSTEMD SERVICE - Run the release
#=================================================
release_folder="_build/prod/rel/bonfire"
release_folder="./"
### Not running the migration, they are done on startup anyway
#ynh_script_progression --message="Running database migrations..." --weight=1
@ -114,7 +121,7 @@ ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$ap
# CREATE ADMIN USER
#=================================================
ynh_script_progression --message="Creating admin user account..." --weight=1
ynh_exec_warn_less ynh_exec_as $app -s $SHELL -lc "WITH_DOCKER=no just cmd /var/www/bonfire/_build/prod/rel/bonfire/bin/bonfire rpc 'Bonfire.Me.make_account_and_user(\"$admin\", \"$(ynh_user_get_info --username=\"$admin\" --key=mail)\", \"$password\")'"
ynh_exec_warn_less ynh_exec_as $app -s $SHELL -lc "$install_dir/bin/bonfire rpc 'Bonfire.Me.make_account_and_user(\"$admin\", \"$(ynh_user_get_info --username=\"$admin\" --key=mail)\", \"$password\")'"
#=================================================
# END OF SCRIPT

View file

@ -40,9 +40,10 @@ chown -R $app:www-data "$install_dir"
ynh_script_progression --message="Building Bonfire release... (This will take a long time)" --weight=1
export TERM=linux # why is that not defined ?
export TERMINFO=/etc/terminfo
### DONT USE GLOBAL NPM INSTALL
ynh_replace_string --match_string="npm install --global" --replace_string="npm install" --target_file="$install_dir/justfile"
ynh_exec_warn_less ynh_exec_as $app -s $SHELL -lc "WITH_DOCKER=no $ynh_node_load_PATH just rel-build"
# ynh_replace_string --match_string="npm install --global" --replace_string="npm install" --target_file="$install_dir/justfile"
# ynh_exec_warn_less ynh_exec_as $app -s $SHELL -lc "WITH_DOCKER=no $ynh_node_load_PATH just rel-build"
#=================================================
# RECONFIGURE THE APP (UPDATE CONF, APPLY MIGRATIONS...)