♻️ Changed a way of building SPA
This commit is contained in:
		@@ -1,33 +0,0 @@
 | 
			
		||||
# Web
 | 
			
		||||
 | 
			
		||||
This template should help get you started developing with Vue 3 in Vite.
 | 
			
		||||
 | 
			
		||||
## Recommended IDE Setup
 | 
			
		||||
 | 
			
		||||
[VSCode](https://code.visualstudio.com/) + [Volar](https://marketplace.visualstudio.com/items?itemName=Vue.volar) (and disable Vetur).
 | 
			
		||||
 | 
			
		||||
## Type Support for `.vue` Imports in TS
 | 
			
		||||
 | 
			
		||||
TypeScript cannot handle type information for `.vue` imports by default, so we replace the `tsc` CLI with `vue-tsc` for type checking. In editors, we need [Volar](https://marketplace.visualstudio.com/items?itemName=Vue.volar) to make the TypeScript language service aware of `.vue` types.
 | 
			
		||||
 | 
			
		||||
## Customize configuration
 | 
			
		||||
 | 
			
		||||
See [Vite Configuration Reference](https://vite.dev/config/).
 | 
			
		||||
 | 
			
		||||
## Project Setup
 | 
			
		||||
 | 
			
		||||
```sh
 | 
			
		||||
bun install
 | 
			
		||||
```
 | 
			
		||||
 | 
			
		||||
### Compile and Hot-Reload for Development
 | 
			
		||||
 | 
			
		||||
```sh
 | 
			
		||||
bun dev
 | 
			
		||||
```
 | 
			
		||||
 | 
			
		||||
### Type-Check, Compile and Minify for Production
 | 
			
		||||
 | 
			
		||||
```sh
 | 
			
		||||
bun run build
 | 
			
		||||
```
 | 
			
		||||
							
								
								
									
										4523
									
								
								DysonNetwork.Pass/Client/package-lock.json
									
									
									
										generated
									
									
									
								
							
							
						
						
									
										4523
									
								
								DysonNetwork.Pass/Client/package-lock.json
									
									
									
										generated
									
									
									
								
							
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							@@ -1,34 +1,55 @@
 | 
			
		||||
# Stage 1: Base runtime image
 | 
			
		||||
FROM mcr.microsoft.com/dotnet/aspnet:9.0 AS base
 | 
			
		||||
USER $APP_UID
 | 
			
		||||
WORKDIR /app
 | 
			
		||||
EXPOSE 8080
 | 
			
		||||
EXPOSE 8081
 | 
			
		||||
 | 
			
		||||
FROM mcr.microsoft.com/dotnet/sdk:9.0 AS build
 | 
			
		||||
ARG BUILD_CONFIGURATION=Release
 | 
			
		||||
# Stage 2: Build SPA
 | 
			
		||||
FROM node:22-alpine AS spa-builder
 | 
			
		||||
WORKDIR /src
 | 
			
		||||
 | 
			
		||||
# Install Node.js 22 and npm
 | 
			
		||||
RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
 | 
			
		||||
    && apt-get -y install --no-install-recommends curl ca-certificates \
 | 
			
		||||
    && curl -fsSL https://deb.nodesource.com/setup_22.x | bash - \
 | 
			
		||||
    && apt-get -y install --no-install-recommends nodejs \
 | 
			
		||||
    && npm install -g npm \
 | 
			
		||||
    && rm -rf /var/lib/apt/lists/*
 | 
			
		||||
# Copy package files for SPA
 | 
			
		||||
COPY ["DysonNetwork.Pass/Client/package.json", "DysonNetwork.Pass/Client/package-lock.json*", "./Client/"]
 | 
			
		||||
 | 
			
		||||
# Restore NuGet packages
 | 
			
		||||
# Install SPA dependencies
 | 
			
		||||
WORKDIR /src/Client
 | 
			
		||||
RUN npm ci
 | 
			
		||||
 | 
			
		||||
# Copy SPA source
 | 
			
		||||
COPY ["DysonNetwork.Pass/Client/", "./"]
 | 
			
		||||
 | 
			
		||||
# Build SPA
 | 
			
		||||
RUN npm run build
 | 
			
		||||
 | 
			
		||||
# Stage 3: Build .NET application
 | 
			
		||||
FROM mcr.microsoft.com/dotnet/sdk:9.0 AS build
 | 
			
		||||
WORKDIR /src
 | 
			
		||||
 | 
			
		||||
# Copy .csproj and restore as distinct layers
 | 
			
		||||
COPY ["DysonNetwork.Pass/DysonNetwork.Pass.csproj", "DysonNetwork.Pass/"]
 | 
			
		||||
RUN dotnet restore "DysonNetwork.Pass/DysonNetwork.Pass.csproj"
 | 
			
		||||
 | 
			
		||||
# Copy everything and build
 | 
			
		||||
# Copy everything else and build
 | 
			
		||||
COPY . .
 | 
			
		||||
 | 
			
		||||
# Copy built SPA to wwwroot
 | 
			
		||||
COPY --from=spa-builder /src/Client/dist /src/DysonNetwork.Pass/wwwroot/dist
 | 
			
		||||
 | 
			
		||||
# Build the application
 | 
			
		||||
WORKDIR "/src/DysonNetwork.Pass"
 | 
			
		||||
RUN dotnet build "./DysonNetwork.Pass.csproj" -c $BUILD_CONFIGURATION -o /app/build
 | 
			
		||||
RUN dotnet build "DysonNetwork.Pass.csproj" -c Release -o /app/build \
 | 
			
		||||
    -p:TypeScriptCompileBlocked=true \
 | 
			
		||||
    -p:UseRazorBuildServer=false
 | 
			
		||||
 | 
			
		||||
# Stage 4: Publish
 | 
			
		||||
FROM build AS publish
 | 
			
		||||
ARG BUILD_CONFIGURATION=Release
 | 
			
		||||
RUN dotnet publish "./DysonNetwork.Pass.csproj" -c $BUILD_CONFIGURATION -o /app/publish /p:UseAppHost=false
 | 
			
		||||
RUN dotnet publish "DysonNetwork.Pass.csproj" -c Release -o /app/publish \
 | 
			
		||||
    -p:TypeScriptCompileBlocked=true \
 | 
			
		||||
    -p:UseRazorBuildServer=false \
 | 
			
		||||
    /p:UseAppHost=false
 | 
			
		||||
 | 
			
		||||
# Final stage: Runtime
 | 
			
		||||
FROM base AS final
 | 
			
		||||
WORKDIR /app
 | 
			
		||||
COPY --from=publish /app/publish .
 | 
			
		||||
 
 | 
			
		||||
@@ -120,28 +120,6 @@
 | 
			
		||||
        <AdditionalFiles Include="Resources\Localization\SharedResource.zh-hans.resx" />
 | 
			
		||||
    </ItemGroup>
 | 
			
		||||
 | 
			
		||||
    <Target Name="BuildSpa" BeforeTargets="Build">
 | 
			
		||||
        <Message Importance="high" Text="Building SPA with Vite..." />
 | 
			
		||||
        <Exec WorkingDirectory="Client" Command="npm install" />
 | 
			
		||||
        <Exec WorkingDirectory="Client" Command="npm run build" />
 | 
			
		||||
    </Target>
 | 
			
		||||
 | 
			
		||||
    <Target Name="CopySpa" AfterTargets="Build">
 | 
			
		||||
        <Message Importance="high" Text="Copying SPA to wwwroot..." />
 | 
			
		||||
        <RemoveDir Directories="wwwroot\dist" />
 | 
			
		||||
        <MakeDir Directories="wwwroot\dist" />
 | 
			
		||||
 | 
			
		||||
        <ItemGroup>
 | 
			
		||||
            <_SpaDistFiles Include="Client\dist\**\*" />
 | 
			
		||||
        </ItemGroup>
 | 
			
		||||
        
 | 
			
		||||
        <Copy SourceFiles="@(SpaDistFiles)" DestinationFolder="wwwroot\dist\%(RecursiveDir)" SkipUnchangedFiles="true" />
 | 
			
		||||
    </Target>
 | 
			
		||||
 | 
			
		||||
    <ItemGroup>
 | 
			
		||||
        <SpaDistFiles Include="Client\dist\**\*" />
 | 
			
		||||
    </ItemGroup>
 | 
			
		||||
 | 
			
		||||
    <ItemGroup>
 | 
			
		||||
      <_ContentIncludedByDefault Remove="Pages\Shared\_Layout.cshtml" />
 | 
			
		||||
      <_ContentIncludedByDefault Remove="Pages\Checkpoint\CheckpointPage.cshtml" />
 | 
			
		||||
 
 | 
			
		||||
@@ -12,30 +12,38 @@ FROM mcr.microsoft.com/dotnet/sdk:9.0 AS build
 | 
			
		||||
ARG BUILD_CONFIGURATION=Release
 | 
			
		||||
WORKDIR /src
 | 
			
		||||
 | 
			
		||||
# Install Node.js 22 and npm
 | 
			
		||||
RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
 | 
			
		||||
    && apt-get -y install --no-install-recommends curl ca-certificates \
 | 
			
		||||
    && curl -fsSL https://deb.nodesource.com/setup_22.x | bash - \
 | 
			
		||||
    && apt-get -y install --no-install-recommends nodejs \
 | 
			
		||||
    && npm install -g npm \
 | 
			
		||||
    && rm -rf /var/lib/apt/lists/*
 | 
			
		||||
# Copy only the necessary project files first for better layer caching
 | 
			
		||||
COPY ["DysonNetwork.Sphere/DysonNetwork.Sphere.csproj", "DysonNetwork.Sphere/"]
 | 
			
		||||
COPY ["DysonNetwork.Shared/DysonNetwork.Shared.csproj", "DysonNetwork.Shared/"]
 | 
			
		||||
 | 
			
		||||
# Copy everything and build
 | 
			
		||||
# Restore NuGet packages
 | 
			
		||||
RUN dotnet restore "DysonNetwork.Sphere/DysonNetwork.Sphere.csproj"
 | 
			
		||||
 | 
			
		||||
# Copy the rest of the source code
 | 
			
		||||
COPY . .
 | 
			
		||||
WORKDIR /src/DysonNetwork.Sphere
 | 
			
		||||
RUN dotnet restore
 | 
			
		||||
RUN dotnet build -c $BUILD_CONFIGURATION -o /app/build
 | 
			
		||||
 | 
			
		||||
# Build the project (this will skip frontend build as it's not needed)
 | 
			
		||||
WORKDIR "/src/DysonNetwork.Sphere"
 | 
			
		||||
RUN dotnet build -c $BUILD_CONFIGURATION -o /app/build \
 | 
			
		||||
    --no-restore \
 | 
			
		||||
    -p:TypeScriptCompileBlocked=true \
 | 
			
		||||
    -p:UseRazorBuildServer=false
 | 
			
		||||
 | 
			
		||||
# -------- Publish stage --------
 | 
			
		||||
FROM build AS publish
 | 
			
		||||
ARG BUILD_CONFIGURATION=Release
 | 
			
		||||
RUN mkdir -p /app/publish/zh-Hans
 | 
			
		||||
 | 
			
		||||
# Trim, ReadyToRun, single-file (optional), no self-contained to keep image small
 | 
			
		||||
RUN dotnet publish -c $BUILD_CONFIGURATION -o /app/publish \
 | 
			
		||||
  -p:PublishReadyToRun=true \
 | 
			
		||||
  -p:TieredPGO=true \
 | 
			
		||||
  -p:SuppressTrimAnalysisWarnings=true
 | 
			
		||||
# Publish the application without frontend assets
 | 
			
		||||
RUN dotnet publish "DysonNetwork.Sphere.csproj" \
 | 
			
		||||
    -c $BUILD_CONFIGURATION \
 | 
			
		||||
    -o /app/publish \
 | 
			
		||||
    --no-restore \
 | 
			
		||||
    --no-build \
 | 
			
		||||
    -p:PublishReadyToRun=true \
 | 
			
		||||
    -p:TieredPGO=true \
 | 
			
		||||
    -p:SuppressTrimAnalysisWarnings=true \
 | 
			
		||||
    -p:TypeScriptCompileBlocked=true \
 | 
			
		||||
    -p:UseRazorBuildServer=false
 | 
			
		||||
 | 
			
		||||
# -------- Final image --------
 | 
			
		||||
FROM base AS final
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user