fix: Change BackOffice Dockerfile to nginx runtime for Blazor WASM
All checks were successful
Build and Deploy / build (push) Successful in 2m26s
All checks were successful
Build and Deploy / build (push) Successful in 2m26s
- Changed from aspnet to nginx:alpine - Copy wwwroot output instead of BackOffice.dll - Configure nginx SPA routing (try_files for client-side routing) - Remove ENTRYPOINT dotnet command
This commit is contained in:
@@ -1,17 +1,35 @@
|
|||||||
FROM mcr.microsoft.com/dotnet/sdk:9.0 AS build
|
FROM mcr.microsoft.com/dotnet/sdk:9.0 AS build
|
||||||
WORKDIR /src
|
WORKDIR /src
|
||||||
|
|
||||||
|
# Copy NuGet config and project file
|
||||||
COPY ["BackOffice/NuGet.config", "NuGet.config"]
|
COPY ["BackOffice/NuGet.config", "NuGet.config"]
|
||||||
COPY ["BackOffice/BackOffice.csproj", "BackOffice/"]
|
COPY ["BackOffice/BackOffice.csproj", "BackOffice/"]
|
||||||
|
|
||||||
|
# Restore dependencies
|
||||||
RUN dotnet restore "BackOffice/BackOffice.csproj" --configfile NuGet.config
|
RUN dotnet restore "BackOffice/BackOffice.csproj" --configfile NuGet.config
|
||||||
|
|
||||||
|
# Copy all source code
|
||||||
COPY . .
|
COPY . .
|
||||||
|
|
||||||
|
# Build and publish
|
||||||
WORKDIR "/src/BackOffice"
|
WORKDIR "/src/BackOffice"
|
||||||
RUN dotnet publish "./BackOffice.csproj" -c Release -o /app/publish
|
RUN dotnet publish "BackOffice.csproj" -c Release -o /app/publish
|
||||||
|
|
||||||
|
# Runtime stage - nginx for Blazor WebAssembly
|
||||||
|
FROM nginx:alpine AS final
|
||||||
|
WORKDIR /usr/share/nginx/html
|
||||||
|
|
||||||
FROM mcr.microsoft.com/dotnet/aspnet:9.0 AS runtime
|
# Copy published wwwroot (Blazor WASM output)
|
||||||
WORKDIR /app
|
COPY --from=build /app/publish/wwwroot .
|
||||||
COPY --from=build /app/publish .
|
|
||||||
ENV ASPNETCORE_URLS=http://+:8080
|
|
||||||
EXPOSE 8080
|
|
||||||
ENTRYPOINT ["dotnet", "BackOffice.dll"]
|
|
||||||
|
|
||||||
|
# Configure nginx for SPA routing
|
||||||
|
RUN echo 'server { \
|
||||||
|
listen 80; \
|
||||||
|
server_name _; \
|
||||||
|
location / { \
|
||||||
|
root /usr/share/nginx/html; \
|
||||||
|
try_files $uri $uri/ /index.html; \
|
||||||
|
} \
|
||||||
|
}' > /etc/nginx/conf.d/default.conf
|
||||||
|
|
||||||
|
EXPOSE 80
|
||||||
|
|||||||
Reference in New Issue
Block a user