Przeglądaj źródła

Require separate SSH user in Pi deploy script

master
Daniel Covington 1 tydzień temu
rodzic
commit
36bd4c8588
2 zmienionych plików z 15 dodań i 13 usunięć
  1. +7
    -6
      docs/deploy-raspberry-pi.md
  2. +8
    -7
      scripts/deploy-raspi.sh

+ 7
- 6
docs/deploy-raspberry-pi.md Wyświetl plik

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

```bash
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:

- 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

@@ -44,7 +45,7 @@ Arguments:
DEPLOY_REF=main \
DEPLOY_PATH=/var/www/warehouse \
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
@@ -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
- 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
- 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 Wyświetl plik

@@ -1,19 +1,20 @@
#!/usr/bin/env bash
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
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_ref="${DEPLOY_REF:-main}"
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

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

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

Ładowanie…
Anuluj
Zapisz

Powered by TurnKey Linux.