Dockerfile 1005 B

1234567891011121314151617181920212223242526272829303132333435
  1. # 使用Python 3.11.11作为基础镜像
  2. # FROM python:3.11.11-slim
  3. # FROM swr.cn-north-4.myhuaweicloud.com/ddn-k8s/docker.io/wallies/python-cuda:3.11-cuda11.8-runtime
  4. FROM registry.cn-hangzhou.aliyuncs.com/serverless_devs/pytorch:22.12-py3
  5. RUN pip config set global.index-url https://mirrors.aliyun.com/pypi/simple/
  6. RUN sed -i 's|http://archive.ubuntu.com/ubuntu|http://mirrors.aliyun.com/ubuntu|g' /etc/apt/sources.list && \
  7. sed -i 's|http://security.ubuntu.com/ubuntu|http://mirrors.aliyun.com/ubuntu|g' /etc/apt/sources.list
  8. # 设置工作目录
  9. WORKDIR /app
  10. # 设置环境变量
  11. ENV PYTHONUNBUFFERED=1 \
  12. PYTHONDONTWRITEBYTECODE=1 \
  13. PIP_NO_CACHE_DIR=1
  14. # 安装系统依赖
  15. RUN apt-get update && apt-get install -y --no-install-recommends \
  16. build-essential \
  17. libmagic1 \
  18. && rm -rf /var/lib/apt/lists/*
  19. # 复制项目文件
  20. COPY . .
  21. # 安装Python依赖
  22. RUN pip install --no-cache-dir -r requirements.txt
  23. EXPOSE 5001
  24. # 设置默认命令
  25. CMD ["python", "func_test.py"]