Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/django/23.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/docker/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用Docker部署Django频道_Django_Docker_Docker Compose_Django Channels - Fatal编程技术网

使用Docker部署Django频道

使用Docker部署Django频道,django,docker,docker-compose,django-channels,Django,Docker,Docker Compose,Django Channels,我正在尝试将我的应用程序移动到Docker。我目前正在使用fabric部署我的Django应用程序。 我创建了一个docker compose文件: version: '3' volumes: static-files: services: nginx: image: nginx:latest volumes: - ./deploy/conf/nginx.conf.template:/etc/nginx/conf.d/mysite.template

我正在尝试将我的应用程序移动到Docker。我目前正在使用fabric部署我的Django应用程序。 我创建了一个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
版本:“3”
卷数:
静态文件:
服务:
nginx:
图片:nginx:latest
卷数:
-./deploy/conf/nginx.conf.template:/etc/nginx/conf.d/mysite.template
-静态文件:/app/static
端口:
- "80:80"
环境:
-NGINX_HOST='localhost'
命令:/bin/bash-c“envsubt'\$NGINX\u HOST'/etc/NGINX/conf.d/default.conf&&NGINX-g“daemon off;””
取决于:
-接口
redis:
图片:redis:最新版本
db:
重新启动:始终
图片:mdillon/postgis:9.5
环境:
-POSTGRES_用户=生产
-POSTGRES_密码=生产
-POSTGRES_DB=生产
接口:
重新启动:始终
生成:。
工作目录:/app/code/src
命令:[“../../../wait for db.sh”、“db”、“/interface entrypoint.sh”]
卷数:
-静态文件:/app/static
环境:
-DJANGO_设置_模块=restapi.SETTINGS.production_设置
揭露:
- "8001"
取决于:
-分贝
-雷迪斯
workerserver:
重新启动:始终
生成:。
工作目录:/app/code/src
命令:[“/worker entrypoint.sh”]
环境:
-DJANGO_设置_模块=restapi.SETTINGS.production_设置
取决于:
-分贝
-雷迪斯
-接口
这个docker组件工作正常,我可以连接到服务器和所有。因此,我的问题是:

  • 如何在Docker设置中使用现有数据库?我尝试使用卷,但无法使其正常工作
  • 如何使用此设置处理迁移和代码更改?对于fabric,我只进行了迁移,并且与主管一起重新启动了工人。在这里,每个工人在容器中都有自己的“代码”。以某种方式在容器之间共享代码并为迁移创建单独的容器是否有意义
  • 如何自动部署?例如:我对代码进行更改,并希望将其部署到临时环境,我不希望我的服务器在几分钟内不可用。使用fabric,我的服务器永远不会停机,因为Daphne从未重新启动,它一直在接受连接

  • 请一次只问一个问题。堆栈溢出用于特定问题。