grok-server-demo / Dockerfile
emheroes's picture
Update Dockerfile
9fc0b61 verified
raw
history blame contribute delete
856 Bytes
# 使用官方 Go 镜像作为构建阶段
FROM golang:1.24.0 AS builder
# 设置工作目录
WORKDIR /app
# 复制 go.mod 和 go.sum 文件
COPY go.mod go.sum ./
# 下载依赖
RUN go mod download
# 复制源代码
COPY app-text.go ./
# 构建 Go 应用
RUN CGO_ENABLED=0 GOOS=linux go build -o grok3_api app-text.go
# 使用轻量级 Alpine 镜像作为运行阶段
FROM alpine:latest
# 安装必要的证书(如果需要 HTTPS 请求)
RUN apk --no-cache add ca-certificates
# 设置工作目录
WORKDIR /root/
# 从构建阶段复制可执行文件
COPY --from=builder /app/grok3_api .
# 暴露端口(默认 8180,可根据需要修改)
EXPOSE 7860
# 设置默认环境变量(可通过 Hugging Face 环境变量覆盖)
ENV GROK3_AUTH_TOKEN="your-auth-token"
ENV GROK3_COOKIE="your-grok-cookie"
# 运行应用
CMD ["./grok3_api"]