Add deploy docs: nginx vhost, Caddy, full deploy steps
Made-with: Cursor
This commit is contained in:
parent
3b153fc63d
commit
17a99e8518
100
deploy/DEPLOY.md
Normal file
100
deploy/DEPLOY.md
Normal file
@ -0,0 +1,100 @@
|
||||
# Deploying iliadobkin.com
|
||||
|
||||
## Architecture
|
||||
|
||||
```
|
||||
Browser → Caddy (public IP, TLS) → nginx on 10.0.10.124:80 → /var/www/iliadobkin.com
|
||||
```
|
||||
|
||||
- **DNS** for `iliadobkin.com` points to the **Caddy** server.
|
||||
- **Caddy** terminates TLS and reverse-proxies to `10.0.10.124:80`.
|
||||
- **nginx** on `10.0.10.124` (`portfolio`) serves static files from `/var/www/iliadobkin.com`.
|
||||
|
||||
### Paths on `portfolio` (10.0.10.124)
|
||||
|
||||
| Path | Purpose |
|
||||
|------|---------|
|
||||
| `/var/www/iliadobkin.com-src` | Git clone — pull, build here |
|
||||
| `/var/www/iliadobkin.com` | Live site — nginx `root`, rsync `dist/` here |
|
||||
| `/var/www/html` | Default nginx docroot — **not used** for this site |
|
||||
|
||||
## Full deploy (SSH into `portfolio` as root)
|
||||
|
||||
```bash
|
||||
cd /var/www/iliadobkin.com-src
|
||||
git fetch origin && git checkout main && git reset --hard origin/main
|
||||
rm -rf node_modules dist
|
||||
npm ci
|
||||
npm run build
|
||||
rsync -av --delete ./dist/ /var/www/iliadobkin.com/
|
||||
```
|
||||
|
||||
No nginx reload needed after a normal deploy — only the static files change.
|
||||
|
||||
## Verify deploy worked
|
||||
|
||||
```bash
|
||||
# On the server — disk should match the build:
|
||||
grep -o 'assets/index-[^"]*\.js' /var/www/iliadobkin.com/index.html
|
||||
|
||||
# From anywhere — public site should match disk:
|
||||
curl -sS https://iliadobkin.com/index.html | grep -o 'assets/index-[^"]*\.js'
|
||||
```
|
||||
|
||||
Both commands must print the **same** hash (e.g. `assets/index-BURprqoD.js`).
|
||||
|
||||
## If the site still looks old in the browser
|
||||
|
||||
1. Hard refresh: **Ctrl+Shift+R** or open in a private/incognito window.
|
||||
2. DevTools → **Application** → **Storage** → **Clear site data**, then reload.
|
||||
3. The app is a PWA — an old service worker can cache stale assets.
|
||||
|
||||
## nginx vhost (one-time setup)
|
||||
|
||||
If `/etc/nginx/sites-available/iliadobkin.com` doesn't exist or nginx is serving
|
||||
from `/var/www/html` instead, create the vhost:
|
||||
|
||||
```bash
|
||||
cat > /etc/nginx/sites-available/iliadobkin.com << 'EOF'
|
||||
server {
|
||||
listen 80;
|
||||
listen [::]:80;
|
||||
server_name iliadobkin.com www.iliadobkin.com;
|
||||
|
||||
root /var/www/iliadobkin.com;
|
||||
index index.html;
|
||||
|
||||
location / {
|
||||
try_files $uri $uri/ /index.html;
|
||||
}
|
||||
|
||||
location = /index.html {
|
||||
add_header Cache-Control "no-cache, no-store, must-revalidate";
|
||||
}
|
||||
|
||||
location /assets/ {
|
||||
add_header Cache-Control "public, max-age=31536000, immutable";
|
||||
}
|
||||
}
|
||||
EOF
|
||||
ln -sf /etc/nginx/sites-available/iliadobkin.com /etc/nginx/sites-enabled/
|
||||
nginx -t && systemctl reload nginx
|
||||
```
|
||||
|
||||
## Caddy config (on the Caddy server, not `portfolio`)
|
||||
|
||||
```caddy
|
||||
iliadobkin.com {
|
||||
reverse_proxy 10.0.10.124:80
|
||||
}
|
||||
|
||||
www.iliadobkin.com {
|
||||
redir https://iliadobkin.com{uri} permanent
|
||||
}
|
||||
```
|
||||
|
||||
## Quick one-liner deploy
|
||||
|
||||
```bash
|
||||
ssh root@10.0.10.124 'cd /var/www/iliadobkin.com-src && git fetch origin && git reset --hard origin/main && rm -rf node_modules dist && npm ci && npm run build && rsync -av --delete ./dist/ /var/www/iliadobkin.com/'
|
||||
```
|
||||
29
deploy/nginx-iliadobkin.com.conf.example
Normal file
29
deploy/nginx-iliadobkin.com.conf.example
Normal file
@ -0,0 +1,29 @@
|
||||
# Install on the origin server (e.g. 10.0.10.124):
|
||||
# sudo cp deploy/nginx-iliadobkin.com.conf.example /etc/nginx/sites-available/iliadobkin.com
|
||||
# sudo ln -sf /etc/nginx/sites-available/iliadobkin.com /etc/nginx/sites-enabled/
|
||||
# sudo nginx -t && sudo systemctl reload nginx
|
||||
#
|
||||
# Caddy in front should reverse_proxy to this host :80 (unchanged).
|
||||
|
||||
server {
|
||||
listen 80;
|
||||
listen [::]:80;
|
||||
server_name iliadobkin.com www.iliadobkin.com;
|
||||
|
||||
root /var/www/iliadobkin.com;
|
||||
index index.html;
|
||||
|
||||
# SPA: client-side routes fall back to index.html
|
||||
location / {
|
||||
try_files $uri $uri/ /index.html;
|
||||
}
|
||||
|
||||
location = /index.html {
|
||||
add_header Cache-Control "no-cache, no-store, must-revalidate";
|
||||
}
|
||||
|
||||
# Optional: long cache for hashed assets (browser renames on each build)
|
||||
location /assets/ {
|
||||
add_header Cache-Control "public, max-age=31536000, immutable";
|
||||
}
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user