Skip to content

Commit f79ce1c

Browse files
committed
MCP-70 Let users pass certificates to the docker container
1 parent e32d0bf commit f79ce1c

File tree

3 files changed

+76
-9
lines changed

3 files changed

+76
-9
lines changed

Dockerfile

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -29,18 +29,22 @@ ENV PATH="${JAVA_HOME}/bin:${PATH}"
2929

3030
COPY --from=builder /optimized-jdk-21 $JAVA_HOME
3131

32-
RUN apk add --no-cache nodejs=~22 npm
33-
34-
WORKDIR /app
35-
36-
RUN addgroup -S appgroup && adduser -S appuser -G appgroup && \
37-
mkdir -p /home/appuser/.sonarlint ./storage && \
38-
chown -R appuser:appgroup /home/appuser ./storage
32+
RUN apk add --no-cache \
33+
ca-certificates \
34+
nodejs=~22 \
35+
npm \
36+
sudo && \
37+
addgroup -S appgroup && adduser -S appuser -G appgroup && \
38+
mkdir -p /home/appuser/.sonarlint ./storage && \
39+
chown -R appuser:appgroup /home/appuser ./storage && \
40+
echo "appuser ALL=(ALL) NOPASSWD: /usr/sbin/update-ca-certificates" > /etc/sudoers.d/appuser && \
41+
chmod 0440 /etc/sudoers.d/appuser
3942

4043
COPY --from=builder --chown=appuser:appgroup --chmod=755 /app/sonarqube-mcp-server.jar /app/sonarqube-mcp-server.jar
44+
COPY --chown=appuser:appgroup --chmod=755 scripts/install-certificates.sh /usr/local/bin/install-certificates
4145

4246
USER appuser
43-
47+
WORKDIR /app
4448
ENV STORAGE_PATH=./storage
4549

46-
ENTRYPOINT ["java", "-jar", "/app/sonarqube-mcp-server.jar"]
50+
ENTRYPOINT ["/bin/sh", "-c", "/usr/local/bin/install-certificates && exec java -jar /app/sonarqube-mcp-server.jar"]

README.md

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,55 @@ To enable full functionality, the following environment variables must be set be
169169
| `SONARQUBE_TOKEN` | Your SonarQube Server **USER** [token](https://docs.sonarsource.com/sonarqube-server/latest/user-guide/managing-tokens/#generating-a-token) |
170170
| `SONARQUBE_URL` | Your SonarQube Server URL |
171171

172+
### Custom Certificates
173+
174+
If your SonarQube Server uses a self-signed certificate or a certificate from a private Certificate Authority (CA), you can add custom certificates to the Docker container that will automatically be installed.
175+
176+
#### Using Docker Volume Mount
177+
178+
Mount a directory containing your certificates when running the container:
179+
180+
```bash
181+
docker run -i --rm \
182+
-v /path/to/your/certificates/:/usr/local/share/ca-certificates/:ro \
183+
-e SONARQUBE_TOKEN="<token>" \
184+
-e SONARQUBE_URL="<url>" \
185+
mcp/sonarqube
186+
```
187+
188+
#### Supported Certificate Formats
189+
190+
The container supports the following certificate formats:
191+
- `.crt` files (PEM or DER encoded)
192+
- `.pem` files (PEM encoded)
193+
194+
#### MCP Configuration with Certificates
195+
196+
When using custom certificates, you can modify your MCP configuration to mount the certificates:
197+
198+
```JSON
199+
{
200+
"sonarqube": {
201+
"command": "docker",
202+
"args": [
203+
"run",
204+
"-i",
205+
"--rm",
206+
"-v",
207+
"/path/to/your/certificates/:/usr/local/share/ca-certificates/:ro",
208+
"-e",
209+
"SONARQUBE_TOKEN",
210+
"-e",
211+
"SONARQUBE_URL",
212+
"mcp/sonarqube"
213+
],
214+
"env": {
215+
"SONARQUBE_TOKEN": "<token>",
216+
"SONARQUBE_URL": "<url>"
217+
}
218+
}
219+
}
220+
```
172221

173222
## Tools
174223

scripts/install-certificates.sh

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#!/bin/sh
2+
3+
# Certificate installation script for SonarQube MCP Server
4+
5+
CERT_DIR="/usr/local/share/ca-certificates/"
6+
7+
if [ "$(ls -A "$CERT_DIR")" ]; then
8+
echo "Installing custom certificates from $CERT_DIR..."
9+
10+
# Run as root via sudo
11+
sudo /usr/sbin/update-ca-certificates
12+
13+
echo "Custom certificates installed successfully"
14+
fi

0 commit comments

Comments
 (0)