trilium/apps/server/Dockerfile.rootless
2026-09-13 07:19:19 +00:00

43 lines
1.3 KiB
Docker

# See the comment in Dockerfile: better-sqlite3 v13 ships N-API prebuilds, so
# there is no native compile step and no builder stage, and the Linux prebuilds
# need trixie's glibc rather than bookworm's.
FROM node:24.21.0-trixie-slim
# Create a non-root user with configurable UID/GID
ARG USER=trilium
ARG UID=1001
ARG GID=1001
ENV USER=${USER}
ENV UID=${UID}
ENV GID=${GID}
# 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/* && \
# Create the user/group with the default UID/GID
groupadd -g ${GID} ${USER} && \
useradd -u ${UID} -g ${USER} -s /bin/sh -m ${USER}
WORKDIR /home/${USER}/app
COPY ./dist /home/${USER}/app
# Also copy the rootless entrypoint script
COPY rootless-entrypoint.sh /home/${USER}/app/
RUN chown -R ${USER}:${USER} /home/${USER}
# Configure container
USER ${USER}
EXPOSE 8080
# By default, use UID/GID that was set during build
# These can be overridden at runtime
ENV TRILIUM_UID=${UID}
ENV TRILIUM_GID=${GID}
ENV TRILIUM_DATA_DIR=/home/${USER}/trilium-data
# Use the entrypoint script
CMD [ "bash", "./rootless-entrypoint.sh" ]
HEALTHCHECK --interval=60s --timeout=5s --start-period=30s CMD sh /home/${USER}/app/docker_healthcheck.sh