Dockerfile 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. #FROM python:3.8
  2. #
  3. #RUN apt-get update && apt-get install -y nodejs
  4. #
  5. #
  6. #RUN apt-get install -y npm
  7. #
  8. #WORKDIR /FlaskProject
  9. #COPY . /FlaskProject
  10. #
  11. #
  12. ##RUN npm --registry http://mirrors.cloud.tencent.com/npm/ install crypto
  13. ##RUN npm --registry http://mirrors.cloud.tencent.com/npm/ install crypto-js
  14. #
  15. #
  16. #
  17. #RUN pip3 install --no-cache-dir -r requirements.txt -i https://pypi.tuna.tsinghua.edu.cn/simple/
  18. #
  19. #
  20. #
  21. #CMD ["python3","Flask_API.py"]
  22. # 基于的基础镜像
  23. FROM python:3.9.13
  24. # setup dependencies
  25. RUN wget https://nodejs.org/dist/v16.17.0/node-v16.17.0-linux-x64.tar.xz
  26. RUN xz -d node-v16.17.0-linux-x64.tar.xz
  27. RUN tar -xvf node-v16.17.0-linux-x64.tar
  28. # 添加软链接
  29. RUN ln -s /node-v16.17.0-linux-x64/bin/node /usr/local/bin/node
  30. RUN ln -s /node-v16.17.0-linux-x64/bin/npm /usr/local/bin/npm
  31. RUN npm config set registry https://registry.npmmirror.com/
  32. WORKDIR /usr/src
  33. RUN npm install crypto
  34. RUN npm install crypto-js
  35. # 设置app文件夹是工作目录
  36. WORKDIR /usr/src/FlaskProject
  37. # Docker 避免每次更新代码后都重新安装依赖
  38. # 先将依赖文件拷贝到项目中
  39. COPY requirements.txt /usr/src/FlaskProject
  40. # 执行指令,安装依赖
  41. RUN pip install -r requirements.txt -i https://pypi.tuna.tsinghua.edu.cn/simple/
  42. # RUN pip install --no-cache-dir -r requirements.txt
  43. # COPY指令和ADD指令功能和使用方式类似。只是COPY指令不会做自动解压工作。
  44. # 拷贝项目文件和代码
  45. COPY . /usr/src/FlaskProject
  46. # 执行命令
  47. CMD ["python", "/usr/src/FlaskProject/Flask_API.py"]