Browse Source

修改docker配置文件

locky 2 weeks ago
parent
commit
11f70abe25
3 changed files with 16 additions and 17 deletions
  1. 11 8
      Dockerfile
  2. 2 4
      docker-compose.yml
  3. 3 5
      requirements.txt

+ 11 - 8
Dockerfile

@@ -1,21 +1,24 @@
-FROM python:3.7.9-slim
+FROM python:3.9-slim
 
 WORKDIR /app
 
-# 安装系统依赖
+# 安装系统依赖(mysqlclient 编译需要)
 RUN apt-get update && apt-get install -y \
     default-libmysqlclient-dev \
     build-essential \
     pkg-config \
-    && rm -rf /var/lib/apt/lists/*
+ && rm -rf /var/lib/apt/lists/*
+
+# 复制 requirements
+COPY requirements.txt /app/
+
+# 安装 Python 依赖
+RUN pip install --no-cache-dir -r requirements.txt \
+ && pip install --no-cache-dir gunicorn
 
 # 复制项目文件
 COPY . /app/
 
-# 安装Python依赖
-RUN pip install --no-cache-dir -r requirements.txt
-RUN pip install gunicorn
-
 # 创建日志目录
 RUN mkdir -p /app/logs
 
@@ -23,4 +26,4 @@ RUN mkdir -p /app/logs
 EXPOSE 8889
 
 # 启动命令
-CMD ["gunicorn", "-w", "2", "-b", "0.0.0.0:8889", "VSeesResourceWeb.wsgi"]
+CMD ["gunicorn", "-w", "2", "-b", "0.0.0.0:8889", "VSeesResourceWeb.wsgi"]

+ 2 - 4
docker-compose.yml

@@ -1,5 +1,3 @@
-version: '3'
-
 services:
   web:
     build: .
@@ -12,7 +10,7 @@ services:
     depends_on:
       - redis
     environment:
-      - DJANGO_SETTINGS_MODULE=VSeesResourceWeb.settings
+      DJANGO_SETTINGS_MODULE: VSeesResourceWeb.settings
 
   redis:
     image: redis:6.0
@@ -21,4 +19,4 @@ services:
       - redis_data:/data
 
 volumes:
-  redis_data:
+  redis_data:

+ 3 - 5
requirements.txt

@@ -1,14 +1,12 @@
 asgiref==3.4.1
 Django==3.2.20
 djangorestframework==3.14.0
-mysqlclient==1.4.6
+mysqlclient==1.4.7
 pytz==2023.3
 sqlparse==0.4.4
 typing_extensions==4.1.1
 boto3==1.23.10
 botocore==1.26.10
-requests==2.18.4
+requests==2.28.2
 redis==3.4.1
-boto3==1.23.10
-botocore==1.26.10
-PyJWT==1.5.3
+PyJWT==1.7.1