Explorar o código

增加docker配置文件

swjian hai 3 semanas
pai
achega
b21cc65e4a
Modificáronse 2 ficheiros con 48 adicións e 0 borrados
  1. 15 0
      Dockerfile
  2. 33 0
      docker-compose.yml

+ 15 - 0
Dockerfile

@@ -0,0 +1,15 @@
+FROM python:3.11-slim
+
+WORKDIR /app
+
+COPY requirements.txt .
+RUN pip install --no-cache-dir -r requirements.txt
+
+# 安装 gunicorn 用于生产环境运行 Flask
+RUN pip install --no-cache-dir gunicorn
+
+COPY . .
+
+EXPOSE 8888
+
+CMD ["gunicorn", "-w", "4", "-b", "0.0.0.0:8888", "app:app"]

+ 33 - 0
docker-compose.yml

@@ -0,0 +1,33 @@
+services:
+  math-analysis:
+    build: .
+    ports:
+      - "8888:8888"
+    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-analysis
+    restart: unless-stopped
+    networks:
+      - app-network
+
+volumes:
+  nginx-logs:
+
+
+networks:
+  app-network:
+    driver: bridge