在Visual Studio 2019的一个解决方案中,我在Docker的微服务架构中有很多项目。现在我有一个docker-compose.yml文件。建立一个图像似乎花费太长时间,而花费太长时间则意味着一个多小时。
services:
nosql.data:
image: mongo
mongo1:
image: mongo
hostname: mongo1
container_name: mongo1
command: "--replSet rs0"
mongo2:
image: mongo
hostname: mongo2
container_name: mongo2
command: "--replSet rs0"
mongo3:
image: mongo
hostname: mongo3
container_name: mongo3
command: "--replSet rs0"
mysql.data:
image: mysql:latest
container_name: mysql.data
rabbit:
image: rabbitmq:management
container_name: rabbit
es01:
image: docker.elastic.co/elasticsearch/elasticsearch:7.2.0
container_name: es01
ulimits:
memlock:
soft: -1
hard: -1
volumes:
- esdata01:/elasticsearch/data
es02:
image: docker.elastic.co/elasticsearch/elasticsearch:7.2.0
container_name: es02
ulimits:
memlock:
soft: -1
hard: -1
volumes:
- esdata02:/elasticsearch/data
cnx.useraccessmanagement.api:
image: ${REGISTRY:}/useraccessmanagement.api:${PLATFORM:-linux}-${TAG:-latest}
build:
context: .
dockerfile: src/Services/Program2/Dockerfile
depends_on:
- nosql.data
- mysql.data
- rabbit
cnx.identity.api:
image: ${REGISTRY:}/identity.api:${PLATFORM:-linux}-${TAG:-latest}
build:
context: .
dockerfile: src/Services/Program1/Dockerfile
cnx.apigateway:
image: ${REGISTRY:}/apigateway:${PLATFORM:-linux}-${TAG:-latest}
build:
context: .
dockerfile: src/ApiGateway/Dockerfile
depends_on:
- identity.api
- nosql.data
- mysql.data
- rabbit
volumes:
esdata01:
driver: local
esdata02:
driver: local
项目文件大小几乎为1gb,就此docker compose文件中设置的构建上下文而言,影响构建时间是否重要?如果可以,该如何优化呢?