mirror of
https://github.com/decolua/9router.git
synced 2026-05-08 12:01:28 +00:00
- Added `DOCKER.md` documentation to guide users on using Docker with the project. - Migrated Dockerfile to use `oven/bun:1-alpine` for performance improvements. - Refined build process and permissions in the container for better compatibility. - Excluded `.idea/` files in `.gitignore`. - Enhanced `.npmignore` to clean redundant blank lines.
47 lines
1.3 KiB
Docker
47 lines
1.3 KiB
Docker
# syntax=docker/dockerfile:1.7
|
|
FROM oven/bun:1-alpine AS base
|
|
WORKDIR /app
|
|
|
|
FROM base AS builder
|
|
|
|
RUN apk add --no-cache nodejs npm python3 make g++ linux-headers
|
|
|
|
COPY package.json ./
|
|
RUN --mount=type=cache,target=/root/.npm \
|
|
npm install
|
|
|
|
COPY . ./
|
|
ENV NEXT_TELEMETRY_DISABLED=1
|
|
RUN bun run build:bun
|
|
|
|
FROM oven/bun:1-alpine AS runner
|
|
WORKDIR /app
|
|
|
|
LABEL org.opencontainers.image.title="9router"
|
|
|
|
ENV NODE_ENV=production
|
|
ENV PORT=20128
|
|
ENV HOSTNAME=0.0.0.0
|
|
ENV NEXT_TELEMETRY_DISABLED=1
|
|
|
|
COPY --from=builder /app/public ./public
|
|
COPY --from=builder /app/.next/static ./.next/static
|
|
COPY --from=builder /app/.next/standalone ./
|
|
COPY --from=builder /app/open-sse ./open-sse
|
|
# Next file tracing can omit sibling files; MITM runs server.js as a separate process.
|
|
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
|
|
|
|
# Fix permissions at runtime (handles mounted volumes)
|
|
RUN apk add --no-cache su-exec && \
|
|
printf '#!/bin/sh\nchown -R bun:bun /app/data 2>/dev/null\nexec su-exec bun "$@"\n' > /entrypoint.sh && \
|
|
chmod +x /entrypoint.sh
|
|
|
|
EXPOSE 20128
|
|
|
|
ENTRYPOINT ["/entrypoint.sh"]
|
|
CMD ["bun", "server.js"]
|