mirror of
https://github.com/outline/outline.git
synced 2026-08-03 13:27:25 +03:00
* Reduce server memory usage and add container memory best practices Profiling a full-service boot showed ~300MB RSS per service process, much of it client-only dependencies pulled into the server module graph, and no heap limits applied in containers: - Import date-fns locales individually rather than via the locale index, which loaded all ~90 locales into every process - Load @sentry/react dynamically in insertFiles so the browser Sentry SDK stays out of the server-side editor graph - Replace class-validator isHexColor with the existing validateColorHex in the Highlight mark - Extract icon names into a standalone IconNames module so server-side schema validation no longer imports Font Awesome icon packs, with a test to keep it in sync with IconLibrary - Require S3Storage lazily so the AWS SDK and native CRT binding are only loaded when S3 file storage is configured - Default each forked service process to a V8 heap limit derived from the cgroup memory constraint, preventing several processes from together committing more memory than the container allows - Cap glibc malloc arenas in the Docker image to reduce resident memory fragmentation in multi-threaded processes Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016YMX5ReGHyxrR4ZE5ZbaXa * Require both file storage backends lazily for consistency Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016YMX5ReGHyxrR4ZE5ZbaXa * Load AWS SDK via dynamic imports compatible with test environment Requiring the storage TypeScript modules lazily broke under Vitest, which cannot resolve require() of source files and does not apply vi.mock to bare requires. Move the laziness into S3Storage instead: the module is imported statically, and the AWS SDK packages are loaded with dynamic imports on first use, including deferred creation of the S3 client. Also address review feedback: handle rejection of the dynamic Sentry import, and warn when the minimum per-process heap limit exceeds the memory budget of the container. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016YMX5ReGHyxrR4ZE5ZbaXa * Consolidate S3 SDK loading into a single lazy accessor The commands are loaded together with the client in getS3() rather than as separate dynamic imports per method. The global S3Client test mock is now a class, as a mock function is not constructable when reached through a dynamic import. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016YMX5ReGHyxrR4ZE5ZbaXa --------- Co-authored-by: Claude <noreply@anthropic.com>
53 lines
1.8 KiB
Docker
53 lines
1.8 KiB
Docker
ARG APP_PATH=/opt/outline
|
|
ARG BASE_IMAGE=outlinewiki/outline-base
|
|
FROM ${BASE_IMAGE} AS base
|
|
|
|
ARG APP_PATH
|
|
WORKDIR $APP_PATH
|
|
|
|
# ---
|
|
FROM node:26.3.0-slim AS runner
|
|
|
|
LABEL org.opencontainers.image.source="https://github.com/outline/outline"
|
|
|
|
ARG APP_PATH
|
|
WORKDIR $APP_PATH
|
|
ENV NODE_ENV=production
|
|
|
|
# Limit glibc malloc arenas, which default to 8 per CPU. Each arena can hold
|
|
# onto 64MB of virtual memory and freed allocations, which inflates resident
|
|
# memory in multi-threaded Node.js processes for no performance benefit here.
|
|
ENV MALLOC_ARENA_MAX=2
|
|
|
|
# Create a non-root user compatible with Debian and BusyBox based images
|
|
RUN addgroup --gid 1001 nodejs && \
|
|
adduser --uid 1001 --ingroup nodejs nodejs && \
|
|
mkdir -p /var/lib/outline && \
|
|
chown -R nodejs:nodejs /var/lib/outline && \
|
|
chown -R nodejs:nodejs $APP_PATH
|
|
|
|
COPY --from=base --chown=nodejs:nodejs $APP_PATH/build ./build
|
|
COPY --from=base --chown=nodejs:nodejs $APP_PATH/server ./server
|
|
COPY --from=base --chown=nodejs:nodejs $APP_PATH/public ./public
|
|
COPY --from=base --chown=nodejs:nodejs $APP_PATH/.sequelizerc ./.sequelizerc
|
|
COPY --from=base --chown=nodejs:nodejs $APP_PATH/node_modules ./node_modules
|
|
COPY --from=base --chown=nodejs:nodejs $APP_PATH/package.json ./package.json
|
|
# Install wget to healthcheck the server
|
|
RUN apt-get update \
|
|
&& apt-get install -y wget \
|
|
&& rm -rf /var/lib/apt/lists/*
|
|
|
|
ENV FILE_STORAGE_LOCAL_ROOT_DIR=/var/lib/outline/data
|
|
RUN mkdir -p "$FILE_STORAGE_LOCAL_ROOT_DIR" && \
|
|
chown -R nodejs:nodejs "$FILE_STORAGE_LOCAL_ROOT_DIR" && \
|
|
chmod 1777 "$FILE_STORAGE_LOCAL_ROOT_DIR"
|
|
|
|
VOLUME /var/lib/outline/data
|
|
|
|
USER nodejs
|
|
|
|
HEALTHCHECK --interval=1m CMD wget -qO- "http://localhost:${PORT:-3000}/_health" | grep -q "OK" || exit 1
|
|
|
|
EXPOSE 3000
|
|
CMD ["node", "build/server/index.js"]
|