diff --git a/conf/back.env b/conf/back.env index 9942f1e..9a88881 100644 --- a/conf/back.env +++ b/conf/back.env @@ -1,2 +1,2 @@ -FRONTEND_URL=http://__DOMAIN__/__PATH__ -DATABASE_URL=postgres://__DB_USER__:__DB_PWD__/__DB__NAME__ +FRONTEND_URL=https://__DOMAIN__/__PATH__ +DATABASE_URL=postgres://__DB_USER__:__DB_PWD__@localhost:5432/__DB_NAME__ diff --git a/conf/crabfit-front.service b/conf/crabfit-front.service index a1f2200..9e4c7f3 100644 --- a/conf/crabfit-front.service +++ b/conf/crabfit-front.service @@ -10,6 +10,8 @@ Group=__APP__ WorkingDirectory=__INSTALL_DIR__/frontend StandardOutput=append:/var/log/__APP__/__APP__-front.log StandardError=inherit +Environment=__YNH_NODE_LOAD_PATH__ +Environment=PORT=__PORT__ ExecStart=__YNH_NPM__ run start # Sandboxing options to harden security diff --git a/conf/front.env b/conf/front.env index 4214c4e..4b553a4 100644 --- a/conf/front.env +++ b/conf/front.env @@ -1,3 +1,4 @@ -NEXT_PUBLIC_API_URL=http://__DOMAIN__/api +NEXT_PUBLIC_API_URL=https://__DOMAIN__/__PATH__/api NEXT_TELEMETRY_DISABLED=1 NODE_ENV=production +NODE_TLS_REJECT_UNAUTHORIZED='0' diff --git a/scripts/install b/scripts/install index ba91d31..0dcbb8b 100755 --- a/scripts/install +++ b/scripts/install @@ -29,9 +29,10 @@ ynh_use_nodejs ynh_script_progression --message="Adding system configurations related to $app..." --weight=1 # Create a dedicated NGINX config using the conf/nginx.conf template -ynh_add_config --template="../conf/crabfit.target" --destination="/etc/systemd/system/$app.target" +ynh_add_nginx_config # Create a dedicated systemd config +ynh_add_config --template="../conf/crabfit.target" --destination="/etc/systemd/system/$app.target" ynh_add_systemd_config --service="${app}-front" --template="crabfit-front.service" ynh_add_systemd_config --service="${app}-back" --template="crabfit-back.service" @@ -63,6 +64,11 @@ ynh_script_progression --message="Building crabfit backend..." --weight=1 # The cargo version packaged with debian (currently 11) is too old and results in errors.. # Thus the latest version is manually installed alongside the application for the moment pushd $install_dir/api + # The API port is currently hard-coded instead of being in a .env + # TODO: MR to the upstream + # In the meantime, lets do some sed! + sed "s/3000/$port_api/g" src/main.rs + curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs > rustup.sh ynh_exec_warn_less ynh_exec_as "$app" \ RUSTUP_HOME=$install_dir/api/.rustup \ @@ -72,7 +78,7 @@ pushd $install_dir/api ynh_exec_warn_less ynh_exec_as "$app" \ RUSTUP_HOME=$install_dir/api/.rustup \ CARGO_HOME=$install_dir/api/.cargo \ - $install_dir/api/.cargo/bin/cargo build --release #--features sql-adaptor + $install_dir/api/.cargo/bin/cargo build --release --features sql-adaptor # Remove build files and rustup # cp -af "$install_dir/api/target/release/crabfit-api" "$install_dir/api/api" @@ -86,9 +92,9 @@ popd #================================================= ynh_script_progression --message="Building crabfit frontend..." --weight=1 pushd $install_dir/frontend - ynh_exec_warn_less ynh_exec_as "$app" $nodejs_path/corepack enable - ynh_exec_warn_less ynh_exec_as "$app" $nodejs_path/yarn install --production --frozen-lockfile - ynh_exec_warn_less ynh_exec_as "$app" $ynh_npm run build + ynh_exec_warn_less ynh_exec_as "$app" env "$ynh_node_load_PATH" $nodejs_path/corepack enable + ynh_exec_warn_less ynh_exec_as "$app" env "$ynh_node_load_PATH" $nodejs_path/yarn install --production --frozen-lockfile + ynh_exec_warn_less ynh_exec_as "$app" env "$ynh_node_load_PATH" $ynh_npm run build popd #================================================= @@ -99,9 +105,8 @@ popd ynh_script_progression --message="Starting systemd services..." --weight=1 # Start a systemd service -# Changed the log path to systemd accoding to what funkwhale_ynh does but dunno why -ynh_systemd_action --service_name="${app}-front" --action="start" --log_path="systemd" -ynh_systemd_action --service_name="${app}-back" --action="start" --log_path="systemd" +ynh_systemd_action --service_name="${app}-front" --action="start" --log_path="/var/log/$app/${app}-front.log" +ynh_systemd_action --service_name="${app}-back" --action="start" --log_path="/var/log/$app/${app}-back.log" #================================================= # END OF SCRIPT