fix: Correct Dockerfile for Blazor WASM with nginx runtime
Some checks failed
Build and Deploy / build (push) Has been cancelled
Some checks failed
Build and Deploy / build (push) Has been cancelled
- Changed from aspnet to nginx:alpine - Copy wwwroot instead of BackOffice.dll - Configure nginx SPA routing - Remove incorrect ENTRYPOINT
This commit is contained in:
47
Dockerfile
47
Dockerfile
@@ -1,15 +1,38 @@
|
||||
FROM mcr.microsoft.com/dotnet/sdk:9.0 AS build
|
||||
WORKDIR /src
|
||||
COPY src/*.sln ./ 2>/dev/null || true
|
||||
COPY src/*/*.csproj ./
|
||||
RUN for file in *.csproj; do mkdir -p "${file%.*}" && mv "$file" "${file%.*}/"; done 2>/dev/null || true
|
||||
RUN dotnet restore "BackOffice/BackOffice.csproj" || dotnet restore
|
||||
COPY src/ ./
|
||||
RUN dotnet publish "BackOffice/BackOffice.csproj" -c Release -o /app/publish
|
||||
|
||||
FROM mcr.microsoft.com/dotnet/aspnet:9.0 AS runtime
|
||||
WORKDIR /app
|
||||
COPY --from=build /app/publish .
|
||||
ENV ASPNETCORE_URLS=http://+:8080
|
||||
EXPOSE 8080
|
||||
ENTRYPOINT ["dotnet", "BackOffice.dll"]
|
||||
# Copy project file
|
||||
COPY src/BackOffice/BackOffice.csproj ./BackOffice/
|
||||
COPY src/BackOffice/NuGet.config ./BackOffice/
|
||||
|
||||
# Restore dependencies
|
||||
RUN dotnet restore "BackOffice/BackOffice.csproj" --configfile BackOffice/NuGet.config
|
||||
|
||||
# Copy source code
|
||||
COPY src/BackOffice/ ./BackOffice/
|
||||
|
||||
# Build and publish
|
||||
WORKDIR "/src/BackOffice"
|
||||
RUN dotnet publish "BackOffice.csproj" -c Release -o /app/publish
|
||||
|
||||
# Runtime stage - nginx for Blazor WASM
|
||||
FROM nginx:alpine AS final
|
||||
WORKDIR /usr/share/nginx/html
|
||||
|
||||
# Copy published wwwroot
|
||||
COPY --from=build /app/publish/wwwroot .
|
||||
|
||||
# Configure nginx for SPA routing
|
||||
RUN cat > /etc/nginx/conf.d/default.conf << 'NGINX_CONF'
|
||||
server {
|
||||
listen 80;
|
||||
server_name _;
|
||||
|
||||
location / {
|
||||
root /usr/share/nginx/html;
|
||||
try_files $uri $uri/ /index.html;
|
||||
}
|
||||
}
|
||||
NGINX_CONF
|
||||
|
||||
EXPOSE 80
|
||||
|
||||
Reference in New Issue
Block a user