新增wiki命令文件
This commit is contained in:
57
wiki/concepts/Docker容器化部署.md
Normal file
57
wiki/concepts/Docker容器化部署.md
Normal file
@@ -0,0 +1,57 @@
|
||||
---
|
||||
title: "Docker容器化部署"
|
||||
type: concept
|
||||
tags: [docker, deployment, containerization]
|
||||
sources: [tiktok-pm-python-django-project.md]
|
||||
last_updated: 2026-04-14
|
||||
---
|
||||
|
||||
## Definition
|
||||
Docker容器化部署通过docker-compose编排多个容器,实现开发生产环境一致性。
|
||||
|
||||
## Architecture
|
||||
|
||||
### Services
|
||||
- **web**:Django + Gunicorn应用
|
||||
- **nginx**:反向代理和静态文件服务
|
||||
- **MySQL**:外部数据库(也可容器化)
|
||||
|
||||
### docker-compose.yml
|
||||
```yaml
|
||||
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
|
||||
- [[Docker容器化部署]] ← contains ← [[Django]]
|
||||
- [[Docker容器化部署]] ← contains ← [[Gunicorn]]
|
||||
- [[Docker容器化部署]] ← contains ← [[Nginx]]
|
||||
- [[Docker容器化部署]] ← uses ← [[MySQL]]
|
||||
Reference in New Issue
Block a user