Repository navigation
Expand file tree
/
Copy pathDockerfile
More file actions
185 lines (152 loc) · 7.59 KB
/
Copy pathDockerfile
File metadata and controls
185 lines (152 loc) · 7.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
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
FROM python:3.13-slim AS builder
COPY --from=ghcr.io/astral-sh/uv:latest /uv /usr/local/bin/uv
WORKDIR /app
COPY pyproject.toml uv.lock ./
RUN --mount=type=cache,target=/root/.cache/uv \
uv sync --frozen --no-install-project
COPY src/ src/
COPY config/ config/
RUN --mount=type=cache,target=/root/.cache/uv \
uv sync --frozen
FROM bufbuild/buf:latest AS buf
FROM python:3.13-slim AS runtime
RUN apt-get update && apt-get install -y --no-install-recommends \
ca-certificates curl git gnupg gosu xz-utils \
&& rm -rf /var/lib/apt/lists/*
RUN curl -fsSL https://cli.github.com/packages/githubcli-archive-keyring.gpg \
| gpg --dearmor -o /usr/share/keyrings/githubcli-archive-keyring.gpg \
&& echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" \
> /etc/apt/sources.list.d/github-cli.list \
&& apt-get update && apt-get install -y --no-install-recommends gh \
&& rm -rf /var/lib/apt/lists/*
RUN curl -fsSL https://packages.adoptium.net/artifactory/api/gpg/key/public \
| gpg --dearmor -o /usr/share/keyrings/adoptium.gpg \
&& echo "deb [signed-by=/usr/share/keyrings/adoptium.gpg] https://packages.adoptium.net/artifactory/deb $(. /etc/os-release && echo $VERSION_CODENAME) main" \
> /etc/apt/sources.list.d/adoptium.list \
&& apt-get update && apt-get install -y --no-install-recommends temurin-21-jdk \
&& rm -rf /var/lib/apt/lists/*
ARG MAVEN_VERSION=3.9.14
RUN curl -fsSL "https://archive.apache.org/dist/maven/maven-3/${MAVEN_VERSION}/binaries/apache-maven-${MAVEN_VERSION}-bin.tar.gz" \
| tar -xz -C /opt \
&& ln -s "/opt/apache-maven-${MAVEN_VERSION}/bin/mvn" /usr/local/bin/mvn
ARG POETRY_VERSION=1.8.5
RUN pip install --no-cache-dir "poetry==${POETRY_VERSION}" ty
COPY --from=buf /usr/local/bin/buf /usr/local/bin/buf
COPY --from=builder /usr/local/bin/uv /usr/local/bin/uv
RUN mkdir -p /opt/jdtls && \
curl -fsSL "https://download.eclipse.org/jdtls/milestones/1.54.0/jdt-language-server-1.54.0-202511261751.tar.gz" \
| tar -xz -C /opt/jdtls
RUN git config --global commit.gpgsign true && \
git config --global user.signingkey "DOES_NOT_EXIST" && \
git config --global user.email "open-agent-tag-bot@invalid.local" && \
git config --global user.name "open-agent-tag-bot (use git_commit MCP tool)"
RUN --mount=type=secret,id=BUF_TOKEN \
BUF_TOKEN=$(cat /run/secrets/BUF_TOKEN) && \
[ -n "$BUF_TOKEN" ] || { echo "ERROR: BUF_TOKEN secret is empty"; exit 1; } && \
mkdir -p /root/.m2 && \
cat > /root/.m2/settings.xml <<EOF
<settings>
<servers>
<server>
<id>buf</id>
<configuration>
<httpHeaders>
<property>
<name>Authorization</name>
<value>Bearer ${BUF_TOKEN}</value>
</property>
</httpHeaders>
</configuration>
</server>
</servers>
<profiles>
<profile>
<id>default</id>
<repositories>
<repository>
<id>buf</id>
<url>https://buf.build/gen/maven</url>
<releases><enabled>true</enabled></releases>
<snapshots><enabled>false</enabled></snapshots>
</repository>
<repository>
<id>confluent</id>
<url>https://packages.confluent.io/maven/</url>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>buf</id>
<url>https://buf.build/gen/maven</url>
</pluginRepository>
</pluginRepositories>
</profile>
</profiles>
<activeProfiles>
<activeProfile>default</activeProfile>
</activeProfiles>
</settings>
EOF
RUN --mount=type=secret,id=BUF_USERNAME \
--mount=type=secret,id=BUF_TOKEN \
BUF_TOKEN=$(cat /run/secrets/BUF_TOKEN) && \
BUF_USERNAME=$(cat /run/secrets/BUF_USERNAME) && \
[ -n "$BUF_TOKEN" ] || { echo "ERROR: BUF_TOKEN secret is empty"; exit 1; } && \
[ -n "$BUF_USERNAME" ] || { echo "ERROR: BUF_USERNAME secret is empty"; exit 1; } && \
printf 'machine buf.build\n login %s\n password %s\n' "$BUF_USERNAME" "$BUF_TOKEN" > /root/.netrc && \
chmod 600 /root/.netrc
RUN cat > /usr/local/bin/setup-npmrc <<'SCRIPT'
#!/bin/bash
set -euo pipefail
{
if [ -n "${BUF_BUILD_NPM_TOKEN:-}" ]; then
echo "@buf:registry=https://buf.build/gen/npm/v1/"
echo "//buf.build/gen/npm/v1/:_authToken=${BUF_BUILD_NPM_TOKEN}"
fi
if [ -n "${BRYNTUM_NPM_TOKEN:-}" ]; then
echo "@bryntum:registry=https://npm.bryntum.com"
echo "//npm.bryntum.com/:_authToken=${BRYNTUM_NPM_TOKEN}"
fi
if [ -n "${TIPTAP_NPM_TOKEN:-}" ]; then
echo "@tiptap-pro:registry=https://registry.tiptap.dev/"
echo "//registry.tiptap.dev/:_authToken=${TIPTAP_NPM_TOKEN}"
fi
} > /root/.npmrc
SCRIPT
RUN chmod +x /usr/local/bin/setup-npmrc
RUN useradd -m -s /bin/bash agent
WORKDIR /app
COPY --from=builder /app/.venv .venv/
COPY --from=builder /app/src src/
COPY --from=builder /app/config config/
COPY docker/scripts/pytest /usr/local/bin/pytest
RUN chmod +x /usr/local/bin/pytest
ARG NODE_VERSION=22.14.0
RUN curl -fsSL "https://nodejs.org/dist/v${NODE_VERSION}/node-v${NODE_VERSION}-linux-$(dpkg --print-architecture).tar.xz" \
| tar -xJf - -C /usr/local --strip-components=1 \
&& corepack enable \
&& corepack prepare pnpm@10.17.1 --activate
RUN npm install -g typescript-language-server@5.1.0 typescript@5.7.3
RUN npm install -g eslint@9.39.1 prettier@3.5.2 @eslint/js@9.39.1 typescript-eslint@8.48.0
RUN npm install -g turbo
RUN curl -fsSL https://download.docker.com/linux/debian/gpg | gpg --dearmor -o /usr/share/keyrings/docker.gpg \
&& echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/docker.gpg] https://download.docker.com/linux/debian $(. /etc/os-release && echo $VERSION_CODENAME) stable" \
> /etc/apt/sources.list.d/docker.list \
&& apt-get update && apt-get install -y --no-install-recommends docker-ce-cli \
&& rm -rf /var/lib/apt/lists/*
RUN mkdir -p /app/plugins/ty /app/plugins/jdtls /app/plugins/typescript
RUN echo '{"name":"ty-lsp","version":"0.1.0"}' > /app/plugins/ty/plugin.json \
&& echo '{"python":{"command":"ty","args":["server"],"extensionToLanguage":{".py":"python"}}}' > /app/plugins/ty/.lsp.json
RUN echo '{"name":"jdtls-lsp","version":"0.1.0"}' > /app/plugins/jdtls/plugin.json \
&& echo '{"java":{"command":"java","args":["-Declipse.application=org.eclipse.jdt.ls.core.id1","-Dosgi.bundles.defaultStartLevel=4","-Declipse.product=org.eclipse.jdt.ls.core.product","-Dlog.level=ALL","-jar","/opt/jdtls/plugins/org.eclipse.equinox.launcher_1.6.900.v20240613-2009.jar","-configuration","/opt/jdtls/config_linux","--add-modules=ALL-SYSTEM","--add-opens","java.base/java.util=ALL-UNNAMED","--add-opens","java.base/java.lang=ALL-UNNAMED"],"extensionToLanguage":{".java":"java"}}}' > /app/plugins/jdtls/.lsp.json
RUN echo '{"name":"typescript-lsp","version":"5.1.0"}' > /app/plugins/typescript/plugin.json \
&& echo '{"typescript":{"command":"typescript-language-server","args":["--stdio"],"extensionToLanguage":{".ts":"typescript",".tsx":"typescript",".js":"javascript",".jsx":"javascript",".mjs":"javascript",".cjs":"javascript",".mts":"typescript",".cts":"typescript"}}}' > /app/plugins/typescript/.lsp.json
RUN chown -R agent:agent /app
ENV PATH="/app/.venv/bin:/usr/local/bin:$PATH"
ENV NODE_PATH="/usr/local/lib/node_modules"
ENV ENABLE_LSP_TOOL=1
EXPOSE 8080
CMD ["sh", "-c", "setup-npmrc; \
mkdir -p /home/agent && cp /root/.npmrc /home/agent/.npmrc 2>/dev/null || true; \
chown -R agent:agent /app/data /app/repos /home/agent 2>/dev/null; \
exec gosu agent python -m open_agent_tag.main"]