Fix Docker volume permissions for SQLite database
All checks were successful
Build And Test / publish (push) Successful in 47s

Container runs as non-root user but mounted volumes may be owned by root.
Added entrypoint script to fix /data permissions before starting the app.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
2025-12-30 16:11:08 -08:00
parent 87c55e0f1f
commit 73d3ff4319
2 changed files with 26 additions and 5 deletions

View File

@@ -6,6 +6,10 @@ ENV PYTHONDONTWRITEBYTECODE=1 \
PIP_NO_CACHE_DIR=1 \
PIP_DISABLE_PIP_VERSION_CHECK=1
# Install gosu for stepping down from root
RUN apt-get update && apt-get install -y --no-install-recommends gosu \
&& rm -rf /var/lib/apt/lists/*
# Create non-root user
RUN groupadd -r mcp && useradd -r -g mcp mcp
@@ -19,12 +23,13 @@ RUN pip install --no-cache-dir -r requirements.txt
# Copy application code
COPY src/ ./src/
# Copy entrypoint script
COPY entrypoint.sh /entrypoint.sh
RUN chmod +x /entrypoint.sh
# Create data directory for SQLite
RUN mkdir -p /data && chown -R mcp:mcp /data /app
# Switch to non-root user
USER mcp
# Expose port
EXPOSE 8000
@@ -32,5 +37,6 @@ EXPOSE 8000
HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
CMD python -c "import urllib.request; urllib.request.urlopen('http://localhost:8000/mcp')" || exit 1
# Run the server
CMD ["python", "src/server.py"]
# Use entrypoint to fix permissions, then run as mcp user
ENTRYPOINT ["/entrypoint.sh"]
CMD ["gosu", "mcp", "python", "src/server.py"]