소스 검색

增加docker配置

swjian 3 주 전
부모
커밋
602389b35a
2개의 변경된 파일5개의 추가작업 그리고 27개의 파일을 삭제
  1. 2 1
      Dockerfile
  2. 3 26
      docker-compose.yml

+ 2 - 1
Dockerfile

@@ -9,4 +9,5 @@ COPY . .
 
 EXPOSE 8100
 
-CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8100", "--workers", "8"]
+# 使用 waitress 运行 Flask 应用,监听 8100 端口
+CMD ["python", "-m", "waitress", "--host", "0.0.0.0", "--port", "8100", "--threads", "8", "app:app"]

+ 3 - 26
docker-compose.yml

@@ -1,34 +1,11 @@
 services:
   math-questions:
     build: .
-    # 不再直接暴露端口,通过 Nginx 访问
-    # ports:
-    #   - "8100:8100"
+    container_name: math-questions-app
     env_file:
       - .env
     restart: unless-stopped
-    networks:
-      - app-network
-
-  nginx:
-    image: nginx:alpine
     ports:
-      - "80:80"
-      - "443:443"
-    volumes:
-      - ./nginx.conf:/etc/nginx/conf.d/default.conf:ro
-      - ./ssl:/etc/nginx/ssl:ro
-      - nginx-logs:/var/log/nginx
-    depends_on:
-      - math-questions
-    restart: unless-stopped
-    networks:
-      - app-network
-
-volumes:
-  nginx-logs:
-
+      - "8100:8100"   # 外部访问 http://服务器IP:8100
 
-networks:
-  app-network:
-    driver: bridge
+# 使用默认 bridge 网络即可,这里就不单独配置 networks 了