Spaces:
Build error
Build error
Fix: Corrected Dockerfile to resolve module replacement issue
Browse filesRemoved problematic go mod edit -replace command and implemented proper multi-stage build process
- Dockerfile +26 -37
Dockerfile
CHANGED
|
@@ -1,51 +1,40 @@
|
|
| 1 |
-
|
| 2 |
-
|
| 3 |
|
| 4 |
-
# Set the working directory
|
| 5 |
WORKDIR /build
|
| 6 |
|
| 7 |
-
# Install git
|
| 8 |
-
RUN --
|
| 9 |
-
apk add git
|
| 10 |
|
| 11 |
-
# Copy
|
| 12 |
-
COPY . .
|
| 13 |
|
| 14 |
-
#
|
| 15 |
-
RUN
|
| 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 |
-
#
|
| 21 |
-
|
| 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 |
-
#
|
| 27 |
-
|
| 28 |
|
| 29 |
-
#
|
| 30 |
-
|
| 31 |
|
| 32 |
-
|
| 33 |
-
|
| 34 |
|
| 35 |
-
# Copy the
|
| 36 |
-
COPY
|
| 37 |
|
| 38 |
-
#
|
| 39 |
-
|
| 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 |
-
#
|
| 45 |
-
RUN
|
| 46 |
|
| 47 |
-
# Expose
|
| 48 |
-
EXPOSE
|
| 49 |
|
| 50 |
-
# Run the
|
| 51 |
-
CMD ["
|
|
|
|
| 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"]
|