Skip to content

Commit c3e9009

Browse files
Merge pull request #332 from CentrifugalBadger/fix/docker-security
chore: optimize Dockerfile security and multi-stage build
2 parents 651b7f9 + 4db4525 commit c3e9009

6 files changed

Lines changed: 405 additions & 28 deletions

File tree

.dockerignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,6 @@ cython_debug/
150150
# Docker-specific exclusions
151151
.git
152152
.github
153-
README.md
154153
.DS_Store
155154

156155
# DXT Extension

.python-version

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
3.13
1+
3.14

Dockerfile

Lines changed: 20 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,33 @@
1-
# Use slim Python base instead of full Playwright image (saves ~300-400 MB)
2-
# Only Chromium is installed, not Firefox/WebKit
3-
FROM python:3.14-slim-bookworm@sha256:55e465cb7e50cd1d7217fcb5386aa87d0356ca2cd790872142ef68d9ef6812b4
1+
# -- Stage 1: Build virtual environment --
2+
FROM python:3.14-slim-bookworm@sha256:55e465cb7e50cd1d7217fcb5386aa87d0356ca2cd790872142ef68d9ef6812b4 AS builder
43

5-
# Install uv package manager
64
COPY --from=ghcr.io/astral-sh/uv:latest@sha256:90bbb3c16635e9627f49eec6539f956d70746c409209041800a0280b93152823 /uv /uvx /bin/
75

8-
# Create non-root user first (matching original pwuser from Playwright image)
9-
RUN useradd -m -s /bin/bash pwuser
10-
11-
# Set working directory and ownership
126
WORKDIR /app
13-
RUN chown pwuser:pwuser /app
7+
COPY pyproject.toml uv.lock README.md ./
8+
RUN uv sync --frozen --no-install-project --no-dev --no-editable --compile-bytecode
149

15-
# Copy project files with correct ownership
16-
COPY --chown=pwuser:pwuser . /app
10+
COPY . .
11+
RUN uv sync --frozen --no-dev --no-editable --compile-bytecode
1712

18-
# Install git (needed for git-based dependencies in pyproject.toml)
19-
RUN apt-get update && apt-get install -y --no-install-recommends git && rm -rf /var/lib/apt/lists/*
2013

21-
# Set browser install location (Patchright reads PLAYWRIGHT_BROWSERS_PATH internally)
14+
# -- Stage 2: Production runtime --
15+
FROM python:3.14-slim-bookworm@sha256:55e465cb7e50cd1d7217fcb5386aa87d0356ca2cd790872142ef68d9ef6812b4
16+
17+
RUN useradd -m -s /bin/bash pwuser
18+
19+
WORKDIR /app
20+
21+
COPY --from=builder /app/.venv /app/.venv
22+
ENV PATH="/app/.venv/bin:$PATH"
2223
ENV PLAYWRIGHT_BROWSERS_PATH=/opt/patchright
23-
# Install dependencies, system libs for Chromium, and patched Chromium binary
24-
RUN uv sync --frozen && \
25-
uv run patchright install-deps chromium && \
26-
uv run patchright install chromium && \
27-
chmod -R 755 /opt/patchright
2824

29-
# Fix ownership of app directory (venv created by uv)
30-
RUN chown -R pwuser:pwuser /app
25+
RUN patchright install-deps chromium && \
26+
patchright install chromium && \
27+
chmod -R 755 /opt/patchright && \
28+
rm -rf /var/lib/apt/lists/*
3129

32-
# Switch to non-root user
3330
USER pwuser
3431

35-
# Set entrypoint and default arguments
36-
ENTRYPOINT ["uv", "run", "-m", "linkedin_mcp_server"]
32+
ENTRYPOINT ["python", "-m", "linkedin_mcp_server"]
3733
CMD []

pyproject.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ name = "linkedin-scraper-mcp"
33
version = "4.8.2"
44
description = "MCP server for LinkedIn profile, company, and job scraping with Claude AI integration. Supports direct profile/company/job URL scraping with secure credential storage."
55
readme = "README.md"
6-
requires-python = ">=3.12,<3.14"
6+
requires-python = ">=3.12,<3.15"
77
authors = [
88
{ name = "Daniel Sticker", email = "daniel@sticker.name" }
99
]
@@ -25,6 +25,7 @@ classifiers = [
2525
"Programming Language :: Python :: 3",
2626
"Programming Language :: Python :: 3.12",
2727
"Programming Language :: Python :: 3.13",
28+
"Programming Language :: Python :: 3.14",
2829
"Topic :: Software Development :: Libraries :: Python Modules",
2930
"Topic :: Internet :: WWW/HTTP :: Dynamic Content",
3031
"Topic :: Scientific/Engineering :: Artificial Intelligence",

renovate.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,13 @@
3030
"matchPackageNames": ["fastmcp", "mcp"],
3131
"matchUpdateTypes": ["minor", "patch"],
3232
"groupName": "MCP ecosystem"
33+
},
34+
{
35+
"description": "Python runtime upgrades need manual validation",
36+
"matchDatasources": ["docker"],
37+
"matchPackageNames": ["python"],
38+
"matchUpdateTypes": ["major", "minor"],
39+
"enabled": false
3340
}
3441
]
3542
}

0 commit comments

Comments
 (0)