-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathDockerfile
More file actions
52 lines (36 loc) · 1.22 KB
/
Copy pathDockerfile
File metadata and controls
52 lines (36 loc) · 1.22 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
52
FROM golang:1.19-alpine AS builder
# 设置工作目录
WORKDIR /app
# 安装必要的工具
RUN apk add --no-cache git
# 复制 go.mod 和 go.sum 文件
COPY go.mod go.sum ./
# 下载依赖
RUN go mod download
# 复制源代码
COPY . .
# 编译应用
RUN CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o rainmcp ./cmd/rainmcp
# 使用 nginx 镜像作为最终镜像
FROM nginx:1.23-alpine
# 安装 ca-certificates 以支持 HTTPS 和 supervisor 来管理进程
RUN apk --no-cache add ca-certificates tzdata supervisor
# 设置工作目录
WORKDIR /app
# 从 builder 阶段复制编译好的二进制文件
COPY --from=builder /app/rainmcp .
# 设置时区为亚洲/上海
ENV TZ=Asia/Shanghai
# 设置环境变量默认值
ENV RAINBOND_HOST=127.0.0.1:8080
ENV RAINBOND_API=https://rainbond-api.example.com
ENV RAINBOND_TOKEN=""
# 创建 Nginx 配置文件,添加 CORS 支持
RUN mkdir -p /etc/nginx/conf.d
COPY nginx.conf /etc/nginx/conf.d/default.conf
# 创建 supervisor 配置文件
COPY supervisord.conf /etc/supervisor/conf.d/supervisord.conf
# 暴露 Nginx 端口
EXPOSE 80
# 使用 supervisor 启动 Nginx 和 Rainbond MCP 服务
CMD ["/usr/bin/supervisord", "-c", "/etc/supervisor/conf.d/supervisord.conf"]