Skip to content

Commit fc986b4

Browse files
committed
Cache NuGet Packages in Docker Builds
1 parent e2bc0a2 commit fc986b4

File tree

3 files changed

+9
-3
lines changed

3 files changed

+9
-3
lines changed

Source/ApiTemplate/Source/ApiTemplate/Dockerfile

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,9 @@ WORKDIR /src
4343
COPY "ApiTemplate.sln" "."
4444
COPY "Source/ApiTemplate/*.csproj" "Source/ApiTemplate/"
4545
COPY "Tests/ApiTemplate.IntegrationTest/*.csproj" "Tests/ApiTemplate.IntegrationTest/"
46-
RUN dotnet restore
46+
# Run the restore and cache the packages on the host for faster subsequent builds.
47+
RUN --mount=type=cache,id=nuget,target=/root/.nuget/packages /
48+
dotnet restore
4749
COPY . .
4850
# To view the files that have been copied into the container file system for debugging purposes uncomment this line
4951
# RUN apk add --no-cache tree && tree

Source/GraphQLTemplate/Source/GraphQLTemplate/Dockerfile

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,9 @@ WORKDIR /src
4343
COPY "GraphQLTemplate.sln" "."
4444
COPY "Source/GraphQLTemplate/*.csproj" "Source/GraphQLTemplate/"
4545
COPY "Tests/GraphQLTemplate.IntegrationTest/*.csproj" "Tests/GraphQLTemplate.IntegrationTest/"
46-
RUN dotnet restore
46+
# Run the restore and cache the packages on the host for faster subsequent builds.
47+
RUN --mount=type=cache,id=nuget,target=/root/.nuget/packages /
48+
dotnet restore
4749
COPY . .
4850
# To view the files that have been copied into the container file system for debugging purposes uncomment this line
4951
# RUN apk add --no-cache tree && tree

Source/OrleansTemplate/Source/OrleansTemplate.Server/Dockerfile

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,9 @@ COPY "Source/OrleansTemplate.Client/*.csproj" "Source/OrleansTemplate.Client/"
4242
COPY "Source/OrleansTemplate.Grains/*.csproj" "Source/OrleansTemplate.Grains/"
4343
COPY "Source/OrleansTemplate.Server/*.csproj" "Source/OrleansTemplate.Server/"
4444
COPY "Tests/OrleansTemplate.Server.IntegrationTest/*.csproj" "Tests/OrleansTemplate.Server.IntegrationTest/"
45-
RUN dotnet restore
45+
# Run the restore and cache the packages on the host for faster subsequent builds.
46+
RUN --mount=type=cache,id=nuget,target=/root/.nuget/packages /
47+
dotnet restore
4648
COPY . .
4749
# To view the files that have been copied into the container file system for debugging purposes uncomment this line
4850
# RUN apk add --no-cache tree && tree

0 commit comments

Comments
 (0)