mirror of
https://github.com/decolua/9router.git
synced 2026-05-08 12:01:28 +00:00
Update Docker build process and documentation
- Replaced `bun run build:bun` with `npm run build` in Dockerfile for consistency. - Enhanced `DOCKER.md` to include `DATA_DIR` environment variable usage for database persistence. - Clarified paths for container and host data storage.
This commit is contained in:
21
DOCKER.md
21
DOCKER.md
@@ -14,6 +14,7 @@ docker build -t 9router .
|
||||
docker run --rm \
|
||||
-p 20128:20128 \
|
||||
-v "$HOME/.9router:/app/data" \
|
||||
-e DATA_DIR=/app/data \
|
||||
--name 9router \
|
||||
9router
|
||||
```
|
||||
@@ -23,10 +24,24 @@ The app listens on port `20128` in the container.
|
||||
## What the volume does
|
||||
|
||||
```bash
|
||||
-v "$HOME/.9router:/app/data"
|
||||
-v "$HOME/.9router:/app/data" \
|
||||
-e DATA_DIR=/app/data
|
||||
```
|
||||
|
||||
This keeps your data outside the container so it survives restarts and image rebuilds.
|
||||
`9router` stores its database at `path.join(DATA_DIR, "db.json")`.
|
||||
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.
|
||||
|
||||
With the example above, the database file is:
|
||||
|
||||
```text
|
||||
/app/data/db.json
|
||||
```
|
||||
|
||||
and it is persisted on the host at:
|
||||
|
||||
```text
|
||||
$HOME/.9router/db.json
|
||||
```
|
||||
|
||||
## Stop container
|
||||
|
||||
@@ -40,6 +55,7 @@ docker stop 9router
|
||||
docker run -d \
|
||||
-p 20128:20128 \
|
||||
-v "$HOME/.9router:/app/data" \
|
||||
-e DATA_DIR=/app/data \
|
||||
--name 9router \
|
||||
9router
|
||||
```
|
||||
@@ -60,6 +76,7 @@ Example:
|
||||
docker run --rm \
|
||||
-p 20128:20128 \
|
||||
-v "$HOME/.9router:/app/data" \
|
||||
-e DATA_DIR=/app/data \
|
||||
-e PORT=20128 \
|
||||
-e HOSTNAME=0.0.0.0 \
|
||||
-e DEBUG=true \
|
||||
|
||||
@@ -12,7 +12,7 @@ RUN --mount=type=cache,target=/root/.npm \
|
||||
|
||||
COPY . ./
|
||||
ENV NEXT_TELEMETRY_DISABLED=1
|
||||
RUN bun run build:bun
|
||||
RUN npm run build
|
||||
|
||||
FROM oven/bun:1-alpine AS runner
|
||||
WORKDIR /app
|
||||
|
||||
Reference in New Issue
Block a user