fix: быстрое развёртывание — PGDG, /opt/shop/shop10, без placeholder URL

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
shop
2026-05-17 13:23:00 +03:00
parent 42177555ac
commit b7c8d2ed80
9 changed files with 238 additions and 86 deletions
+34 -33
View File
@@ -100,7 +100,7 @@ apt install -y postgresql-17 postgresql-client-17
Пользователь и база `shop`:
```bash
cd /opt/shop
cd /opt/shop/shop10
bash scripts/setup-postgres-ubuntu.sh
```
@@ -112,32 +112,33 @@ bash scripts/setup-postgres-ubuntu.sh
## Быстрый развёртывание на Ubuntu
**Одной командой** (клон в `/opt/shop/shop10`, PostgreSQL через PGDG, systemd):
```bash
# 1. Система + Node.js 20
apt update
apt install -y git curl
curl -fsSL https://deb.nodesource.com/setup_20.x | bash -
apt install -y nodejs
apt update && apt install -y git curl
git clone https://git.evilfox.cc/test/shop10.git /opt/shop/shop10
cd /opt/shop/shop10
sudo bash scripts/quick-deploy-ubuntu.sh
```
# 2. PostgreSQL 17
apt install -y postgresql-17 postgresql-client-17
**Уже установлен магазин — только обновить код:**
# 3. Код
cd /opt
git clone <URL_РЕПОЗИТОРИЯ> shop
cd shop
```bash
bash /opt/shop/shop10/scripts/server-update.sh
```
# 4. БД
Не выполняйте `cd /opt/shop`, если репозиторий в `/opt/shop/shop10` — там нет `package.json`.
Ручная установка:
```bash
cd /opt/shop/shop10
sudo bash scripts/install-postgresql-ubuntu.sh # PGDG, не apt install postgresql-17 напрямую
bash scripts/setup-postgres-ubuntu.sh
# 5. Окружение
cp .env.example .env
sed -i "s/change-me-to-a-long-random-string/$(openssl rand -hex 32)/" .env
# Проверьте DATABASE_URL в .env
# 6. Приложение
# SESSION_SECRET, DATABASE_URL, SITE_URL
npm install --omit=dev
npm start
systemctl restart shop
```
Проверка:
@@ -169,9 +170,9 @@ DATABASE_URL=postgresql://shop:shop@127.0.0.1:5432/shop
## Запуск как служба (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
cd /opt/shop
cd /opt/shop/shop10
cp .env.example .env # при первой установке
# Заполните SESSION_SECRET и DATABASE_URL
@@ -184,7 +185,7 @@ systemctl start shop
journalctl -u shop -f
```
`EnvironmentFile=/opt/shop/.env` должен содержать `DATABASE_URL`.
`EnvironmentFile=/opt/shop/shop10/.env` должен содержать `DATABASE_URL`.
---
@@ -276,19 +277,17 @@ shop.example.com {
**Быстрое исправление (одной командой):**
```bash
cd /opt/shop
git pull
bash scripts/fix-db-connection.sh
bash /opt/shop/shop10/scripts/fix-db-connection.sh
```
**Вручную:**
```bash
apt install -y postgresql-17 postgresql-client-17
cd /opt/shop/shop10
sudo bash scripts/install-postgresql-ubuntu.sh
systemctl enable --now postgresql
pg_isready -h 127.0.0.1 -p 5432
cd /opt/shop
bash scripts/setup-postgres-ubuntu.sh
nano .env # DATABASE_URL=postgresql://shop:shop@127.0.0.1:5432/shop
@@ -301,7 +300,7 @@ curl -s http://127.0.0.1:3000/health
### HTTP 502
```bash
bash /opt/shop/scripts/diagnose-502.sh
bash /opt/shop/shop10/scripts/diagnose-502.sh
journalctl -u shop -n 50 --no-pager
```
@@ -344,6 +343,8 @@ caddy/Caddyfile.docker.example
deploy/shop.service
scripts/
setup-postgres-ubuntu.sh
install-postgresql-ubuntu.sh
quick-deploy-ubuntu.sh
fix-db-connection.sh
diagnose-502.sh
server-update.sh
@@ -353,8 +354,8 @@ src/
## Релиз 0.20.0
```bash
git clone <URL_РЕПОЗИТОРИЯ> shop
cd shop
git clone https://git.evilfox.cc/test/shop10.git /opt/shop/shop10
cd /opt/shop/shop10
git checkout v0.20.0
```
@@ -366,6 +367,6 @@ git checkout v0.20.0
## Репозиторий
```bash
git clone <URL_РЕПОЗИТОРИЯ> shop
cd shop
git clone https://git.evilfox.cc/test/shop10.git /opt/shop/shop10
cd /opt/shop/shop10
```