简体   繁体   English

码头工人与python3和Django生产映像?

[英]docker with python3 and django production image?

Does anyone use docker for a production image of Django, and how do you build that box? 是否有人将docker用于Django的生产映像,以及如何构建该框?

I'm using the base python image with a requirements.txt for development. 我正在将基本的python图像与require.txt一起用于开发。 but id like to use a docker image for production too, but appreciate a web server should be used for this. 但id也想将docker映像用于生产,但感谢您应该为此使用网络服务器。 I've used apache in the past. 我过去曾经用过Apache。 is there a good approach to this? 有一个好的方法吗?

Thanks 谢谢

I'm currently using Docker in production with Django. 我目前在Django中使用Docker。 There is not only one valid approach, but there are some components (Docker images) that you're going to need. 不仅有一种有效的方法,而且还需要一些组件(Docker映像)。

  1. WSGI server: This will serve your Django application. WSGI服务器:这将为您的Django应用程序服务。 Personally, I use gunicorn, but there are other good options. 就我个人而言,我使用gunicorn,但还有其他不错的选择。
  2. Web server: You could use the WSGI server to serve your static files, but that's not recommended in production. Web服务器:您可以使用WSGI服务器来提供您的静态文件,但是在生产中不建议这样做。 I use nginx to this, but almost any web server will be suitable for this task. 我为此使用nginx,但是几乎任何Web服务器都适合该任务。 Take a look to this section at Django documentation about serving static files in production ( https://docs.djangoproject.com/en/1.11/howto/static-files/deployment/ ) 请参阅有关在生产环境中提供静态文件的Django文档的本节( https://docs.djangoproject.com/zh-CN/1.11/howto/static-files/deployment/
  3. Database : Unless your Django app is really simple, you'll need a database. 数据库 :除非您的Django应用非常简单,否则您将需要一个数据库。

This are the basic components that you are going to need in a Django app. 这是Django应用程序中需要的基本组件。 Each one of this should be a Docker image. 其中的每一个都应该是一个Docker映像。

Hope this helps, good luck! 希望这有帮助,祝你好运!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM