-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathDockerfile
More file actions
159 lines (149 loc) · 4.59 KB
/
Copy pathDockerfile
File metadata and controls
159 lines (149 loc) · 4.59 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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
# check=skip=SecretsUsedInArgOrEnv
ARG BUN_VERSION=1.3.14
ARG PLAYWRIGHT_VERSION=1.59.0
FROM oven/bun:${BUN_VERSION} AS ui-builder
WORKDIR /source
COPY ui /source/ui
COPY src/local_shell_mcp /source/src/local_shell_mcp
RUN cd /source/ui && bun install --frozen-lockfile && bun run build
FROM alpine:3.22 AS tmux-builder
ARG TMUX_VERSION=3.5a
ARG TMUX_SHA256=16216bd0877170dfcc64157085ba9013610b12b082548c7c9542cc0103198951
RUN apk add --no-cache \
build-base \
bison \
ca-certificates \
curl \
libevent-dev \
libevent-static \
linux-headers \
ncurses-dev \
ncurses-static \
pkgconf
WORKDIR /build
RUN curl -fsSL "https://github.com/tmux/tmux/releases/download/${TMUX_VERSION}/tmux-${TMUX_VERSION}.tar.gz" -o tmux.tar.gz \
&& echo "${TMUX_SHA256} tmux.tar.gz" | sha256sum -c - \
&& tar -xzf tmux.tar.gz
WORKDIR /build/tmux-${TMUX_VERSION}
RUN LIBEVENT_CFLAGS="$(pkg-config --cflags libevent)" \
LIBEVENT_LIBS="$(pkg-config --static --libs libevent)" \
LIBTINFO_CFLAGS="$(pkg-config --cflags ncursesw)" \
LIBTINFO_LIBS="$(pkg-config --static --libs ncursesw)" \
LDFLAGS="-static" \
./configure \
&& make -j"$(getconf _NPROCESSORS_ONLN)" \
&& strip tmux \
&& ./tmux -V \
&& mkdir -p /out \
&& install -m 0755 tmux /out/tmux
FROM mcr.microsoft.com/playwright/python:v${PLAYWRIGHT_VERSION}-noble
ARG PLAYWRIGHT_VERSION
ARG TARGETARCH
ENV PYTHONUNBUFFERED=1 \
PIP_DISABLE_PIP_VERSION_CHECK=1 \
VIRTUAL_ENV=/opt/local-shell-mcp-venv \
LOCAL_SHELL_MCP_WORKSPACE_ROOT=/workspace \
LOCAL_SHELL_MCP_HOST=0.0.0.0 \
LOCAL_SHELL_MCP_PORT=8765 \
LOCAL_SHELL_MCP_PERSISTENT_CREDENTIALS=true \
LOCAL_SHELL_MCP_CREDENTIALS_DIR=/persist/credentials \
LOCAL_SHELL_MCP_UI_TUI_COMMAND=/usr/local/bin/local-shell-mcp-tui
RUN apt-get update && apt-get install -y --no-install-recommends \
bash \
ca-certificates \
sudo \
curl \
git \
gh \
jq \
openssh-client \
patch \
ripgrep \
tmux \
tree \
vim-tiny \
wget \
zip \
unzip \
build-essential \
autoconf \
automake \
clang \
cmake \
gdb \
lldb \
libtool \
make \
ninja-build \
pkg-config \
python3-dev \
python3-pip \
python3-venv \
pipx \
nodejs \
npm \
golang-go \
rustc \
cargo \
openjdk-21-jdk \
maven \
gradle \
ruby-full \
php-cli \
php-curl \
php-dev \
php-mbstring \
php-xml \
composer \
perl \
lua5.4 \
luarocks \
r-base \
shellcheck \
sqlite3 \
file \
libmagic1 \
pandoc \
poppler-utils \
tesseract-ocr \
libreoffice-calc \
libreoffice-impress \
libreoffice-writer \
&& rm -rf /var/lib/apt/lists/*
RUN python3 -m venv "${VIRTUAL_ENV}"
ENV PATH="${VIRTUAL_ENV}/bin:${PATH}"
WORKDIR /app
COPY requirements-agent.txt pyproject.toml hatch_build.py README.md LICENSE /app/
RUN pip install --no-cache-dir -r requirements-agent.txt
COPY src /app/src
COPY --from=tmux-builder /out/tmux /tmp/local-shell-mcp-tmux
RUN set -eux; \
case "${TARGETARCH}" in \
amd64) helper_arch="x86_64" ;; \
arm64) helper_arch="aarch64" ;; \
*) echo "Unsupported tmux helper architecture: ${TARGETARCH}" >&2; exit 1 ;; \
esac; \
install -d "/app/src/local_shell_mcp/helpers/linux-${helper_arch}"; \
install -m 0755 /tmp/local-shell-mcp-tmux "/app/src/local_shell_mcp/helpers/linux-${helper_arch}/tmux"; \
rm -f /tmp/local-shell-mcp-tmux
COPY --from=ui-builder /source/src/local_shell_mcp/ui_static /app/src/local_shell_mcp/ui_static
COPY --from=ui-builder /source/ui/dist/local-shell-mcp-tui /usr/local/bin/local-shell-mcp-tui
RUN pip install --no-cache-dir -e ".[dev]" "playwright==${PLAYWRIGHT_VERSION}" \
&& chmod 0755 /usr/local/bin/local-shell-mcp-tui \
&& test -s /app/src/local_shell_mcp/ui_static/index.html \
&& test -s /app/src/local_shell_mcp/ui_static/web.js \
&& test -s /app/src/local_shell_mcp/ui_static/web.css \
&& /usr/local/bin/local-shell-mcp-tui --version
COPY scripts/docker-entrypoint.sh /usr/local/bin/docker-entrypoint.sh
RUN useradd -m -u 10001 agent \
&& mkdir -p /workspace /workspace/.local-shell-mcp /persist/credentials \
&& echo "agent ALL=(ALL) NOPASSWD:ALL" > /etc/sudoers.d/agent-nopasswd \
&& chmod 0440 /etc/sudoers.d/agent-nopasswd \
&& chown -R agent:agent /workspace /app \
&& chmod +x /usr/local/bin/docker-entrypoint.sh
WORKDIR /workspace
VOLUME ["/workspace", "/persist/credentials"]
EXPOSE 8765
ENTRYPOINT ["docker-entrypoint.sh"]
CMD ["local-shell-mcp", "--mode", "mcp"]