You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This project ships with a `Dockerfile` for building and running 9Router in a container.
3
+
Run 9Router in a container. Published image: [`decolua/9router`](https://hub.docker.com/r/decolua/9router) — multi-platform `linux/amd64` + `linux/arm64`.
4
4
5
-
## Build image
5
+
---
6
6
7
-
```bash
8
-
docker build -t 9router .
9
-
```
7
+
# 👤 For Users
10
8
11
-
## Start container
9
+
## Quick start
12
10
13
11
```bash
14
-
docker run --rm \
12
+
docker run -d \
15
13
-p 20128:20128 \
16
14
-v "$HOME/.9router:/app/data" \
17
15
-e DATA_DIR=/app/data \
18
16
--name 9router \
19
-
9router
17
+
decolua/9router:latest
20
18
```
21
19
22
-
The app listens on port `20128` in the container.
20
+
App listens on port `20128`. Open: http://localhost:20128
23
21
24
-
## What the volume does
22
+
## Manage container
25
23
26
24
```bash
27
-
-v "$HOME/.9router:/app/data" \
28
-
-e DATA_DIR=/app/data
25
+
docker logs -f 9router # view logs
26
+
docker stop 9router # stop
27
+
docker start 9router # start again
28
+
docker rm -f 9router # remove
29
29
```
30
30
31
-
`9router` stores its database at `path.join(DATA_DIR, "db.json")`.
32
-
Without `DATA_DIR`, the app falls back to the current user's home directory (for example `~/.9router/db.json` on macOS/Linux). In the container, set `DATA_DIR=/app/data` so the bind mount is actually used.
31
+
## Data persistence
33
32
34
-
With the example above, the database file is:
35
-
36
-
```text
37
-
/app/data/db.json
33
+
```bash
34
+
-v "$HOME/.9router:/app/data" \
35
+
-e DATA_DIR=/app/data
38
36
```
39
37
40
-
and it is persisted on the host at:
38
+
Without `DATA_DIR`, the app falls back to `~/.9router/` (macOS/Linux) or `%APPDATA%\9router\` (Windows). In the container, `DATA_DIR=/app/data` makes the bind mount work.
39
+
40
+
Data layout under `$DATA_DIR/`:
41
41
42
42
```text
43
-
$HOME/.9router/db.json
43
+
$DATA_DIR/
44
+
├── db/
45
+
│ ├── data.sqlite # main SQLite database
46
+
│ └── backups/ # auto backups
47
+
└── ... # certs, logs, runtime configs
44
48
```
45
49
46
-
## Stop container
50
+
Host path: `$HOME/.9router/db/data.sqlite`
51
+
Container path: `/app/data/db/data.sqlite`
47
52
48
-
```bash
49
-
docker stop 9router
50
-
```
51
-
52
-
## Run in background
53
+
## Optional env vars
53
54
54
55
```bash
55
56
docker run -d \
56
57
-p 20128:20128 \
57
58
-v "$HOME/.9router:/app/data" \
58
59
-e DATA_DIR=/app/data \
60
+
-e PORT=20128 \
61
+
-e HOSTNAME=0.0.0.0 \
62
+
-e DEBUG=true \
59
63
--name 9router \
60
-
9router
64
+
decolua/9router:latest
61
65
```
62
66
63
-
## View logs
67
+
## Update to latest
64
68
65
69
```bash
66
-
docker logs -f 9router
70
+
docker pull decolua/9router:latest
71
+
docker rm -f 9router
72
+
# re-run the quick start command
67
73
```
68
74
69
-
## Optional environment variables
75
+
---
70
76
71
-
You can override runtime env vars with `-e`.
77
+
# 🛠 For Developers
72
78
73
-
Example:
79
+
## Build image locally
74
80
75
81
```bash
76
-
docker run --rm \
77
-
-p 20128:20128 \
82
+
# from repo root
83
+
npm run docker:build
84
+
```
85
+
86
+
Or directly:
87
+
```bash
88
+
cd app && docker build -t 9router .
89
+
```
90
+
91
+
Run local build:
92
+
```bash
93
+
docker run --rm -p 20128:20128 \
78
94
-v "$HOME/.9router:/app/data" \
79
95
-e DATA_DIR=/app/data \
80
-
-e PORT=20128 \
81
-
-e HOSTNAME=0.0.0.0 \
82
-
-e DEBUG=true \
83
-
--name 9router \
84
96
9router
85
97
```
86
98
87
-
## Rebuild after code changes
99
+
## Publish to Docker Hub (multi-platform)
100
+
101
+
Triggered automatically by `npm run cli:publish`. Manual:
- Optional request/translator logs: `<repo>/logs/...` when `ENABLE_REQUEST_LOGS=true`
1121
1127
- Both `${DATA_DIR}` and `~/.9router` resolve to the same location in a Docker container — the symlink `/root/.9router -> /app/data` is created at build time.
0 commit comments