Skip to content

Commit da9ecad

Browse files
committed
Update Dockerfile to build Go-based image
1 parent a83af0f commit da9ecad

File tree

2 files changed

+90
-17
lines changed

2 files changed

+90
-17
lines changed

.dockerignore

+60
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
# Git
2+
.git
3+
.gitignore
4+
.github/
5+
6+
# Docker
7+
Dockerfile
8+
.dockerignore
9+
10+
# Build artifacts
11+
bin/
12+
dist/
13+
build/
14+
*.exe
15+
*.exe~
16+
*.dll
17+
*.so
18+
*.dylib
19+
20+
# Go specific
21+
vendor/
22+
go.work
23+
24+
# Testing
25+
*_test.go
26+
**/test/
27+
**/tests/
28+
coverage.out
29+
coverage.html
30+
31+
# IDE and editor files
32+
.idea/
33+
.vscode/
34+
*.swp
35+
*.swo
36+
*~
37+
38+
# OS specific
39+
.DS_Store
40+
Thumbs.db
41+
42+
# Temporary files
43+
tmp/
44+
temp/
45+
*.tmp
46+
*.log
47+
48+
# Documentation
49+
docs/
50+
*.md
51+
LICENSE
52+
53+
# Development tools
54+
.air.toml
55+
.golangci.yml
56+
.goreleaser.yml
57+
58+
# Debug files
59+
debug
60+
__debug_bin

Dockerfile

+30-17
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,41 @@
1-
FROM python:3.13-slim AS builder
2-
COPY --from=ghcr.io/astral-sh/uv:latest /uv /uvx /bin/
1+
# Build stage
2+
FROM golang:1.24-bullseye AS builder
33

4-
# Change the working directory to the `app` directory
4+
# Set the working directory
55
WORKDIR /app
66

7-
# Install dependencies
8-
RUN --mount=type=cache,target=/root/.cache/uv \
9-
--mount=type=bind,source=uv.lock,target=uv.lock \
10-
--mount=type=bind,source=pyproject.toml,target=pyproject.toml \
11-
uv sync --frozen --no-install-project --no-editable
7+
# Copy go.mod and go.sum files
8+
COPY go.mod go.sum ./
129

13-
# Copy the project into the intermediate image
14-
ADD . /app
10+
# Download dependencies
11+
RUN go mod download
1512

16-
# Sync the project
17-
RUN --mount=type=cache,target=/root/.cache/uv \
18-
uv sync --frozen --no-editable
13+
# Copy the source code
14+
COPY . .
1915

20-
FROM python:3.13-slim
16+
# Build the application
17+
RUN go build -o mcp-grafana ./cmd/mcp-grafana
2118

22-
# Copy the environment, but not the source code
23-
COPY --from=builder --chown=app:app /app/.venv /app/.venv
19+
# Final stage
20+
FROM debian:bullseye-slim
2421

22+
# Install ca-certificates for HTTPS requests
23+
RUN apt-get update && apt-get install -y ca-certificates && rm -rf /var/lib/apt/lists/*
24+
25+
# Create a non-root user
26+
RUN useradd -r -u 1000 -m mcp-grafana
27+
28+
# Set the working directory
29+
WORKDIR /app
30+
31+
# Copy the binary from the builder stage
32+
COPY --from=builder --chown=1000:1000 /app/mcp-grafana /app/
33+
34+
# Use the non-root user
35+
USER mcp-grafana
36+
37+
# Expose the port the app runs on
2538
EXPOSE 8000
2639

2740
# Run the application
28-
ENTRYPOINT ["/app/.venv/bin/mcp-grafana", "--transport", "sse"]
41+
ENTRYPOINT ["/app/mcp-grafana", "--transport", "sse", "--sse-address", "0.0.0.0:8000"]

0 commit comments

Comments
 (0)