-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdockerfile
More file actions
51 lines (35 loc) · 1.01 KB
/
dockerfile
File metadata and controls
51 lines (35 loc) · 1.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# 构建阶段
FROM golang:1.24-alpine AS builder
# 设置工作目录
WORKDIR /app
# 安装必要的构建工具
RUN apk add --no-cache git ca-certificates
# 复制 go.mod 和 go.sum
COPY go.mod go.sum ./
# 下载依赖
RUN go mod download
# 复制源代码
COPY . .
# 构建应用程序,针对 Linux AMD64
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -a -installsuffix cgo -ldflags="-w -s" -o github-mcp .
# 运行阶段
FROM alpine:latest
# 安装 ca-certificates 以支持 HTTPS 请求
RUN apk --no-cache add ca-certificates
# 创建非 root 用户
RUN addgroup -S appgroup && adduser -S appuser -G appgroup
WORKDIR /app
# 从构建阶段复制二进制文件
COPY --from=builder /app/github-mcp .
# 更改所有权
RUN chown -R appuser:appgroup /app
# 切换到非 root 用户
USER appuser
# 暴露端口(默认 8080)
EXPOSE 8080
# 设置环境变量
ENV SERVER_PORT=8080
ENV SERVER_MODE=streamable-http
# 启动应用程序
ENTRYPOINT ["./github-mcp"]
CMD ["--mode", "streamable-http", "--port", "8080"]