二、使用docker-compose搭建AspNetCore开发环境
version: "2" services:redis:
build: ./redis/
restart: always
container_name: mac-redis
identity:
build: ~/identity/src/Web/#identity项目的Dockerfile所在的目录
restart: always
volumes:
- ~/identity/src/Web/bin/Debug/netcoreapp1.1/publish:/app #把编译好的序集添加到数据卷中
links:
- 'ucenter:api.ucenter.com' #因为identity项目依赖ucenter项目,identity目内部通过url:api.ucenter.com调用ucenter的webapi,所以这里要给设置一个和ur一样的别名,这样identity项目访问`api.ucenter.com`就会被转发到ucenter容器。
- redis
extra_hosts:
- "dbserver:192.168.199.143" #之前搭建了一个sqlserver容器,那个是单独放在个Linux机器里面,所以这里就直接通过地址调用,注意要开启远程访问。
container_name:> logging:
driver: "json-file"
options:
max-size: "50k" #因为随着程序的运行,日志会越来越多,导致每次加载时间越越长,所以规定日志文件大小,节省时间
max-file: "10"
ucenter:
build: ~/UCenter/src/WebAPI #ucenter项目的Dockerfile所在的目录
restart: always
volumes:
- ~/UCenter/src/WebAPI/bin/Debug/netcoreapp1.1/publish:/app
links:
- redis
extra_hosts:
- "dbserver:192.168.199.143"
container_name: ucenter
nginx-host:
build: ./nginx #nginx的Dockerfile所在的目录
restart: always
ports:
- "80:80" #监听主机的80端口,或者其它的端口都可以
links:
-> - ucenter
volumes:
- ./nginx/sites-enabled:/etc/nginx/sites-enabled #nginx的配置文件放在据卷中,以后需要改动的时候,重启nginx就可以了,不用重新build
- /WebCommon:/www/data #各个项目共用的静态文件,一般走cdn的,在开发环境里就nginx代理
container_name: nginx-host
logging:
driver: "json-file"
options:
max-size: "50k"
max-file: "10"
页:
[1]