fix: быстрое развёртывание — PGDG, /opt/shop/shop10, без placeholder URL
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
+10
-4
@@ -1,4 +1,4 @@
|
||||
# Shop — документация v0.10.0
|
||||
# Shop — документация v0.20.0
|
||||
|
||||
Интернет-магазин на **Node.js** и **PostgreSQL 17**.
|
||||
|
||||
@@ -30,9 +30,15 @@ cp .env.docker.example .env && docker compose up -d --build
|
||||
### Без Docker
|
||||
|
||||
```bash
|
||||
git clone https://git.evilfox.cc/test/shop10.git && cd shop10
|
||||
git checkout v0.10.0
|
||||
# см. Install-Native
|
||||
git clone https://git.evilfox.cc/test/shop10.git /opt/shop/shop10
|
||||
cd /opt/shop/shop10
|
||||
sudo bash scripts/quick-deploy-ubuntu.sh
|
||||
```
|
||||
|
||||
Обновление на работающем сервере:
|
||||
|
||||
```bash
|
||||
bash /opt/shop/shop10/scripts/server-update.sh
|
||||
```
|
||||
|
||||
## Проверка работы
|
||||
|
||||
+12
-24
@@ -26,38 +26,26 @@ node -v # v20.x
|
||||
|
||||
### PostgreSQL 17
|
||||
|
||||
```bash
|
||||
apt install -y postgresql-17 postgresql-client-17
|
||||
systemctl enable postgresql
|
||||
systemctl start postgresql
|
||||
pg_isready -h 127.0.0.1 -p 5432
|
||||
```
|
||||
|
||||
Если пакет `postgresql-17` не найден — [репозиторий PGDG](https://www.postgresql.org/download/linux/ubuntu/):
|
||||
Не используйте `apt install postgresql-17` без PGDG — пакет не найдётся. Скрипт подключает PGDG автоматически:
|
||||
|
||||
```bash
|
||||
apt install -y curl ca-certificates
|
||||
install -d /usr/share/postgresql-common/pgdg
|
||||
curl -o /usr/share/postgresql-common/pgdg/apt.postgresql.org.asc --fail \
|
||||
https://www.postgresql.org/media/keys/ACCC4CF8.asc
|
||||
sh -c 'echo "deb [signed-by=/usr/share/postgresql-common/pgdg/apt.postgresql.org.asc] https://apt.postgresql.org/pub/repos/apt $(. /etc/os-release && echo ${VERSION_CODENAME}-pgdg) main" > /etc/apt/sources.list.d/pgdg.list'
|
||||
apt update
|
||||
apt install -y postgresql-17 postgresql-client-17
|
||||
sudo bash /opt/shop/shop10/scripts/install-postgresql-ubuntu.sh
|
||||
```
|
||||
|
||||
## 3. Клонирование проекта
|
||||
|
||||
```bash
|
||||
cd /opt
|
||||
git clone https://git.evilfox.cc/test/shop10.git shop
|
||||
cd shop
|
||||
git checkout v0.10.0
|
||||
git clone https://git.evilfox.cc/test/shop10.git /opt/shop/shop10
|
||||
cd /opt/shop/shop10/shop10
|
||||
git checkout v0.20.0
|
||||
```
|
||||
|
||||
Или быстрая установка всего стека: `sudo bash scripts/quick-deploy-ubuntu.sh`
|
||||
|
||||
## 4. База данных PostgreSQL
|
||||
|
||||
```bash
|
||||
cd /opt/shop
|
||||
cd /opt/shop/shop10/shop10
|
||||
bash scripts/setup-postgres-ubuntu.sh
|
||||
```
|
||||
|
||||
@@ -101,7 +89,7 @@ openssl rand -hex 32
|
||||
## 6. Установка зависимостей Node.js
|
||||
|
||||
```bash
|
||||
cd /opt/shop
|
||||
cd /opt/shop/shop10
|
||||
npm install --omit=dev
|
||||
```
|
||||
|
||||
@@ -110,7 +98,7 @@ npm install --omit=dev
|
||||
## 7. Служба systemd
|
||||
|
||||
```bash
|
||||
cp /opt/shop/deploy/shop.service /etc/systemd/system/shop.service
|
||||
cp /opt/shop/shop10/deploy/shop.service /etc/systemd/system/shop.service
|
||||
systemctl daemon-reload
|
||||
systemctl enable shop
|
||||
systemctl start shop
|
||||
@@ -152,7 +140,7 @@ apt update && apt install -y caddy
|
||||
Конфигурация:
|
||||
|
||||
```bash
|
||||
cp /opt/shop/caddy/Caddyfile.example /etc/caddy/Caddyfile
|
||||
cp /opt/shop/shop10/caddy/Caddyfile.example /etc/caddy/Caddyfile
|
||||
nano /etc/caddy/Caddyfile
|
||||
```
|
||||
|
||||
@@ -195,7 +183,7 @@ systemctl daemon-reload
|
||||
## 10. Обновление
|
||||
|
||||
```bash
|
||||
cd /opt/shop/shop10
|
||||
cd /opt/shop/shop10/shop10
|
||||
git config --global --add safe.directory "$(pwd)"
|
||||
bash scripts/server-update.sh
|
||||
```
|
||||
|
||||
+25
-3
@@ -8,6 +8,28 @@ bash /opt/shop/shop10/scripts/diagnose-502.sh
|
||||
|
||||
(замените путь на каталог вашего клона — где есть `package.json`)
|
||||
|
||||
## Ошибки при «быстром развёртывании»
|
||||
|
||||
| Ошибка | Причина | Решение |
|
||||
|--------|---------|---------|
|
||||
| `Unable to locate package postgresql-17` | В Ubuntu нет PG 17 без PGDG | `sudo bash /opt/shop/shop10/scripts/install-postgresql-ubuntu.sh` |
|
||||
| `URL_РЕПОЗИТОРИЯ: No such file` | Скопирован placeholder из README | Используйте реальный URL: `git clone https://git.evilfox.cc/test/shop10.git /opt/shop/shop10` |
|
||||
| `package.json` в `/opt/shop` | Неверный каталог | Репозиторий в `/opt/shop/shop10` |
|
||||
| Изменения не применились | `git pull` не в том каталоге | `bash /opt/shop/shop10/scripts/server-update.sh` |
|
||||
|
||||
Полное развёртывание / обновление:
|
||||
|
||||
```bash
|
||||
cd /opt/shop/shop10 && git pull
|
||||
sudo bash scripts/quick-deploy-ubuntu.sh
|
||||
```
|
||||
|
||||
Только обновление кода (сайт уже работает):
|
||||
|
||||
```bash
|
||||
bash /opt/shop/shop10/scripts/server-update.sh
|
||||
```
|
||||
|
||||
## scripts/server-update.sh: No such file or directory
|
||||
|
||||
Вы не в каталоге репозитория или клон в подпапке (например `/opt/shop/shop10`):
|
||||
@@ -40,7 +62,7 @@ journalctl -u shop -n 30 --no-pager
|
||||
PostgreSQL не запущен или не установлен.
|
||||
|
||||
```bash
|
||||
bash /opt/shop/scripts/fix-db-connection.sh
|
||||
bash /opt/shop/shop10/scripts/fix-db-connection.sh
|
||||
```
|
||||
|
||||
Или вручную:
|
||||
@@ -51,7 +73,7 @@ pg_isready -h 127.0.0.1 -p 5432
|
||||
bash scripts/setup-postgres-ubuntu.sh
|
||||
```
|
||||
|
||||
Проверьте `DATABASE_URL` в `/opt/shop/.env`.
|
||||
Проверьте `DATABASE_URL` в `/opt/shop/shop10/.env`.
|
||||
|
||||
---
|
||||
|
||||
@@ -60,7 +82,7 @@ bash scripts/setup-postgres-ubuntu.sh
|
||||
В логе только «База уже содержит товары» без строки `Магазин: http://...`:
|
||||
|
||||
```bash
|
||||
cd /opt/shop && git pull # нужен исправленный seed.js (v0.10.0+)
|
||||
bash /opt/shop/shop10/scripts/server-update.sh
|
||||
systemctl restart shop
|
||||
```
|
||||
|
||||
|
||||
Reference in New Issue
Block a user