Build your personal knowledge base with Trilium Notes
TypeScript electronelectron-appknowledge-baseknowledge-graphknowledge-managementknowledge-management-graphlocal-firstnote-managmentnote-takernote-takingnotebooknotesnotes-apppersonal-knowledge-basepersonal-wikiscriptableself-hostedself-hostingwiki
FROM node:22.23.4-bookworm-slim AS builder
RUN corepack enable
# Install build tools required to compile native addons (e.g. better-sqlite3) on ARM
RUN apt-get update && \
apt-get install -y --no-install-recommends \
python3 \
make \
g++ && \
rm -rf /var/lib/apt/lists/*
# Unlike the other images, this one cannot use better-sqlite3 v13's bundled
# N-API prebuilds and must keep compiling from source:
# - 32-bit ARM (linux/arm/v7) has no prebuild at all;
# - linux/arm/v8 normalizes to arm64, whose prebuild needs glibc >= 2.38,
# while this image stays on bookworm (glibc 2.36) to support old hosts.
# Asking for it is not implicit: better-sqlite3's binding.gyp resolves both of
# its targets to `type: none` whenever a prebuild for the host exists, so the
# node-gyp run would emit a stamp file and no addon. force_build restores the
# real compile and link rules.
ENV npm_config_force_build=1
# Install native dependencies since we might be building cross-platform.
WORKDIR /usr/src/app/build
COPY ./docker/package.json ./docker/pnpm-workspace.yaml /usr/src/app/
# We have to use --no-frozen-lockfile due to CKEditor patches
RUN pnpm install --no-frozen-lockfile --prod && pnpm rebuild
FROM node:22.23.4-bookworm-slim
# Install only runtime dependencies
RUN apt-get update && \
apt-get install -y --no-install-recommends \
curl && \
rm -rf \
/var/lib/apt/lists/* \
/var/cache/apt/*
WORKDIR /usr/src/app
COPY ./dist /usr/src/app
RUN rm -rf /usr/src/app/node_modules/better-sqlite3
COPY --from=builder /usr/src/app/node_modules/better-sqlite3 /usr/src/app/node_modules/better-sqlite3
COPY ./start-docker.sh /usr/src/app
# A new named volume takes its owner from the mount point, so a container started with --user
# can write to it. Other UIDs need to pass through /home/node to reach a volume of their own.
RUN mkdir -p /home/node/trilium-data && \
chown node:node /home/node/trilium-data && \
chmod 700 /home/node/trilium-data && \
chmod 711 /home/node
# The healthcheck reads the listening address the server records here.
ENV TRILIUM_DATA_DIR=/home/node/trilium-data
# Configure container
EXPOSE 8080
CMD [ "sh", "./start-docker.sh" ]
HEALTHCHECK --interval=60s --timeout=5s --start-period=30s CMD sh /usr/src/app/docker_healthcheck.sh