修改dockerfile
Some checks failed
Gitea Actions Demo / Explore-Gitea-Actions (push) Failing after 4m45s
Some checks failed
Gitea Actions Demo / Explore-Gitea-Actions (push) Failing after 4m45s
This commit is contained in:
parent
cae827e801
commit
a632bc7332
@ -39,8 +39,6 @@ jobs:
|
|||||||
fi
|
fi
|
||||||
docker run -d --rm --name gong-zheng-api \
|
docker run -d --rm --name gong-zheng-api \
|
||||||
-v /usr/share/fonts/opentype/noto:/usr/share/fonts \
|
-v /usr/share/fonts/opentype/noto:/usr/share/fonts \
|
||||||
-v $(pwd)/audio:/app/audio \
|
|
||||||
-p 6211:8080 \
|
-p 6211:8080 \
|
||||||
-p 6212:8000 \
|
|
||||||
gong-zheng-api:${{ gitea.run_id }}
|
gong-zheng-api:${{ gitea.run_id }}
|
||||||
- run: echo "🍏 This job's status is ${{ job.status }}."
|
- run: echo "🍏 This job's status is ${{ job.status }}."
|
||||||
49
Dockerfile
49
Dockerfile
@ -1,7 +1,7 @@
|
|||||||
# 构建 Go 服务
|
# 构建 Go 服务
|
||||||
FROM golang:1.21-alpine AS go-builder
|
FROM golang:1.21-alpine AS go-builder
|
||||||
|
|
||||||
WORKDIR /app
|
WORKDIR /usr/src/app
|
||||||
|
|
||||||
# 安装必要的构建工具
|
# 安装必要的构建工具
|
||||||
RUN apk add --no-cache gcc musl-dev
|
RUN apk add --no-cache gcc musl-dev
|
||||||
@ -12,45 +12,16 @@ COPY . .
|
|||||||
# 构建 Go 服务
|
# 构建 Go 服务
|
||||||
RUN go build -o main ./main.go
|
RUN go build -o main ./main.go
|
||||||
|
|
||||||
# 构建 Python 服务
|
# 运行阶段
|
||||||
FROM python:3.11-slim
|
FROM alpine:latest
|
||||||
|
|
||||||
WORKDIR /app
|
WORKDIR /usr/src/app
|
||||||
|
|
||||||
# 安装必要的系统依赖
|
# 从构建阶段复制编译好的二进制文件
|
||||||
RUN apt-get update && apt-get install -y \
|
COPY --from=go-builder /usr/src/app/main .
|
||||||
ca-certificates \
|
|
||||||
&& rm -rf /var/lib/apt/lists/*
|
|
||||||
|
|
||||||
# 创建音频目录
|
# 暴露端口(根据你的 API 服务端口修改)
|
||||||
RUN mkdir -p /app/audio
|
EXPOSE 8080
|
||||||
|
|
||||||
# 复制 Python 文件服务器
|
# 运行服务
|
||||||
COPY file_server.py .
|
CMD ["./main"]
|
||||||
|
|
||||||
# 从 go-builder 阶段复制编译好的 Go 服务
|
|
||||||
COPY --from=go-builder /app/main .
|
|
||||||
|
|
||||||
# 复制配置文件(如果有的话)
|
|
||||||
COPY --from=go-builder /app/config.yaml .
|
|
||||||
|
|
||||||
# 设置环境变量
|
|
||||||
ENV PORT=8000
|
|
||||||
ENV GO_PORT=8080
|
|
||||||
|
|
||||||
# 创建启动脚本
|
|
||||||
RUN echo '#!/bin/bash\n\
|
|
||||||
# 启动 Go 服务\n\
|
|
||||||
./main &\n\
|
|
||||||
# 启动 Python 文件服务器\n\
|
|
||||||
python file_server.py -p $PORT\n\
|
|
||||||
' > /app/start.sh && chmod +x /app/start.sh
|
|
||||||
|
|
||||||
# 暴露端口
|
|
||||||
EXPOSE 8000 8080
|
|
||||||
|
|
||||||
# 设置工作目录
|
|
||||||
WORKDIR /app
|
|
||||||
|
|
||||||
# 启动服务
|
|
||||||
CMD ["/app/start.sh"]
|
|
||||||
|
|||||||
@ -4,11 +4,9 @@ services:
|
|||||||
app:
|
app:
|
||||||
build: .
|
build: .
|
||||||
ports:
|
ports:
|
||||||
- "8000:8000" # Python 文件服务器端口
|
|
||||||
- "8080:8080" # Go 服务端口
|
- "8080:8080" # Go 服务端口
|
||||||
volumes:
|
volumes:
|
||||||
- ./audio:/app/audio # 挂载音频目录
|
- ./audio:/app/audio # 挂载音频目录
|
||||||
environment:
|
environment:
|
||||||
- PORT=8000
|
|
||||||
- GO_PORT=8080
|
- GO_PORT=8080
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
@ -62,7 +62,6 @@ class FileHandler(http.server.SimpleHTTPRequestHandler):
|
|||||||
with open(file_path, 'rb') as f:
|
with open(file_path, 'rb') as f:
|
||||||
self.send_response(200)
|
self.send_response(200)
|
||||||
self.send_header('Content-type', content_type)
|
self.send_header('Content-type', content_type)
|
||||||
self.send_header('Content-Disposition', f'attachment; filename="{os.path.basename(file_path)}"')
|
|
||||||
self.end_headers()
|
self.end_headers()
|
||||||
self.wfile.write(f.read())
|
self.wfile.write(f.read())
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user