使用Docker部署Django通道

我正试图将我的应用程序移到Docker上。 我目前正在使用结构来部署我的Django应用程序。 我创build了一个docker-compose文件:

version: '3' volumes: static-files: services: nginx: image: nginx:latest volumes: - ./deploy/conf/nginx.conf.template:/etc/nginx/conf.d/mysite.template - static-files:/app/static ports: - "80:80" environment: - NGINX_HOST='localhost' command: /bin/bash -c "envsubst '\$NGINX_HOST' < /etc/nginx/conf.d/mysite.template > /etc/nginx/conf.d/default.conf && nginx -g 'daemon off;'" depends_on: - interface redis: image: redis:latest db: restart: always image: mdillon/postgis:9.5 environment: - POSTGRES_USER=production - POSTGRES_PASSWORD=production - POSTGRES_DB=production interface: restart: always build: . working_dir: /app/code/src command: ["../../../wait-for-db.sh", "db", "./interface-entrypoint.sh"] volumes: - static-files:/app/static environment: - DJANGO_SETTINGS_MODULE=restapi.settings.production_settings expose: - "8001" depends_on: - db - redis workerserver: restart: always build: . working_dir: /app/code/src command: ["./worker-entrypoint.sh"] environment: - DJANGO_SETTINGS_MODULE=restapi.settings.production_settings depends_on: - db - redis - interface 

这个docker-compose工作正常,我可以连接到服务器和所有。 所以我的问题是:

  1. 如何使用我的现有数据库与Docker安装程序? 我尝试使用卷,但我不能得到它的工作..
  2. 你如何处理这个设置的迁移和代码更改? 在织物方面,我只是做了迁移工作,并且和pipe理人员重新启动了工人 。 这里每个工人都有自己的“代码”在容器中。 以某种方式共享容器之间的代码并为迁移创build单独的容器是否有意义?
  3. 我如何自动部署? 例如:我对代码进行了更改,我想将其部署到暂存环境中,我不希望我的服务器在几分钟内不可用。 随着面料我的服务器永远不会下降,因为达芙妮从来没有重新启动,并始终接受连接。