chore: configurable deployment
This commit is contained in:
1 parent
caeb47be11
commit
6be745a6f4
6 files changed
+62
-30
No files matched your search
@@ -0,0 +1,2 @@
|
|||||||
|
domain=hub.hordelab.com
|
||||||
|
install_path=/var/horde/hub/
|
||||||
+50
-21
@@ -2,42 +2,71 @@
|
|||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
cd "$(dirname "$0")"
|
cd "$(dirname "$0")"
|
||||||
|
|
||||||
host="root@hub.hordelab.com"
|
if [ ! -f .env ]; then
|
||||||
remote_path="/var/horde/hub/"
|
echo ".env file not found. You can create one by copying the provided example:"
|
||||||
|
echo "cp $(dirname "$0")/example.env $(dirname "$0")/.env"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
source .env
|
||||||
|
|
||||||
|
# Required: crash if not set in .env
|
||||||
|
: "${domain:?domain is not defined in .env}"
|
||||||
|
: "${install_path:?install_path is not defined in .env}"
|
||||||
|
|
||||||
|
# Optional: fall back to defaults
|
||||||
|
: "${data_path:=$install_path/local-data}"
|
||||||
|
: "${launch_path:=$data_path/hub-launch.sh}"
|
||||||
|
: "${service_name:=horde-hub}"
|
||||||
|
: "${port:=17922}"
|
||||||
|
: "${remote:=$domain}"
|
||||||
|
|
||||||
|
read_template() {
|
||||||
|
sed \
|
||||||
|
-e "s/\$DOMAIN/$domain/g" \
|
||||||
|
-e "s|\$INSTALL_PATH|$install_path|g" \
|
||||||
|
-e "s|\$LAUNCH_PATH|$launch_path|g" \
|
||||||
|
-e "s|\$DATA_PATH|$data_path|g" \
|
||||||
|
-e "s/\$SERVICE_NAME/$service_name/g" \
|
||||||
|
-e "s/\$PORT/$port/g" \
|
||||||
|
template/$1
|
||||||
|
}
|
||||||
|
|
||||||
|
upload_template() {
|
||||||
|
read_template $1 | ssh $remote "cat > \"$2\""
|
||||||
|
}
|
||||||
|
|
||||||
run_nginx() {
|
run_nginx() {
|
||||||
echo "Uploading nginx config file"
|
echo "Uploading nginx config file"
|
||||||
scp template/nginx.conf "$host:/etc/nginx/sites-enabled/hub.hordelab.com"
|
upload_template nginx.conf "/etc/nginx/sites-enabled/$domain"
|
||||||
ssh "$host" -t "
|
ssh $remote -t "
|
||||||
nginx -s reload
|
|
||||||
|
|
||||||
# full process is currently broken
|
# full process is currently broken
|
||||||
#certbot --keep -d hub.hordelab.com
|
#certbot --keep -d $domain
|
||||||
|
|
||||||
# uncomment if needed
|
# uncomment if needed
|
||||||
#certbot certonly -d hub.hordelab.com
|
#certbot certonly -d $domain
|
||||||
|
|
||||||
#nginx -s reload
|
nginx -s reload
|
||||||
"
|
"
|
||||||
}
|
}
|
||||||
|
|
||||||
run_service() {
|
run_service() {
|
||||||
echo "Uploading Launcher and Service"
|
echo "Uploading Launcher and Service"
|
||||||
scp template/launch-hub.sh "$host:/var/horde/launch-hub.sh"
|
upload_template launch-hub.sh $launch_path
|
||||||
scp template/systemd.service "$host:/etc/systemd/system/horde-hub.service"
|
upload_template systemd.service "/etc/systemd/system/$service_name.service"
|
||||||
ssh "$host" -t "
|
|
||||||
|
ssh $remote -t "
|
||||||
systemctl daemon-reload
|
systemctl daemon-reload
|
||||||
systemctl enable horde-hub.service
|
systemctl enable $service_name.service
|
||||||
systemctl start horde-hub.service
|
systemctl start $service_name.service
|
||||||
"
|
"
|
||||||
}
|
}
|
||||||
|
|
||||||
run_update() {
|
run_update() {
|
||||||
echo "Updating repository"
|
echo "Updating repository"
|
||||||
ssh "$host" -t "
|
ssh $remote -t "
|
||||||
source ~/.nvm/nvm.sh #?
|
source ~/.nvm/nvm.sh #?
|
||||||
|
|
||||||
cd /var/horde/hub
|
cd $install_path
|
||||||
git pull
|
git pull
|
||||||
make install
|
make install
|
||||||
make web
|
make web
|
||||||
@@ -45,14 +74,14 @@ run_update() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
run_dist() {
|
run_dist() {
|
||||||
echo "Uploading frontend/dist to $host:/var/frontend/dist"
|
echo "Uploading frontend/dist to $remote:$install_path/frontend/dist"
|
||||||
ssh "$host" "rm -rf $remote_path/frontend/dist && mkdir $remote_path/frontend/dist"
|
ssh $remote "rm -rf $install_path/frontend/dist && mkdir $install_path/frontend/dist"
|
||||||
scp -r ../frontend/dist "$host:$remote_path/frontend/"
|
scp -r ../frontend/dist $remote:$install_path/frontend/
|
||||||
}
|
}
|
||||||
|
|
||||||
restart_service() {
|
restart_service() {
|
||||||
echo "Restarting horde-hub.service"
|
echo "Restarting $service_name.service"
|
||||||
ssh "$host" -t "systemctl restart horde-hub.service"
|
ssh $remote -t "systemctl restart $service_name.service"
|
||||||
}
|
}
|
||||||
|
|
||||||
# Determine which stages to run
|
# Determine which stages to run
|
||||||
|
|||||||
@@ -1,8 +1,9 @@
|
|||||||
|
|
||||||
|
# Remove tracked keys lmao
|
||||||
export OPENAI_API_KEY=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
|
export OPENAI_API_KEY=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
|
||||||
export REPLICATE_API_KEY=r8_J1lnphqfZNUtK9CIh81SE4uHWWKJuvR3tr8S2
|
export REPLICATE_API_KEY=r8_J1lnphqfZNUtK9CIh81SE4uHWWKJuvR3tr8S2
|
||||||
export OPENROUTER_API_KEY=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
|
export OPENROUTER_API_KEY=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
|
||||||
export HORDE_DATA_DIR=/var/horde/hub-data
|
|
||||||
|
|
||||||
|
export HORDE_DATA_DIR=$DATA_PATH
|
||||||
echo Starting Horde Server
|
echo Starting Horde Server
|
||||||
/var/horde/hub/.venv/bin/python3 /var/horde/hub/backend/src/app.py
|
$INSTALL_PATH/.venv/bin/python3 $INSTALL_PATH/backend/src/app.py
|
||||||
@@ -2,7 +2,7 @@
|
|||||||
server {
|
server {
|
||||||
listen 80;
|
listen 80;
|
||||||
listen [::]:80;
|
listen [::]:80;
|
||||||
server_name hub.hordelab.com;
|
server_name $DOMAIN;
|
||||||
|
|
||||||
return 301 https://$host$request_uri;
|
return 301 https://$host$request_uri;
|
||||||
}
|
}
|
||||||
@@ -12,13 +12,13 @@ server {
|
|||||||
listen 443 ssl;
|
listen 443 ssl;
|
||||||
listen [::]:443 ssl;
|
listen [::]:443 ssl;
|
||||||
|
|
||||||
server_name hub.hordelab.com;
|
server_name $DOMAIN;
|
||||||
|
|
||||||
ssl_certificate /etc/letsencrypt/live/hub.hordelab.com/fullchain.pem;
|
ssl_certificate /etc/letsencrypt/live/$DOMAIN/fullchain.pem;
|
||||||
ssl_certificate_key /etc/letsencrypt/live/hub.hordelab.com/privkey.pem;
|
ssl_certificate_key /etc/letsencrypt/live/$DOMAIN/privkey.pem;
|
||||||
|
|
||||||
location / {
|
location / {
|
||||||
proxy_pass http://localhost:17922;
|
proxy_pass http://localhost:$PORT;
|
||||||
proxy_http_version 1.1;
|
proxy_http_version 1.1;
|
||||||
|
|
||||||
# Websocket support
|
# Websocket support
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ After=network.target
|
|||||||
[Service]
|
[Service]
|
||||||
Type=simple
|
Type=simple
|
||||||
Restart=always
|
Restart=always
|
||||||
ExecStart=bash /var/horde/launch-hub.sh
|
ExecStart=bash $LAUNCH_PATH
|
||||||
|
|
||||||
[Install]
|
[Install]
|
||||||
WantedBy=multi-user.target
|
WantedBy=multi-user.target
|
||||||
Reference in new issue
Block a user