You could use for several apps. Docker Compose file YAML will refer to docker-compose.yml for each app:Dockerfile
version: '3.4'
services:
webfrontend:
image: ${DOCKER_REGISTRY-}webfrontend
build:
context: .
dockerfile: WebFrontEnd/Dockerfile
mywebapi:
image: ${DOCKER_REGISTRY-}mywebapi
build:
context: .
dockerfile: MyWebAPI/Dockerfile
Add Docker File with Nginx Reverse Proxy Server
For Blazor Web Assembly we need to add "nginx.conf" in Project root folder
events { }
http {
include mime.types;
types {
application/wasm wasm;
}
server {
listen 80;
# Here, we set the location for Nginx to serve the files looking for index.html
location / {
root .;
try_files $uri $uri/ /index.html =404;
}
}
}
Now in Dockerfile mention it like
FROM mcr.microsoft.com/dotnet/aspnet:6.0 AS base
WORKDIR /app
EXPOSE 80
FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build
WORKDIR /src
COPY ["projectpath/projectname.csproj", "projectpath"]
RUN dotnet restore "projectpath/projectname.csproj"
COPY . .
WORKDIR "/projectpath"
RUN dotnet build "projectname.csproj" -c Release -o /app/build
FROM build AS publish
RUN dotnet publish "projectname.csproj" -c Release -o /app/publish
FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "projectname.dll"]
FROM nginx:alpine AS final
WORKDIR /usr/share/nginx/html
#Copy from Environment(build/publish)
COPY --from=publish app/publish/wwwroot .
Now build and run the project in docker.