V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
推荐学习书目
Learn Python the Hard Way
Python Sites
PyPI - Python Package Index
http://diveintopython.org/toc/index.html
Pocoo
值得关注的项目
PyPy
Celery
Jinja2
Read the Docs
gevent
pyenv
virtualenv
Stackless Python
Beautiful Soup
结巴中文分词
Green Unicorn
Sentry
Shovel
Pyflakes
pytest
Python 编程
pep8 Checker
Styles
PEP 8
Google Python Style Guide
Code Style from The Hitchhiker's Guide
nanmu42
V2EX  ›  Python

编写 Python Poetry 项目的 Dockerfile

  •  1
     
  •   nanmu42 ·
    nanmu42 · 195 天前 · 1546 次点击
    这是一个创建于 195 天前的主题,其中的信息可能已经有所发展或是发生改变。

    各位好,我写了一篇文章,分享最近摸索出的 Python Poetry 项目的 Docker 镜像打包方法,好处是:

    • Poetry 和 Python 开箱即用,包括项目依赖,不用在启动时额外运行 entrypoint.sh 这类脚本初始化环境;
    • 为开发和部署都准备好镜像;
    • 使用国内镜像源以加速构建。

    欢迎各位交流。

    文章链接: https://nanmu.me/zh-cn/posts/2023/quick-dockerfile-for-python-poetry-projects/

    4 条回复    2023-10-16 09:40:48 +08:00
    nanmu42
        1
    nanmu42  
    OP
       195 天前 via iPhone
    自己打破一下零回复惨案。🤣
    dayeye2006199
        2
    dayeye2006199  
       195 天前 via Android   ❤️ 1
    可以用 buildpack ,超简单的
    nanmu42
        3
    nanmu42  
    OP
       194 天前
    @dayeye2006199 谢谢推荐,我去看看。
    aloxaf
        4
    aloxaf  
       194 天前   ❤️ 1
    你这写得太复杂了,假如有人想通过你的文章学习打包方法,还得手动剔除掉他不需要的部分。

    这里推荐一下 pdm 官方的打包示例: https://pdm.fming.dev/latest/usage/advanced/#use-pdm-in-a-multi-stage-dockerfile
    简洁明了,而且通过设置 PYTHONPATH 使得最终产物中完全不需要把 pdm 自己打包进去
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   984 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 26ms · UTC 19:20 · PVG 03:20 · LAX 12:20 · JFK 15:20
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.