Dockerfile 839 B

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