适用于非Web应用程序的Docker + IDE的Python工作流 [英] Workflow for Python with Docker + IDE for non-web applications

查看:105
本文介绍了适用于非Web应用程序的Docker + IDE的Python工作流的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在尝试将Docker插入我的非Web应用程序的Python开发工作流中。

I am currently trying to insert Docker in my Python development workflow of non-web applications.

使用Docker和IDE进行Python开发的当前最佳实践是什么? ?
我需要使用Docker隔离我的环境并调试代码的可能性。

What are the current best practices in Python development using Docker and an IDE? I need the possibility to isolate my environments with Docker and debug my code.

在网络上,我发现了很多有关使用Docker部署代码的文章。 :

On the web I found many articles about the use of Docker to deploy your code:


  • 生产部署:如何构建Docker映像,准备与已经打包在其中的应用程序一起旋转

  • 反映生产的开发环境:扩展了上述内容,您可以在开发过程中使用容器对项目的当前状态进行全面质量检查,然后再部署到生产中

除了在开发Web应用程序时如何使用共享卷映射到主机上目录的容器的一些技巧外,我对实际开发工作流程的了解不多。这种方法不适用于非Web应用程序,并且存在一些问题,即简单的重新加载(使用类似LiveReload的机制)还不够,因此您需要重新启动容器。

I found a lot less about an actual development workflow, apart from some tips on how to use containers with shared volumes mapped to the directories on the host while developing web applications. This approach does not apply to non-web applications and it has some issues where a simple reload (with a LiveReload-like mechanism) is not enough so you need to restart your container(s).

我能找到的最接近的文字是这个八种Docker开发模式 博客,

The closest writing I could find is this "Eight Docker Development Patterns" blog post, but it does not consider an IDE (like PyCharm I am using now).

也许这个问题是配置PyCharm花费了3-4个小时(并且还在计算)的结果使用运行在Docker容器中的远程Python解释器。我希望两者之间有更好的集成。

Maybe this question is the result of the 3-4 hours (and counting) spent configuring PyCharm to use a remote Python interpreter running in a Docker container. I expected a much better integration between the two.

推荐答案

实际上,我相信在PyCharm中使用Docker解释器是解决问题的方法走。您有哪个版本的PyCharm?如果您使用的是2016版,则应在几秒钟内完成设置。您只需要确保docker计算机正在运行,并且必须构建要与项目一起使用的映像即可。 PyCharm会在添加远程解释器对话框中自动找到Docker计算机。然后选择您的图像,一切就绪。

Actually, I believe that using the Docker interpreter in PyCharm is the way to go. Which version of PyCharm do you have? If you have the 2016 version, it should be set up within seconds. You just have to make sure your docker machine is running and you must have your image built that you would like to use with your project. PyCharm will find the Docker machine in the "add remote interpreter" dialog automatically. Then select your image and you're all set up.

您可以像往常一样运行代码,几乎没有任何延迟。

You can run your code as usual then, almost without any delay.

这对我有用: https://www.jetbrains.com/help/pycharm/2016.1/configuring-remote-interpreters-via-docker.html

并确保更新PyCharm,解决了我遇到的一些问题。

And make sure to update PyCharm, that solved some issues I had.

这篇关于适用于非Web应用程序的Docker + IDE的Python工作流的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆