Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@MoimHossain
Created June 22, 2019 16:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MoimHossain/482332913238db5b1577657de4cd4c10 to your computer and use it in GitHub Desktop.
Save MoimHossain/482332913238db5b1577657de4cd4c10 to your computer and use it in GitHub Desktop.
A docker file that builds Blazor app and deploys in a Blob container
FROM mcr.microsoft.com/dotnet/core/aspnet:3.0-buster-slim AS base
WORKDIR /app
# Build the app
FROM mcr.microsoft.com/dotnet/core/sdk:3.0-buster AS build
WORKDIR /src
COPY . .
WORKDIR "/src/BlazorApp"
RUN dotnet restore "BlazorApp.csproj"
RUN dotnet build "BlazorApp.csproj" -c Release -o /app
# Run the unit tests
RUN dotnet restore "BlazorAppTest.csproj"
RUN dotnet build "BlazorAppTest.csproj"
RUN dotnet test "BlazorAppTest.csproj"
# Publish the app
FROM build AS publish
RUN dotnet publish "BlazorApp.csproj" -c Release -o /app
FROM microsoft/azure-cli AS final
ARG AppID
ARG AppSecret
ARG TenantID
ARG StorageAccountName
WORKDIR /app
COPY --from=publish /app .
WORKDIR "/app/BlazorApp/dist"
RUN az login --service-principal --username $AppID --password $AppSecret --tenant $TenantID
RUN az storage blob delete-batch --account-name $StorageAccountName --source "\$web"
RUN az storage blob upload-batch --account-name $StorageAccountName -s . -d "\$web"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment