harvesthealth commited on
Commit
52515c3
·
verified ·
1 Parent(s): 768fa21

Fix: Corrected Dockerfile to resolve module replacement issue

Browse files

Removed problematic go mod edit -replace command and implemented proper multi-stage build process

Files changed (1) hide show
  1. Dockerfile +26 -37
Dockerfile CHANGED
@@ -1,51 +1,40 @@
1
- FROM golang:1.24.4-alpine AS build
2
- ARG VERSION="dev"
3
 
4
- # Set the working directory
5
  WORKDIR /build
6
 
7
- # Install git
8
- RUN --mount=type=cache,target=/var/cache/apk \
9
- apk add git
10
 
11
- # Copy the entire project structure
12
- COPY . .
13
 
14
- # Fix the import path and tidy dependencies
15
- RUN --mount=type=cache,target=/go/pkg/mod \
16
- --mount=type=cache,target=/root/.cache/go-build \
17
- go mod edit -replace=github.com/mark3labs/mcp-go=github.com/mark3labs/mcp-go/mcp
18
- RUN go mod tidy
19
 
20
- # Build the server
21
- RUN --mount=type=cache,target=/go/pkg/mod \
22
- --mount=type=cache,target=/root/.cache/go-build \
23
- CGO_ENABLED=0 go build -ldflags="-s -w -X main.version=${VERSION} -X main.commit=$(git rev-parse HEAD) -X main.date=$(date -u +%Y-%m-%dT%H:%M:%SZ)" \
24
- -o /bin/github-mcp-server cmd/github-mcp-server/main.go
25
 
26
- # Make a stage to run the app
27
- FROM python:3.9-slim
28
 
29
- # Set the working directory
30
- WORKDIR /app
31
 
32
- # Copy the modified app.py
33
- COPY app.py .
34
 
35
- # Copy the requirements file
36
- COPY requirements.txt .
37
 
38
- # Install the dependencies
39
- RUN pip install --no-cache-dir -r requirements.txt
40
-
41
- # Copy the binary from the build stage
42
- COPY --from=build /bin/github-mcp-server /usr/local/bin/github-mcp-server
43
 
44
- # Verify the binary exists
45
- RUN ls -la /usr/local/bin/github-mcp-server
46
 
47
- # Expose the port the app will run on
48
- EXPOSE 7860
49
 
50
- # Run the web server
51
- CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]
 
1
+ # Multi-stage build for GitHub MCP Server
2
+ FROM golang:1.24.4-alpine AS builder
3
 
 
4
  WORKDIR /build
5
 
6
+ # Install git for go mod download
7
+ RUN apk add --no-cache git
 
8
 
9
+ # Copy go mod files first for better caching
10
+ COPY go.mod go.sum .
11
 
12
+ # Download dependencies
13
+ RUN go mod download
 
 
 
14
 
15
+ # Copy source code
16
+ COPY . .
 
 
 
17
 
18
+ # Build the Go binary
19
+ RUN CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o github-mcp-server ./cmd/github-mcp-server
20
 
21
+ # Final stage
22
+ FROM alpine:latest
23
 
24
+ RUN apk --no-cache add ca-certificates
25
+ WORKDIR /root/
26
 
27
+ # Copy the binary from builder stage
28
+ COPY --from=builder /build/github-mcp-server .
29
 
30
+ # Copy the Python proxy script
31
+ COPY app.py .
 
 
 
32
 
33
+ # Make sure the binary is executable
34
+ RUN chmod +x github-mcp-server
35
 
36
+ # Expose port
37
+ EXPOSE 8080
38
 
39
+ # Run the Python proxy
40
+ CMD ["python3", "app.py"]