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
chore(docker): remove the rootless images
Elian Dorance5154623c07
diff --git a/apps/server/Dockerfile.alpine.rootless b/apps/server/Dockerfile.alpine.rootlessdeleted file mode 100644index b14d1b4158..0000000000--- a/apps/server/Dockerfile.alpine.rootless+++ /dev/null@@ -1,42 +0,0 @@-# See the comment in Dockerfile: better-sqlite3 v13 ships N-API prebuilds — the-# linuxmusl-* ones here — so there is no native compile step and no builder-# stage. They link libstdc++, which node:*-alpine already provides at runtime.-FROM node:24.21.0-alpine-# 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 runtime dependencies and create user with specific UID/GID-RUN apk add --no-cache dumb-init curl && \- apk add --no-cache bash && \- # Alpine uses addgroup/adduser (from busybox) instead of groupadd/useradd- addgroup -g ${GID} ${USER} && \- adduser -u ${UID} -G ${USER} -s /bin/sh -D -h /home/${USER} ${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 dumb-init as entrypoint to handle signals properly-ENTRYPOINT ["/usr/bin/dumb-init", "--"]--# Use the entrypoint script-CMD [ "bash", "./rootless-entrypoint.sh" ]--HEALTHCHECK --interval=60s --timeout=5s --start-period=30s CMD sh /home/${USER}/app/docker_healthcheck.shdiff --git a/apps/server/Dockerfile.rootless b/apps/server/Dockerfile.rootlessdeleted file mode 100644index 45c8e918bc..0000000000--- a/apps/server/Dockerfile.rootless+++ /dev/null@@ -1,42 +0,0 @@-# 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.shdiff --git a/apps/server/package.json b/apps/server/package.jsonindex ca277f27ca..b777adfdd4 100644--- a/apps/server/package.json+++ b/apps/server/package.json@@ -21,12 +21,8 @@"circular-deps": "dpdm -T src/**/*.ts --tree=false --warning=false --skip-dynamic-imports=circular","docker-build-debian": "pnpm build && docker build . -t triliumnext-debian -f Dockerfile","docker-build-alpine": "pnpm build && docker build . -t triliumnext-alpine -f Dockerfile.alpine",- "docker-build-rootless-debian": "pnpm build && docker build . -t triliumnext-rootless-debian -f Dockerfile.rootless",- "docker-build-rootless-alpine": "pnpm build && docker build . -t triliumnext-rootless-alpine -f Dockerfile.alpine.rootless","docker-start-debian": "pnpm docker-build-debian && docker run -p 8081:8080 triliumnext-debian","docker-start-alpine": "pnpm docker-build-alpine && docker run -p 8081:8080 triliumnext-alpine",- "docker-start-rootless-debian": "pnpm docker-build-rootless-debian && docker run -p 8081:8080 triliumnext-rootless-debian",- "docker-start-rootless-alpine": "pnpm docker-build-rootless-alpine && docker run -p 8081:8080 triliumnext-rootless-alpine","generate-document": "cross-env TRILIUM_ENV=dev TRILIUM_DATA_DIR=data TRILIUM_RESOURCE_DIR=src tsx ./scripts/generate_document.ts","proxy-traefik": "docker run --name trilium-traefik --rm --network=host -v ./docker/traefik/traefik.yml:/etc/traefik/traefik.yml:ro -v ./docker/traefik/dynamic:/etc/traefik/dynamic traefik:latest","proxy-nginx-subdir": "docker run --name trilium-nginx-subdir --rm -p 8095:8095 --add-host=host.docker.internal:host-gateway -v ./docker/nginx.conf:/etc/nginx/conf.d/default.conf:ro nginx:latest"diff --git a/apps/server/rootless-entrypoint.sh b/apps/server/rootless-entrypoint.shdeleted file mode 100755index 6e2c071a8a..0000000000--- a/apps/server/rootless-entrypoint.sh+++ /dev/null@@ -1,28 +0,0 @@-#!/bin/bash-# Rootless entrypoint script for Trilium Notes-# Works with both Debian and Alpine-based images--# Check if runtime UID/GID match the expected values-if [ "${TRILIUM_UID}" != "$(id -u)" ] || [ "${TRILIUM_GID}" != "$(id -g)" ]; then- echo "Detected UID:GID mismatch (current: $(id -u):$(id -g), expected: ${TRILIUM_UID}:${TRILIUM_GID})"- # Check GID mismatch- if [ "${TRILIUM_GID}" != "$(id -g)" ]; then- echo "ERROR: Cannot change GID at runtime in rootless mode."- echo " Current GID: $(id -g), Expected GID: ${TRILIUM_GID}"- echo " Please use docker run with --user $(id -u):$(id -g) instead."- exit 1- fi- # Check UID mismatch- if [ "${TRILIUM_UID}" != "$(id -u)" ]; then- echo "ERROR: Cannot change UID at runtime in rootless mode."- echo " Current UID: $(id -u), Expected UID: ${TRILIUM_UID}"- echo " Please use docker run with --user $(id -u):$(id -g) instead."- exit 1- fi-fi--# Make sure data directory has correct permissions-mkdir -p "${TRILIUM_DATA_DIR}"--# Start the app-exec node ./main.mjsdiff --git a/docker-compose.rootless.yml b/docker-compose.rootless.ymldeleted file mode 100644index 396e415d36..0000000000--- a/docker-compose.rootless.yml+++ /dev/null@@ -1,27 +0,0 @@-# Running `docker-compose -f docker-compose.rootless.yml up` will create/use the "trilium-data" directory next to this file-# To run in the background, use `docker-compose -f docker-compose.rootless.yml up -d`-# To use the Alpine-based image, change the image tag below to `rootless-alpine`-services:- trilium:- # Optionally, replace `latest` with a version tag like `v0.90.3`- # Using `latest` may cause unintended updates to the container- image: triliumnext/trilium:rootless- restart: unless-stopped- environment:- # Set the desired UID/GID for the Trilium process. Will be used during docker run- # These should match the owner of your data directory on the host- - TRILIUM_UID=${TRILIUM_UID:-1001}- - TRILIUM_GID=${TRILIUM_GID:-1001}- # Use the specified UID/GID for the container process- user: ${TRILIUM_UID:-1001}:${TRILIUM_GID:-1001}- ports:- # By default, Trilium will be available at http://localhost:8080- # It will also be accessible at http://<host-ip>:8080- # You might want to limit this with something like Docker Networks, reverse proxies, or firewall rules- - '8080:8080'- volumes:- # Trilium stores its data in `trilium-data` next to this file. To use another directory- # on the host, change the part before the colon only.- - ./trilium-data:/home/trilium/trilium-data- - /etc/timezone:/etc/timezone:ro- - /etc/localtime:/etc/localtime:rodiff --git a/docs/Developer Guide/Developer Guide/Building/Docker.md b/docs/Developer Guide/Developer Guide/Building/Docker.mdindex ea5782ad2b..d671f605cd 100644--- a/docs/Developer Guide/Developer Guide/Building/Docker.md+++ b/docs/Developer Guide/Developer Guide/Building/Docker.md@@ -4,5 +4,7 @@ To build the server for Docker:* Go to `apps/server` and run:* `pnpm docker-build-debian` or* `pnpm docker-build-alpine`.-* Similarly, to build the rootless versions: `pnpm docker-build-rootless-debian` or `pnpm docker-build-rootless-alpine`.-* To not only build but also run the Docker container, simply replace `docker-build` with `docker-start` (e.g. `pnpm docker-start-debian`).\ No newline at end of file+* To not only build but also run the Docker container, simply replace `docker-build` with `docker-start` (e.g. `pnpm docker-start-debian`).+* To check that an image also runs as a non-root user, as CI does, run `sh scripts/check-docker-non-root.sh triliumnext-debian` (or `triliumnext-alpine`).++Build the images on Linux or in WSL. The build keeps only the host's prebuilt `better-sqlite3` binary, so an image built from a `dist` made on Windows fails at startup with `Cannot find module …/better_sqlite3.node`.\ No newline at end of file