记一次Django服务搭建
准备Python环境
创建虚拟环境 python3 -m evnv .
安装依赖包 pip install -r requirements.txt
准备Django环境
创建Django项目 django-admin startproject [项目名]
docker-compose.yml
version: "3"
services:
# Nginx负载均衡服务
my_app_nginx:
container_name: my_app_nginx
image: nginx:stable
restart: always
ports:
- 80:80
volumes:
- ./conf.d:/etc/nginx/conf.d
depends_on:
- my_app_1
- my_app_2
my_app_1:
image: gdc.docker.iec.io/my-app:luoyangyang-20210123
restart: always
container_name: my_app_1
environment:
- DB_HOST=my_app_postgres
- DB_PORT=5432
depends_on:
- my_app_2
- my_app_postgres
my_app_2:
image: gdc.docker.iec.io/my-app:luoyangyang-20210123
restart: always
container_name: my_app_2
environment:
- DB_HOST=my_app_postgres
- DB_PORT=5432
depends_on:
- my_app_postgres
my_app_postgres:
image: yisiqi/postgres-asciinema:11
container_name: my_app_postgres
restart: always
environment:
- POSTGRES_DB=demo
- POSTGRES_USER=postgres
- POSTGRES_PASSWORD=postgres