Skip to content

Instantly share code, notes, and snippets.

@berkayakcay
Last active July 3, 2020 15:09
Show Gist options
  • Save berkayakcay/3b421444cdf889e9ec3fb748c2e82390 to your computer and use it in GitHub Desktop.
Save berkayakcay/3b421444cdf889e9ec3fb748c2e82390 to your computer and use it in GitHub Desktop.
dotnet uygulaması için build cache optimizasyonu örnek dockerfile #dotnet #DockerFile DockerBuildCache
FROM mcr.microsoft.com/dotnet/core/sdk:3.1.300-buster AS build
WORKDIR /src
# Docker build cache'inden yararlanarak hızlandırıyoruz.
COPY "eShopOnContainers-ServicesAndWebApps.sln" "eShopOnContainers-ServicesAndWebApps.sln"
COPY "Services/Basket/Basket.API/Basket.API.csproj" "Services/Basket/Basket.API/Basket.API.csproj"
COPY "Services/Catalog/Catalog.API/Catalog.API.csproj" "Services/Catalog/Catalog.API/Catalog.API.csproj"
COPY "Services/Identity/Identity.API/Identity.API.csproj" "Services/Identity/Identity.API/Identity.API.csproj"
COPY "Services/Location/Locations.API/Locations.API.csproj" "Services/Location/Locations.API/Locations.API.csproj"
COPY "Services/Marketing/Marketing.API/Marketing.API.csproj" "Services/Marketing/Marketing.API/Marketing.API.csproj"
COPY "Services/Ordering/Ordering.API/Ordering.API.csproj" "Services/Ordering/Ordering.API/Ordering.API.csproj"
COPY "Services/Payment/Payment.API/Payment.API.csproj" "Services/Payment/Payment.API/Payment.API.csproj"
COPY "Web/WebMVC/WebMVC.csproj" "Web/WebMVC/WebMVC.csproj"
# dotnet restore işlemimizi bir aşama olarak çalıştırıyoruz.
RUN dotnet restore "eShopOnContainers-ServicesAndWebApps.sln"
COPY . .
# dotnet build işlemini çalıştırıyoruz --no-restore komutu ile tekrar restore etmesinin önüne geçiyoruz
RUN dotnet build -c Release --no-restore
WORKDIR /src/Web/WebMVC
# uygulamamızı publish ediyoruz.
RUN dotnet publish -c Release -o /app --no-restore --no-build
FROM nesbilgi/debian:aspnet-3.1.4 AS runtime
WORKDIR /app
COPY --from=build /app .
ENTRYPOINT ["dotnet", "WebMVC.dll"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment