Files
nexus/wiki/concepts/Docker容器化部署.md
2026-04-14 16:02:50 +08:00

1.4 KiB
Raw Blame History

title, type, tags, sources, last_updated
title type tags sources last_updated
Docker容器化部署 concept
docker
deployment
containerization
tiktok-pm-python-django-project.md
2026-04-14

Definition

Docker容器化部署通过docker-compose编排多个容器实现开发生产环境一致性。

Architecture

Services

  • webDjango + Gunicorn应用
  • nginx:反向代理和静态文件服务
  • MySQL:外部数据库(也可容器化)

docker-compose.yml

services:
  web:
    build: .
    command: gunicorn tiktok_pm_project.wsgi:application
    volumes:
      - ./data:/app/data
    env_file:
      - .env

  worker:
    build: .
    command: python manage.py qcluster

  nginx:
    image: nginx
    ports:
      - "80:80"
    volumes:
      - ./nginx/nginx.conf:/etc/nginx/nginx.conf
    depends_on:
      - web

Deployment Workflow

  1. 拉取最新代码git pull origin main
  2. 重建容器docker compose up --build -d
  3. 执行迁移docker compose exec web python manage.py migrate
  4. 创建超级用户docker compose exec web python manage.py createsuperuser

Static Files

使用collectstatic收集静态文件Nginx提供/static/路由。

Connections