Spaces:
Runtime error
Runtime error
jerrylin-dsi
commited on
Commit
•
2caa117
1
Parent(s):
acf9a51
Create Dockerfile
Browse files- Dockerfile +21 -0
Dockerfile
ADDED
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Build Stage
|
2 |
+
FROM golang:alpine AS builder
|
3 |
+
# 克隆代码
|
4 |
+
RUN apk --no-cache add git
|
5 |
+
RUN git clone https://github.com/adams549659584/go-proxy-bingai.git /app
|
6 |
+
# 设置工作目录
|
7 |
+
WORKDIR /app
|
8 |
+
#编译go项目,s和w时检查编译后二进制大小
|
9 |
+
RUN go build -ldflags="-s -w" -tags netgo -trimpath -o go-proxy-bingai main.go
|
10 |
+
# Runtime Stage
|
11 |
+
# 使用alpine作为运行时的镜像
|
12 |
+
FROM alpine
|
13 |
+
WORKDIR /app
|
14 |
+
# 将构建阶段的编译物拷贝到运行时镜像中
|
15 |
+
COPY --from=builder /app/go-proxy-bingai .
|
16 |
+
# 设置环境变量,此处为随机字符
|
17 |
+
ENV Go_Proxy_BingAI_USER_TOKEN_1="kJs8hD92ncMzLaoQWYtx5rG6bE3fZ4iO"
|
18 |
+
# 暴露端口8080,同时需要在README.md中添加app_port: 8080
|
19 |
+
EXPOSE 8080
|
20 |
+
# 容器启动时运行命令
|
21 |
+
CMD ["/app/go-proxy-bingai"]
|