Skip to content

Commit 9388080

Browse files
authored
Merge pull request #20 from grafana/publish-image
Add CI step to publish image to GAR
2 parents 520c107 + ca64dd8 commit 9388080

File tree

4 files changed

+70
-0
lines changed

4 files changed

+70
-0
lines changed

.github/workflows/build-image.yml

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
name: CI
2+
on:
3+
push:
4+
branches:
5+
- main
6+
7+
# These permissions are needed to assume roles from Github's OIDC.
8+
permissions:
9+
contents: read
10+
id-token: write
11+
12+
jobs:
13+
build:
14+
name: Build
15+
runs-on: ubuntu-latest
16+
steps:
17+
- name: Check out code
18+
uses: actions/checkout@v4
19+
20+
- name: Image tag
21+
id: image-tag
22+
run: echo "version=$(./image-tag)" >> $GITHUB_OUTPUT
23+
24+
- name: Build and push to GAR
25+
uses: grafana/shared-workflows/actions/push-to-gar-docker@main
26+
id: push-to-gar
27+
with:
28+
platforms: linux/amd64,linux/arm64
29+
file: ./Dockerfile
30+
tags: |
31+
"${{ steps.image-tag.outputs.version }}"
32+
"latest"
33+
image_name: "mcp-grafana"
34+
environment: "dev"

Makefile

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
.PHONY: build-image
2+
build-image:
3+
docker build -t mcp-grafana:latest .

README.md

+12
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,18 @@ To run the server, use:
9090
uvx --from . mcp-grafana
9191
```
9292

93+
You can also run the server using the SSE transport inside Docker. To build the image, use
94+
95+
```
96+
make build-image
97+
```
98+
99+
And to run the image, use:
100+
101+
```
102+
docker run -it --rm mcp-grafana:latest --port-forward 8000:8000
103+
```
104+
93105
### Testing
94106

95107
TL;DR: start a Grafana instance with `docker-compose up`, run `uv run ruff check .` for lints, and `uv run pytest tests --integration` to run unit and integration tests.

image-tag

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#!/usr/bin/env bash
2+
3+
set -o errexit
4+
set -o nounset
5+
set -o pipefail
6+
7+
WIP=$(git diff --quiet || echo '-WIP')
8+
BRANCH=$(git rev-parse --abbrev-ref HEAD | sed 's#/#-#g')
9+
# When 7 chars are not enough to be unique, git automatically uses more.
10+
# We are forcing to 7 here, as we are doing for grafana/grafana as well.
11+
SHA=$(git rev-parse --short=7 HEAD | head -c7)
12+
13+
# If not a tag, use branch-hash else use tag
14+
TAG=$((git describe --exact-match 2> /dev/null || echo "") | sed 's/v//g')
15+
16+
if [ -z "$TAG" ]
17+
then
18+
echo ${BRANCH}-${SHA}${WIP}
19+
else
20+
echo ${TAG}
21+
fi

0 commit comments

Comments
 (0)