9 months ago
There are articles on deploying a .net application to railway but those I have seen only apply to server side rendered apps like MVC, razor pages, or a web api. How would I go about deploying a blazor web assembly app?
3 Replies
9 months ago
I'm using a Dockerfile with .NET 6
# Base image for building the application
FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build-env
# Copy your source code
WORKDIR /app
COPY . .
# Set the working directory
WORKDIR /app/src/BlazorApp
# Publish your application
RUN dotnet publish "BlazorApp.csproj" -c Release -o /app/publish
# Base image for running the application
FROM mcr.microsoft.com/dotnet/aspnet:6.0
WORKDIR /app
# Copy the published output from the build stage
COPY --from=build-env /app/publish .
# Expose your application's port
EXPOSE 80
# Start the application
ENTRYPOINT ["dotnet", "BlazorApp.dll"]
9 months ago
hey thanks for this. Will this work if my github project has the structure:
Client
blazor wasm project
Server
web api
dockerfile
Shared
classlib
Everything including the dockerfile was in a plain .net web api for this to work but i dont know if this will work for hosted .net blazor wasm project given the complex structure.
7 months ago
Hello friend, i can do with this dockerfile, but, you should change the path of .csproj files:
FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build
WORKDIR /app
COPY ["App3/App3.csproj", "App3/"]
RUN dotnet restore "App3/App3.csproj"
COPY . ./
RUN dotnet publish "App3/App3.csproj" -c Release -o /out
FROM nginx:alpine AS final
COPY --from=build /out/wwwroot /usr/share/nginx/html
I also set a variable PORT=80 in my railway service for bind the app port with railway. Work's to me