I am trying to deploy a Blazor Server side application to the Google Cloud App Engine.
I have the base project that build when you select the Blazor Server App with docker enable for Linux, and put the following app.yaml in the project folder:
runtime: custom
env: flex
I then opened my gcloud console to this directory and did an app deploy, however this failed on step 7 in the boilerplate dockerfile. I noticed that the dockerfile had all of the project relevant files in a nested directory of the project name, so I removed the first folder from each of the docker commands:
#See https://aka.ms/containerfastmode to understand how Visual Studio uses this Dockerfile to build your images for faster debugging.
FROM mcr.microsoft.com/dotnet/aspnet:6.0 AS base
WORKDIR /app
EXPOSE 80
EXPOSE 443
FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build
WORKDIR /src
COPY ["CallAssistant.csproj", "."]
RUN dotnet restore "CallAssistant.csproj"
COPY . .
RUN dotnet build "CallAssistant.csproj" -c Release -o /app/build
FROM build AS publish
RUN dotnet publish "CallAssistant.csproj" -c Release -o /app/publish
FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "CallAssistant.dll"]
After this, I ran another gcloud app deploy and the deployment process completed, and on the google cloud console I was able to see the service running. However, when I tried to access the server I got a 502 Bad Gateway error on the home page, and subsequently in each of the nav pages nested in the app.
Does anyone know how to deploy a Blazor app to google app engine utilizing the docker image?
I figured this out. (It throws some weird errors occasionally though on the initial blazor project template)
If you copy the publish folder in the docker /app/ after publishing the project, then deploy using the app.yaml and dockerfile form the project directory, you can gcloud app deploy
and it will work.
Here's my docker file:
#See https://aka.ms/containerfastmode to understand how Visual Studio uses this Dockerfile to build your images for faster debugging.
FROM mcr.microsoft.com/dotnet/aspnet:6.0 AS base
EXPOSE 8080
#------------------------------------------------------------------------------
# Copy publishing artifacts.
#------------------------------------------------------------------------------
WORKDIR /app
COPY bin/Release/net6.0/publish/ /app/
ENV ASPNETCORE_URLS=http://0.0.0.0:8080
#------------------------------------------------------------------------------
# Run application in Kestrel.
#------------------------------------------------------------------------------
ENTRYPOINT ["dotnet", "CallAssistant.dll"]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With