This commit is contained in:
2026-06-07 16:04:59 +03:30
parent d3089ff2dd
commit 2be0f3e2b8
6 changed files with 135 additions and 2 deletions
+60
View File
@@ -0,0 +1,60 @@
# Deployment
The site is a **static export**. It is built **on your machine** and the result
(`out/`) is copied to the server — nothing is built on the server.
- Server: `185.226.116.88`, user `ubuntu`
- Target dir: `/var/www/aramland-admin` (its contents are fully replaced each deploy)
## Deploy by pushing a git tag (automatic)
A versioned git hook ([`.githooks/pre-push`](.githooks/pre-push)) runs the local
build + upload whenever you push a **tag**:
```bash
git tag v1.0.0
git push origin v1.0.0 # ← hook builds locally, then uploads to the server
```
Normal branch pushes are unaffected — only tag pushes deploy.
> The hook path is set via `git config core.hooksPath .githooks` (already configured
> in this clone). On a fresh clone, run that once.
## Deploy manually (no tag)
```bash
npm run deploy # = bash scripts/deploy.sh : build locally + upload
```
## The password
Both paths use [`scripts/deploy.sh`](scripts/deploy.sh), which streams `out/` over a
single SSH connection. By default **SSH asks for the server password once** per deploy.
To make it **unattended** (no prompt), provide the password without committing it:
1. Create `.env.deploy` in the project root (already gitignored):
```bash
DEPLOY_PASSWORD=your-server-password
```
2. Install `sshpass` (the only piece that can feed a password to SSH non-interactively):
- Linux/WSL: `sudo apt-get install -y sshpass`
- macOS: `brew install hudochenkov/sshpass/sshpass`
- Windows Git Bash has no sshpass — either deploy from WSL, or just answer the one
password prompt.
Override the host/user/path too if needed (env or `.env.deploy`):
`DEPLOY_HOST`, `DEPLOY_USER`, `DEPLOY_PATH`.
> **More robust option:** set up an SSH **key** (`ssh-copy-id ubuntu@185.226.116.88`).
> Then deploys are unattended on any OS with no password or sshpass at all.
## Notes / troubleshooting
- **Permission denied** writing the target: the `ubuntu` user must own it →
on the server run `sudo chown -R ubuntu:ubuntu /var/www/aramland-admin`.
- **Web server:** point nginx's site root at `/var/www/aramland-admin`. The export uses
`trailingSlash: true`, so clean URLs resolve to `…/index.html`.
- The deploy replaces the directory **contents** (including dotfiles) in place; it does
not touch nginx config or sibling folders.