mirror of
https://github.com/decolua/9router.git
synced 2026-05-08 12:01:28 +00:00
fix: redirect ~/.9router to DATA_DIR in Docker to persist usage data across updates (closes #585) (#658)
This commit is contained in:
@@ -24,6 +24,7 @@ ENV NODE_ENV=production
|
||||
ENV PORT=20128
|
||||
ENV HOSTNAME=0.0.0.0
|
||||
ENV NEXT_TELEMETRY_DISABLED=1
|
||||
ENV DATA_DIR=/app/data
|
||||
|
||||
COPY --from=builder /app/public ./public
|
||||
COPY --from=builder /app/.next/static ./.next/static
|
||||
@@ -34,11 +35,13 @@ COPY --from=builder /app/src/mitm ./src/mitm
|
||||
# Standalone node_modules may omit deps only required by the MITM child process.
|
||||
COPY --from=builder /app/node_modules/node-forge ./node_modules/node-forge
|
||||
|
||||
RUN mkdir -p /app/data && chown -R bun:bun /app
|
||||
RUN mkdir -p /app/data && chown -R bun:bun /app && \
|
||||
mkdir -p /app/data-home && chown bun:bun /app/data-home && \
|
||||
ln -sf /app/data-home /root/.9router 2>/dev/null || true
|
||||
|
||||
# Fix permissions at runtime (handles mounted volumes)
|
||||
RUN apk --no-cache upgrade && apk --no-cache add su-exec && \
|
||||
printf '#!/bin/sh\nchown -R bun:bun /app/data 2>/dev/null\nexec su-exec bun "$@"\n' > /entrypoint.sh && \
|
||||
printf '#!/bin/sh\nchown -R bun:bun /app/data /app/data-home 2>/dev/null\nexec su-exec bun "$@"\n' > /entrypoint.sh && \
|
||||
chmod +x /entrypoint.sh
|
||||
|
||||
EXPOSE 20128
|
||||
|
||||
@@ -1078,9 +1078,9 @@ Notes:
|
||||
### Runtime Files and Storage
|
||||
|
||||
- Main app state: `${DATA_DIR}/db.json` (providers, combos, aliases, keys, settings), managed by `src/lib/localDb.js`.
|
||||
- Usage history and logs: `~/.9router/usage.json` and `~/.9router/log.txt`, managed by `src/lib/usageDb.js`.
|
||||
- Usage history and logs: `${DATA_DIR}/usage.json` and `${DATA_DIR}/log.txt`, managed by `src/lib/usageDb.js`.
|
||||
- Optional request/translator logs: `<repo>/logs/...` when `ENABLE_REQUEST_LOGS=true`.
|
||||
- Usage storage currently follows `~/.9router` path logic and is independent from `DATA_DIR`.
|
||||
- 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.
|
||||
|
||||
</details>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user