Files
BackOffice/src/BackOffice/Dockerfile
masoud 82068bf8f8
All checks were successful
Build and Deploy / build (push) Successful in 2m22s
fix: Remove default nginx files before copying Blazor WASM output
- nginx:alpine has default index.html that prevents Blazor from loading
- Added RUN rm -rf /usr/share/nginx/html/* before COPY
2025-12-07 23:30:31 +00:00

39 lines
954 B
Docker

FROM mcr.microsoft.com/dotnet/sdk:9.0 AS build
WORKDIR /src
# Copy NuGet config and project file
COPY ["BackOffice/NuGet.config", "NuGet.config"]
COPY ["BackOffice/BackOffice.csproj", "BackOffice/"]
# Restore dependencies
RUN dotnet restore "BackOffice/BackOffice.csproj" --configfile NuGet.config
# Copy all source code
COPY . .
# Build and publish
WORKDIR "/src/BackOffice"
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
# Remove default nginx files
RUN rm -rf /usr/share/nginx/html/*
# Copy published wwwroot (Blazor WASM output)
COPY --from=build /app/publish/wwwroot .
# 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