I have a project with two parts: a server using ASP.NET Core Web API and a client using Blazor WebAssembly (PWA). I’m trying to containerize both parts using Docker. While the build and run processes complete without any errors, I’m encountering an issue on the client side. The browser displays the following message: This page isn’t working right now. localhost didn’t send any data
.
Both the projects are in their initial state.
Here is my project structure:
I have the following
DockerMe
├───docker-compose.yaml
│
├───client
│ └───Dockerfile
└───server
└───Dockerfile
docker-compose.yaml
version: '3.4'
services:
server:
image: dockerme-server
build:
context: .
dockerfile: server/Dockerfile
ports:
- "7000:8080"
environment:
- ASPNETCORE_ENVIRONMENT=Development
client:
image: dockerme-client
build:
context: .
dockerfile: client/Dockerfile
ports:
- "7001:8080"
environment:
- ASPNETCORE_ENVIRONMENT=Development
client
# Build stage
FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build
WORKDIR /src
COPY ["client/client.csproj", "client/"]
RUN dotnet restore "client/client.csproj"
COPY . .
WORKDIR "/src/client"
RUN dotnet publish "client.csproj" -c Release -o /app/publish
# Final stage
FROM nginx:alpine
WORKDIR /usr/share/nginx/html
COPY --from=build /app/publish/wwwroot .
EXPOSE 8080
ENTRYPOINT ["nginx", "-g", "daemon off;"]
server
FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS base
WORKDIR /app
EXPOSE 8080
EXPOSE 8081
FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build
ARG BUILD_CONFIGURATION=Release
WORKDIR /src
COPY ["server/server.csproj", "server/"]
RUN dotnet restore "./server/server.csproj"
COPY . .
WORKDIR "/src/server"
RUN dotnet build "./server.csproj" -c %BUILD_CONFIGURATION% -o /app/build
FROM build AS publish
ARG BUILD_CONFIGURATION=Release
RUN dotnet publish "./server.csproj" -c %BUILD_CONFIGURATION% -o /app/publish /p:UseAppHost=false
FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "server.dll"]