Skip to content

Commit e4fa15b

Browse files
yanchenwyanchenw
authored andcommitted
Optimize multi-stage build Dockerfile
Remove explicitly copied dependencies, copy entire solution into the conainter and depends on the cache to reduce build time. Addd temporary solution file which does not contains the dcproj file to work around the issue that the dotnet cli cannot handle dcproj.
1 parent 505d0f9 commit e4fa15b

23 files changed

Lines changed: 1177 additions & 147 deletions

.dockerignore

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,14 @@
44
.gitignore
55
.vs
66
.vscode
7-
docker-compose.yml
8-
docker-compose.*.yml
7+
docker-compose*.yml
8+
docker-compose.dcproj
9+
*.sln
10+
!eShopOnContainers-ServicesAndWebApps-MultiStageBuild.sln
11+
*.md
12+
hosts
13+
LICENSE
14+
*.testsettings
915
vsts-docs
1016
test
1117
ServiceFabric
@@ -22,4 +28,5 @@ cli-linux
2228
**/obj/
2329
**/node_modules/
2430
**/bower_components/
31+
**/wwwroot/lib/
2532
global.json

docker-compose-external.override.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
version: '3'
1+
version: '3.4'
22

33
services:
44
sql.data:

docker-compose-external.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
version: '3'
1+
version: '3.4'
22

33
services:
44
sql.data:

docker-compose-windows.prod.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
version: '3'
1+
version: '3.4'
22

33
# The Production docker-compose file has to have the external/real IPs or DNS names for the services
44
# The ESHOP_PROD_EXTERNAL_DNS_NAME_OR_IP environment variable is taken, by default, from the ".env" file defined like:

docker-compose-windows.yml

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
version: '3'
1+
version: '3.4'
22

33
services:
44
basket.api:
55
image: eshop/basket.api-win:${TAG:-latest}
66
build:
77
context: .
8-
dockerfile: ./src/Services/Basket/Basket.API/Dockerfile
8+
dockerfile: src/Services/Basket/Basket.API/Dockerfile
99
depends_on:
1010
- basket.data
1111
- identity.api
@@ -15,7 +15,7 @@ services:
1515
image: eshop/catalog.api-win:${TAG:-latest}
1616
build:
1717
context: .
18-
dockerfile: ./src/Services/Catalog/Catalog.API/Dockerfile
18+
dockerfile: src/Services/Catalog/Catalog.API/Dockerfile
1919
depends_on:
2020
- sql.data
2121
- rabbitmq
@@ -24,15 +24,15 @@ services:
2424
image: eshop/identity.api-win:${TAG:-latest}
2525
build:
2626
context: .
27-
dockerfile: ./src/Services/Identity/Identity.API/Dockerfile
27+
dockerfile: src/Services/Identity/Identity.API/Dockerfile
2828
depends_on:
2929
- sql.data
3030

3131
ordering.api:
3232
image: eshop/ordering.api-win:${TAG:-latest}
3333
build:
3434
context: .
35-
dockerfile: ./src/Services/Ordering/Ordering.API/Dockerfile
35+
dockerfile: src/Services/Ordering/Ordering.API/Dockerfile
3636
depends_on:
3737
- sql.data
3838
- rabbitmq
@@ -41,7 +41,7 @@ services:
4141
image: eshop/marketing.api-win:${TAG:-latest}
4242
build:
4343
context: .
44-
dockerfile: ./src/Services/Marketing/Marketing.API/Dockerfile
44+
dockerfile: src/Services/Marketing/Marketing.API/Dockerfile
4545
depends_on:
4646
- sql.data
4747
- nosql.data
@@ -52,7 +52,7 @@ services:
5252
image: eshop/webspa-win:${TAG:-latest}
5353
build:
5454
context: .
55-
dockerfile: ./src/Web/WebSPA/Dockerfile
55+
dockerfile: src/Web/WebSPA/Dockerfile
5656
depends_on:
5757
- catalog.api
5858
- ordering.api
@@ -63,7 +63,7 @@ services:
6363
webmvc:
6464
image: eshop/webmvc-win:${TAG:-latest}
6565
build:
66-
context: ./src/Web/WebMVC
66+
context: src/Web/WebMVC
6767
dockerfile: Dockerfile
6868
depends_on:
6969
- catalog.api
@@ -76,21 +76,21 @@ services:
7676
image: eshop/webstatus-win:${TAG:-latest}
7777
build:
7878
context: .
79-
dockerfile: ./src/Web/WebStatus/Dockerfile
79+
dockerfile: src/Web/WebStatus/Dockerfile
8080

8181
payment.api:
8282
image: eshop/payment.api-win:${TAG:-latest}
8383
build:
8484
context: .
85-
dockerfile: ./src/Services/Payment/Payment.API/Dockerfile
85+
dockerfile: src/Services/Payment/Payment.API/Dockerfile
8686
depends_on:
8787
- rabbitmq
8888

8989
locations.api:
9090
image: eshop/locations.api-win:${TAG:-latest}
9191
build:
9292
context: .
93-
dockerfile: ./src/Services/Location/Locations.API/Dockerfile
93+
dockerfile: src/Services/Location/Locations.API/Dockerfile
9494
depends_on:
9595
- nosql.data
9696
- rabbitmq

docker-compose.ci.build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
version: '3'
1+
version: '3.4'
22

33
services:
44
ci-build:

docker-compose.dcproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<DockerServiceUrl>http://localhost:5100</DockerServiceUrl>
77
<DockerServiceName>webmvc</DockerServiceName>
88
<DockerTargetOS>Linux</DockerTargetOS>
9-
<ProjectVersion>2.0</ProjectVersion>
9+
<ProjectVersion>2.1</ProjectVersion>
1010
</PropertyGroup>
1111
<ItemGroup>
1212
<None Include=".dockerignore" />

docker-compose.nobuild.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
version: '3'
1+
version: '3.4'
22

33
services:
44
basket.api:

docker-compose.override.windows.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
version: '3'
1+
version: '3.4'
22

33
# ONLY NEEDED WHEN RUNNING WINDOWS CONTAINERS
44
#

docker-compose.override.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
version: '3'
1+
version: '3.4'
22

33
# The default docker-compose.override file can use the "localhost" as the external name for testing web apps within the same dev machine.
44
# The ESHOP_EXTERNAL_DNS_NAME_OR_IP environment variable is taken, by default, from the ".env" file defined like:

0 commit comments

Comments
 (0)