Fix Docker volume permissions for SQLite database

- Add runtime permission fix in docker-entrypoint.sh to ensure
  /app/data volume has correct ownership before app starts
- Remove build-time chown for /app/data from Dockerfile since
  Docker volumes are mounted at runtime, not build time
- This resolves SQLITE_READONLY error when upgrading to OpenCode 1.4.0

The database volume may have incorrect ownership when mounted by Docker,
causing the SQLite database to be read-only. The entrypoint script now
fixes permissions before starting the backend (runs as root before USER node).
This commit is contained in:
Chris Scott committed 2026-04-07 23:19:51 -04:00
1 parent 9973e00dc5
commit 2831533777
2 files changed
+12 -2

No files matched your search

+3 -2
View File
@@ -93,8 +93,9 @@ 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 /app/data && \
chown -R node:node /workspace /app/data
RUN mkdir -p /workspace && \
chown -R node:node /workspace
# Note: /app/data is a Docker volume, permissions are handled at runtime in entrypoint
EXPOSE 5003 5100 5101 5102 5103
+9
View File
@@ -75,5 +75,14 @@ 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
exec "$@"