Skip to content

Commit 607a304

Browse files
yanchenwyanchenw
authored andcommitted
Optimize multistage build
1 parent 9e8f632 commit 607a304

12 files changed

Lines changed: 31 additions & 1128 deletions

File tree

.dockerignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
docker-compose*.yml
88
docker-compose.dcproj
99
*.sln
10-
!eShopOnContainers-ServicesAndWebApps-MultiStageBuild.sln
10+
!eShopOnContainers-ServicesAndWebApps.sln
1111
*.md
1212
hosts
1313
LICENSE

eShopOnContainers-ServicesAndWebApps-MultiStageBuild.sln

Lines changed: 0 additions & 1107 deletions
This file was deleted.

src/Services/Basket/Basket.API/Dockerfile

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,11 @@ EXPOSE 80
55
FROM microsoft/aspnetcore-build:2.0 AS build
66
WORKDIR /src
77
COPY . .
8-
RUN dotnet build -c Release -nowarn:msb3202,nu1503
8+
RUN dotnet restore -nowarn:msb3202,nu1503
9+
WORKDIR /src/src/Services/Basket/Basket.API
10+
RUN dotnet build --no-restore -c Release -o /app
911

1012
FROM build AS publish
11-
WORKDIR /src/src/Services/Basket/Basket.API
1213
RUN dotnet publish --no-restore -c Release -o /app
1314

1415
FROM base AS final

src/Services/Catalog/Catalog.API/Dockerfile

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,11 @@ EXPOSE 80
55
FROM microsoft/aspnetcore-build:2.0 AS build
66
WORKDIR /src
77
COPY . .
8-
RUN dotnet build -c Release -nowarn:msb3202,nu1503
8+
RUN dotnet restore -nowarn:msb3202,nu1503
9+
WORKDIR /src/src/Services/Catalog/Catalog.API
10+
RUN dotnet build --no-restore -c Release -o /app
911

1012
FROM build AS publish
11-
WORKDIR /src/src/Services/Catalog/Catalog.API
1213
RUN dotnet publish --no-restore -c Release -o /app
1314

1415
FROM base AS final

src/Services/Identity/Identity.API/Dockerfile

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,11 @@ EXPOSE 80
55
FROM microsoft/aspnetcore-build:2.0 AS build
66
WORKDIR /src
77
COPY . .
8-
RUN dotnet build -c Release -nowarn:msb3202,nu1503
8+
RUN dotnet restore -nowarn:msb3202,nu1503
9+
WORKDIR /src/src/Services/Identity/Identity.API
10+
RUN dotnet build --no-restore -c Release -o /app
911

1012
FROM build AS publish
11-
WORKDIR /src/src/Services/Identity/Identity.API
1213
RUN dotnet publish --no-restore -c Release -o /app
1314

1415
FROM base AS final

src/Services/Location/Locations.API/Dockerfile

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,11 @@ EXPOSE 80
55
FROM microsoft/aspnetcore-build:2.0 AS build
66
WORKDIR /src
77
COPY . .
8-
RUN dotnet build -c Release -nowarn:msb3202,nu1503
8+
RUN dotnet restore -nowarn:msb3202,nu1503
9+
WORKDIR /src/src/Services/Location/Locations.API
10+
RUN dotnet build --no-restore -c Release -o /app
911

1012
FROM build AS publish
11-
WORKDIR /src/src/Services/Location/Locations.API
1213
RUN dotnet publish --no-restore -c Release -o /app
1314

1415
FROM base AS final

src/Services/Marketing/Marketing.API/Dockerfile

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,11 @@ EXPOSE 80
55
FROM microsoft/aspnetcore-build:2.0 AS build
66
WORKDIR /src
77
COPY . .
8-
RUN dotnet build -c Release -nowarn:msb3202,nu1503
8+
RUN dotnet restore -nowarn:msb3202,nu1503
9+
WORKDIR /src/src/Services/Marketing/Marketing.API
10+
RUN dotnet build --no-restore -c Release -o /app
911

1012
FROM build AS publish
11-
WORKDIR /src/src/Services/Marketing/Marketing.API
1213
RUN dotnet publish --no-restore -c Release -o /app
1314

1415
FROM base AS final

src/Services/Ordering/Ordering.API/Dockerfile

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,11 @@ EXPOSE 80
55
FROM microsoft/aspnetcore-build:2.0 AS build
66
WORKDIR /src
77
COPY . .
8-
RUN dotnet build -c Release -nowarn:msb3202,nu1503
8+
RUN dotnet restore -nowarn:msb3202,nu1503
9+
WORKDIR /src/src/Services/Ordering/Ordering.API
10+
RUN dotnet build --no-restore -c Release -o /app
911

1012
FROM build AS publish
11-
WORKDIR /src/src/Services/Ordering/Ordering.API
1213
RUN dotnet publish --no-restore -c Release -o /app
1314

1415
FROM base AS final

src/Services/Payment/Payment.API/Dockerfile

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,11 @@ EXPOSE 80
55
FROM microsoft/aspnetcore-build:2.0 AS build
66
WORKDIR /src
77
COPY . .
8-
RUN dotnet build -c Release -nowarn:msb3202,nu1503
8+
RUN dotnet restore -nowarn:msb3202,nu1503
9+
WORKDIR /src/src/Services/Payment/Payment.API
10+
RUN dotnet build --no-restore -c Release -o /app
911

1012
FROM build AS publish
11-
WORKDIR /src/src/Services/Payment/Payment.API
1213
RUN dotnet publish --no-restore -c Release -o /app
1314

1415
FROM base AS final

src/Web/WebMVC/Dockerfile

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,11 @@ EXPOSE 80
55
FROM microsoft/aspnetcore-build:2.0 AS build
66
WORKDIR /src
77
COPY . .
8-
RUN dotnet build -c Release -nowarn:msb3202,nu1503
8+
RUN dotnet restore -nowarn:msb3202,nu1503
9+
WORKDIR /src/src/Web/WebMVC
10+
RUN dotnet build --no-restore -c Release -o /app
911

1012
FROM build AS publish
11-
WORKDIR /src/src/Web/WebMVC
1213
RUN bower install --allow-root
1314
RUN dotnet bundle
1415
RUN dotnet publish --no-restore -c Release -o /app

0 commit comments

Comments
 (0)