From 83fe44d7be50b684355219eb849c44feb9a355aa Mon Sep 17 00:00:00 2001 From: liuxiaoqing Date: Mon, 18 Aug 2025 14:01:14 +0800 Subject: [PATCH] =?UTF-8?q?build(docker):=20=E6=9B=B4=E6=96=B0=20Docker=20?= =?UTF-8?q?Compose=20=E9=85=8D=E7=BD=AE=E5=92=8C=20Dockerfile?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 新增 docker-compose.yml 文件,配置 Python 应用服务 - 更新 Dockerfile: - 调整文件结构,先复制再安装依赖 - 移除冗余的 COPY 指令 - 更新 CMD 指令,简化路径 - 注释掉端口映射,可根据需要手动配置 --- docker-compose.yml | 9 +++++++++ dockerfile | 6 +++--- 2 files changed, 12 insertions(+), 3 deletions(-) create mode 100644 docker-compose.yml diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..67caecf --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,9 @@ +version: '1.0' +services: + python-app: + build: . + container_name: python-app + volumes: + - ./:/app + ports: + - "5555:5555" # 如果需要暴露 Flask 端口 diff --git a/dockerfile b/dockerfile index eb6fb0b..ee89b39 100644 --- a/dockerfile +++ b/dockerfile @@ -1,7 +1,7 @@ FROM python:latest WORKDIR /app +COPY . . RUN pip install --no-cache-dir -r requirements.txt RUN python setup.py install -COPY . /app -EXPOSE 5555 -CMD ["python", "/app/alibabacloud_sample/main.py"] \ No newline at end of file + +CMD ["python", "alibabacloud_sample/main.py"] \ No newline at end of file