Просмотр исходного кода

Require separate SSH user in Pi deploy script

master
Daniel Covington 1 неделю назад
Родитель
Сommit
36bd4c8588
2 измененных файлов: 15 добавлений и 13 удалений
  1. +7
    -6
      docs/deploy-raspberry-pi.md
  2. +8
    -7
      scripts/deploy-raspi.sh

+ 7
- 6
docs/deploy-raspberry-pi.md Просмотреть файл

@@ -29,14 +29,15 @@ From this repo on your local machine:


```bash ```bash
chmod +x scripts/deploy-raspi.sh chmod +x scripts/deploy-raspi.sh
scripts/deploy-raspi.sh pi@raspberrypi.local git@github.com:YOUR_USER/warehouse.git DietPi.ntp.kentcommunications.com
scripts/deploy-raspi.sh pi raspberrypi.local git@github.com:YOUR_USER/warehouse.git DietPi.ntp.kentcommunications.com
``` ```


Arguments: Arguments:


- argument 1: SSH target, for example `pi@192.168.1.50`
- argument 2: Git clone URL the Pi can access
- argument 3: nginx `server_name` value, optional, defaults to `DietPi.ntp.kentcommunications.com`
- argument 1: SSH user, for example `pi`
- argument 2: SSH host, for example `192.168.1.50`
- argument 3: Git clone URL the Pi can access
- argument 4: nginx `server_name` value, optional, defaults to `DietPi.ntp.kentcommunications.com`


## Useful environment overrides ## Useful environment overrides


@@ -44,7 +45,7 @@ Arguments:
DEPLOY_REF=main \ DEPLOY_REF=main \
DEPLOY_PATH=/var/www/warehouse \ DEPLOY_PATH=/var/www/warehouse \
PHP_VERSION=8.2 \ PHP_VERSION=8.2 \
scripts/deploy-raspi.sh pi@raspberrypi.local git@github.com:YOUR_USER/warehouse.git DietPi.ntp.kentcommunications.com
scripts/deploy-raspi.sh pi raspberrypi.local git@github.com:YOUR_USER/warehouse.git DietPi.ntp.kentcommunications.com
``` ```


## After deploy ## After deploy
@@ -59,4 +60,4 @@ scripts/deploy-raspi.sh pi@raspberrypi.local git@github.com:YOUR_USER/warehouse.
- the app serves from `public/`, so the nginx root must stay pointed there - the app serves from `public/`, so the nginx root must stay pointed there
- low-stock emails are always queued in this app, so the queue worker service matters in production - low-stock emails are always queued in this app, so the queue worker service matters in production
- this script sets up **HTTP only**; add TLS separately with `certbot` or another reverse-proxy setup if you want HTTPS - this script sets up **HTTP only**; add TLS separately with `certbot` or another reverse-proxy setup if you want HTTPS
- if you prefer MySQL instead of SQLite, update `.env` and the script before rerunning it
- if you prefer MySQL instead of SQLite, update `.env` and the script before rerunning it

+ 8
- 7
scripts/deploy-raspi.sh Просмотреть файл

@@ -1,19 +1,20 @@
#!/usr/bin/env bash #!/usr/bin/env bash
set -euo pipefail set -euo pipefail


if [ "$#" -lt 2 ] || [ "$#" -gt 3 ]; then
echo "Usage: scripts/deploy-raspi.sh <ssh-host> <git-repo> [domain]"
if [ "$#" -lt 3 ] || [ "$#" -gt 4 ]; then
echo "Usage: scripts/deploy-raspi.sh <ssh-user> <ssh-host> <git-repo> [domain]"
exit 1 exit 1
fi fi


ssh_host="$1"
repo_url="$2"
domain="${3:-DietPi.ntp.kentcommunications.com}"
ssh_user="$1"
ssh_host="$2"
repo_url="$3"
domain="${4:-DietPi.ntp.kentcommunications.com}"
deploy_path="${DEPLOY_PATH:-/var/www/warehouse}" deploy_path="${DEPLOY_PATH:-/var/www/warehouse}"
deploy_ref="${DEPLOY_REF:-main}" deploy_ref="${DEPLOY_REF:-main}"
php_version="${PHP_VERSION:-8.2}" php_version="${PHP_VERSION:-8.2}"


ssh "$ssh_host" bash -s -- "$repo_url" "$domain" "$deploy_path" "$deploy_ref" "$php_version" <<'REMOTE'
ssh "${ssh_user}@${ssh_host}" bash -s -- "$repo_url" "$domain" "$deploy_path" "$deploy_ref" "$php_version" <<'REMOTE'
set -euo pipefail set -euo pipefail


repo_url="$1" repo_url="$1"
@@ -122,4 +123,4 @@ sudo systemctl restart nginx
sudo systemctl restart warehouse-queue.service sudo systemctl restart warehouse-queue.service


echo "Deployment complete: http://${domain}" echo "Deployment complete: http://${domain}"
REMOTE
REMOTE

Загрузка…
Отмена
Сохранить

Powered by TurnKey Linux.