V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
推荐学习书目
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 · Oct 15, 2023 · 2588 views
    This topic created in 930 days ago, the information mentioned may be changed or developed.

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

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

    欢迎各位交流。

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

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

    这里推荐一下 pdm 官方的打包示例: https://pdm.fming.dev/latest/usage/advanced/#use-pdm-in-a-multi-stage-dockerfile
    简洁明了,而且通过设置 PYTHONPATH 使得最终产物中完全不需要把 pdm 自己打包进去
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   758 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 31ms · UTC 21:40 · PVG 05:40 · LAX 14:40 · JFK 17:40
    ♥ Do have faith in what you're doing.