diff --git a/.env b/.env index 0595861..0b4cedf 100644 --- a/.env +++ b/.env @@ -6,6 +6,6 @@ MiniMaxApiURL=https://api.minimaxi.com/v1/t2a_v2 APP_ID=1364994890450210816 APP_KEY=b4839cb2-cb81-4472-a2c1-2abf31e4bb27 SIG_EXP=3600 -FILE_URL=http://localhost:8000/ +FILE_URL=http://14.103.170.252:8000/ # Server Configuration PORT=8080 \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..af214b0 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,56 @@ +# 构建 Go 服务 +FROM golang:1.21-alpine AS go-builder + +WORKDIR /app + +# 安装必要的构建工具 +RUN apk add --no-cache gcc musl-dev + +# 复制 Go 项目文件 +COPY . . + +# 构建 Go 服务 +RUN go build -o main ./main.go + +# 构建 Python 服务 +FROM python:3.11-slim + +WORKDIR /app + +# 安装必要的系统依赖 +RUN apt-get update && apt-get install -y \ + ca-certificates \ + && rm -rf /var/lib/apt/lists/* + +# 创建音频目录 +RUN mkdir -p /app/audio + +# 复制 Python 文件服务器 +COPY file_server.py . + +# 从 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"] \ No newline at end of file diff --git a/Readme.md b/Readme.md new file mode 100644 index 0000000..ace6324 --- /dev/null +++ b/Readme.md @@ -0,0 +1,4 @@ +# 一个项目,两个服务 +GO API 服务 暴露端口8080 + +Python 文件访问服务 暴露端口8000 \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..438640c --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,14 @@ +version: '3.8' + +services: + app: + build: . + ports: + - "8000:8000" # Python 文件服务器端口 + - "8080:8080" # Go 服务端口 + volumes: + - ./audio:/app/audio # 挂载音频目录 + environment: + - PORT=8000 + - GO_PORT=8080 + restart: unless-stopped \ No newline at end of file