|
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 |
3 | 3 |
|
4 |
| -# Change the working directory to the `app` directory |
| 4 | +# Set the working directory |
5 | 5 | WORKDIR /app
|
6 | 6 |
|
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 ./ |
12 | 9 |
|
13 |
| -# Copy the project into the intermediate image |
14 |
| -ADD . /app |
| 10 | +# Download dependencies |
| 11 | +RUN go mod download |
15 | 12 |
|
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 . . |
19 | 15 |
|
20 |
| -FROM python:3.13-slim |
| 16 | +# Build the application |
| 17 | +RUN go build -o mcp-grafana ./cmd/mcp-grafana |
21 | 18 |
|
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 |
24 | 21 |
|
| 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 |
25 | 38 | EXPOSE 8000
|
26 | 39 |
|
27 | 40 | # 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