From 1b4c4f2c307f9b027c2a7507253758e541405038 Mon Sep 17 00:00:00 2001 From: Chris Scott <99081550+chriswritescode-dev@users.noreply.github.com> Date: Tue, 7 Apr 2026 23:01:59 -0400 Subject: [PATCH] Fix SQLite readonly: entrypoint must run as root to fix volume permissions Entrypoint ran as USER node (inherited from Dockerfile) so chown silently failed with EPERM. SQLite needs write access to the directory to create WAL/journal files alongside the database. - Remove USER node from Dockerfile so entrypoint runs as root - Restore mkdir /app/data + chown for fresh volume initialization - Entrypoint now fixes ownership then drops to node via runuser before exec --- Dockerfile | 7 ++----- scripts/docker-entrypoint.sh | 13 ++++--------- 2 files changed, 6 insertions(+), 14 deletions(-) diff --git a/Dockerfile b/Dockerfile index a1fd9733..8dab155e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -93,17 +93,14 @@ RUN mkdir -p /app/backend/node_modules/@opencode-manager && \ COPY scripts/docker-entrypoint.sh /docker-entrypoint.sh RUN chmod +x /docker-entrypoint.sh -RUN mkdir -p /workspace && \ - chown -R node:node /workspace -# Note: /app/data is a Docker volume, permissions are handled at runtime in entrypoint +RUN mkdir -p /workspace /app/data && \ + chown -R node:node /workspace /app/data EXPOSE 5003 5100 5101 5102 5103 HEALTHCHECK --interval=30s --timeout=3s --start-period=40s --retries=3 \ CMD curl -f http://localhost:5003/api/health || exit 1 -USER node - ENTRYPOINT ["/docker-entrypoint.sh"] CMD ["bun", "backend/src/index.ts"] diff --git a/scripts/docker-entrypoint.sh b/scripts/docker-entrypoint.sh index 5fa2f6de..4d4b3865 100644 --- a/scripts/docker-entrypoint.sh +++ b/scripts/docker-entrypoint.sh @@ -75,14 +75,9 @@ if [ -z "$AUTH_SECRET" ]; then exit 1 fi -# Fix database directory permissions for Docker volumes -# Docker volumes are mounted at runtime and may have incorrect ownership -if [ -d "/app/data" ]; then - echo "🔧 Ensuring database directory permissions..." - chown -R node:node /app/data 2>/dev/null || true - chmod -R 755 /app/data 2>/dev/null || true - echo "✅ Database directory permissions set" -fi +mkdir -p /app/data +chown -R node:node /app/data +chmod -R 755 /app/data -exec "$@" +exec runuser -u node -- "$@"