增加dockerfile + 说明
This commit is contained in:
		
							parent
							
								
									b4b83d113d
								
							
						
					
					
						commit
						44278f57a6
					
				
							
								
								
									
										2
									
								
								.env
									
									
									
									
									
								
							
							
						
						
									
										2
									
								
								.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 | ||||
							
								
								
									
										56
									
								
								Dockerfile
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										56
									
								
								Dockerfile
									
									
									
									
									
										Normal file
									
								
							| @ -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"]  | ||||
							
								
								
									
										4
									
								
								Readme.md
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										4
									
								
								Readme.md
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,4 @@ | ||||
| # 一个项目,两个服务 | ||||
| GO API 服务       暴露端口8080 | ||||
| 
 | ||||
| Python 文件访问服务     暴露端口8000 | ||||
							
								
								
									
										14
									
								
								docker-compose.yml
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										14
									
								
								docker-compose.yml
									
									
									
									
									
										Normal file
									
								
							| @ -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  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 Song367
						Song367