-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
51 lines (39 loc) · 1.67 KB
/
Copy pathDockerfile
File metadata and controls
51 lines (39 loc) · 1.67 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# Build stage - compile Go binary and Playwright CLI
FROM golang:1.25-bookworm AS builder
WORKDIR /build
COPY go.mod go.sum ./
RUN go mod download
COPY . .
RUN go build -o playwright-mcp-server ./cmd/server && \
go build -o playwright-cli github.com/playwright-community/playwright-go/cmd/playwright
# Runtime stage - minimal image with Playwright browsers
FROM ubuntu:24.04
# Install ca-certificates, Playwright browsers, and their system dependencies.
# The playwright-cli binary (built from the project's pinned playwright-go version)
# ensures browser versions match the library expectations.
COPY --from=builder /build/playwright-cli /usr/local/bin/playwright
RUN apt-get update && \
apt-get install -y --no-install-recommends ca-certificates && \
playwright install --with-deps && \
rm /usr/local/bin/playwright && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*
# Create non-root user and copy Playwright driver + browsers to its home
RUN useradd -r -m -s /usr/sbin/nologin mcpuser && \
mkdir -p /home/mcpuser/.cache && \
cp -r /root/.cache/ms-playwright /root/.cache/ms-playwright-go /home/mcpuser/.cache/ && \
chown -R mcpuser:mcpuser /home/mcpuser/.cache
WORKDIR /app
# Copy server binary and default config
COPY --from=builder /build/playwright-mcp-server .
COPY config.yaml .
RUN chown -R mcpuser:mcpuser /app
USER mcpuser
# Override at runtime with -e MCP_CONFIG_PATH=/custom/config.yaml
ENV MCP_CONFIG_PATH=/app/config.yaml
# Bind to all interfaces so the server is accessible outside the container
ENV MCP_HOST=0.0.0.0
# Default port; override at runtime with -e MCP_PORT=<port>
ENV MCP_PORT=3000
EXPOSE ${MCP_PORT}
CMD ["./playwright-mcp-server"]