Files
tehran_taj/DOCKER.md
T

68 lines
2.1 KiB
Markdown
Raw Normal View History

2026-09-10 12:17:47 +03:30
# Docker — copy-only deploy (Dokploy)
2026-09-10 12:17:47 +03:30
Build artifacts are produced **on the developer machine** and committed to git.
Dokploy only builds thin images that copy those files (no `pnpm install` on the server).
2026-09-10 12:17:47 +03:30
## One-time / before each deploy
```bash
2026-09-10 12:17:47 +03:30
pnpm install
pnpm build:release
git add -f apps/api/release apps/admin-panel/dist apps/user-app-v2/dist
2026-09-10 12:17:47 +03:30
git commit -m "chore: refresh release artifacts"
git push
```
2026-09-10 12:17:47 +03:30
What this produces:
| App | Artifact | Image |
|---|---|---|
| API | `apps/api/release/app.js` (+ Prisma under `release/vendor`) | `docker.arvancloud.ir/node:20-bookworm` |
2026-09-10 12:17:47 +03:30
| Admin | `apps/admin-panel/dist/` | `docker.arvancloud.ir/nginx:latest` |
| User | `apps/user-app-v2/dist/` | `docker.arvancloud.ir/nginx:latest` |
2026-09-10 12:17:47 +03:30
## Dokploy Environment
```env
POSTGRES_USER=goldbank
POSTGRES_PASSWORD=...
POSTGRES_DB=goldbank
EXTERNAL_DB_PORT=5433
DATABASE_URL=postgresql://goldbank:...@db:5432/goldbank?schema=public
PORT=3000
```
2026-10-14 08:48:15 +03:30
A second copy on the **same server** is a separate Dokploy application (its own
domains, passwords, and `JWT_SECRET`). Do not set `container_name` in this file:
those names are global in Docker, and a fixed `goldbank_db` collides with the
first copy. Give the second app its own `EXTERNAL_DB_PORT` (for example `5434`
if `5433` is already taken). Volumes stay separate because Dokploy uses a
different Compose project name for each application.
2026-09-10 12:17:47 +03:30
## Domains (container ports)
Same host (path-based) — default in this repo:
| Service | Path | Port | Notes |
|---|---|---|---|
| `user-app-v2` | `/` | **80** | |
| `admin-panel` | `/admin` | **80** | Strip Path on. Build with `ADMIN_PANEL_BASE=/admin/` (default) so `index.html` links `/admin/assets/…`. |
| `api` | (optional) | **3000** | |
Or separate subdomains — set `ADMIN_PANEL_BASE=/` before `pnpm build:release`:
2026-09-10 12:17:47 +03:30
| Service | Domain | Port |
|---|---|---|
| `admin-panel` | admin.example.com | **80** |
| `user-app-v2` | app.example.com | **80** |
2026-09-10 12:17:47 +03:30
| `api` | (optional) | **3000** |
Frontends call `/api` on their own domain; nginx proxies to `api:3000`.
## Local compose smoke test
```bash
2026-09-10 12:17:47 +03:30
pnpm build:release
docker compose up --build -d
```