♻️ 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
|
FROM mcr.microsoft.com/dotnet/aspnet:9.0 AS base
|
||||||
USER $APP_UID
|
USER $APP_UID
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
EXPOSE 8080
|
EXPOSE 8080
|
||||||
EXPOSE 8081
|
EXPOSE 8081
|
||||||
|
|
||||||
FROM mcr.microsoft.com/dotnet/sdk:9.0 AS build
|
# Stage 2: Build SPA
|
||||||
ARG BUILD_CONFIGURATION=Release
|
FROM node:22-alpine AS spa-builder
|
||||||
WORKDIR /src
|
WORKDIR /src
|
||||||
|
|
||||||
# Install Node.js 22 and npm
|
# Copy package files for SPA
|
||||||
RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
|
COPY ["DysonNetwork.Pass/Client/package.json", "DysonNetwork.Pass/Client/package-lock.json*", "./Client/"]
|
||||||
&& 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/*
|
|
||||||
|
|
||||||
# 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/"]
|
COPY ["DysonNetwork.Pass/DysonNetwork.Pass.csproj", "DysonNetwork.Pass/"]
|
||||||
RUN dotnet restore "DysonNetwork.Pass/DysonNetwork.Pass.csproj"
|
RUN dotnet restore "DysonNetwork.Pass/DysonNetwork.Pass.csproj"
|
||||||
|
|
||||||
# Copy everything and build
|
# Copy everything else and build
|
||||||
COPY . .
|
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"
|
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
|
FROM build AS publish
|
||||||
ARG BUILD_CONFIGURATION=Release
|
RUN dotnet publish "DysonNetwork.Pass.csproj" -c Release -o /app/publish \
|
||||||
RUN dotnet publish "./DysonNetwork.Pass.csproj" -c $BUILD_CONFIGURATION -o /app/publish /p:UseAppHost=false
|
-p:TypeScriptCompileBlocked=true \
|
||||||
|
-p:UseRazorBuildServer=false \
|
||||||
|
/p:UseAppHost=false
|
||||||
|
|
||||||
|
# Final stage: Runtime
|
||||||
FROM base AS final
|
FROM base AS final
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
COPY --from=publish /app/publish .
|
COPY --from=publish /app/publish .
|
||||||
|
@@ -120,28 +120,6 @@
|
|||||||
<AdditionalFiles Include="Resources\Localization\SharedResource.zh-hans.resx" />
|
<AdditionalFiles Include="Resources\Localization\SharedResource.zh-hans.resx" />
|
||||||
</ItemGroup>
|
</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>
|
<ItemGroup>
|
||||||
<_ContentIncludedByDefault Remove="Pages\Shared\_Layout.cshtml" />
|
<_ContentIncludedByDefault Remove="Pages\Shared\_Layout.cshtml" />
|
||||||
<_ContentIncludedByDefault Remove="Pages\Checkpoint\CheckpointPage.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
|
ARG BUILD_CONFIGURATION=Release
|
||||||
WORKDIR /src
|
WORKDIR /src
|
||||||
|
|
||||||
# Install Node.js 22 and npm
|
# Copy only the necessary project files first for better layer caching
|
||||||
RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
|
COPY ["DysonNetwork.Sphere/DysonNetwork.Sphere.csproj", "DysonNetwork.Sphere/"]
|
||||||
&& apt-get -y install --no-install-recommends curl ca-certificates \
|
COPY ["DysonNetwork.Shared/DysonNetwork.Shared.csproj", "DysonNetwork.Shared/"]
|
||||||
&& 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 everything and build
|
# Restore NuGet packages
|
||||||
|
RUN dotnet restore "DysonNetwork.Sphere/DysonNetwork.Sphere.csproj"
|
||||||
|
|
||||||
|
# Copy the rest of the source code
|
||||||
COPY . .
|
COPY . .
|
||||||
WORKDIR /src/DysonNetwork.Sphere
|
|
||||||
RUN dotnet restore
|
# Build the project (this will skip frontend build as it's not needed)
|
||||||
RUN dotnet build -c $BUILD_CONFIGURATION -o /app/build
|
WORKDIR "/src/DysonNetwork.Sphere"
|
||||||
|
RUN dotnet build -c $BUILD_CONFIGURATION -o /app/build \
|
||||||
|
--no-restore \
|
||||||
|
-p:TypeScriptCompileBlocked=true \
|
||||||
|
-p:UseRazorBuildServer=false
|
||||||
|
|
||||||
# -------- Publish stage --------
|
# -------- Publish stage --------
|
||||||
FROM build AS publish
|
FROM build AS publish
|
||||||
ARG BUILD_CONFIGURATION=Release
|
ARG BUILD_CONFIGURATION=Release
|
||||||
RUN mkdir -p /app/publish/zh-Hans
|
|
||||||
|
|
||||||
# Trim, ReadyToRun, single-file (optional), no self-contained to keep image small
|
# Publish the application without frontend assets
|
||||||
RUN dotnet publish -c $BUILD_CONFIGURATION -o /app/publish \
|
RUN dotnet publish "DysonNetwork.Sphere.csproj" \
|
||||||
|
-c $BUILD_CONFIGURATION \
|
||||||
|
-o /app/publish \
|
||||||
|
--no-restore \
|
||||||
|
--no-build \
|
||||||
-p:PublishReadyToRun=true \
|
-p:PublishReadyToRun=true \
|
||||||
-p:TieredPGO=true \
|
-p:TieredPGO=true \
|
||||||
-p:SuppressTrimAnalysisWarnings=true
|
-p:SuppressTrimAnalysisWarnings=true \
|
||||||
|
-p:TypeScriptCompileBlocked=true \
|
||||||
|
-p:UseRazorBuildServer=false
|
||||||
|
|
||||||
# -------- Final image --------
|
# -------- Final image --------
|
||||||
FROM base AS final
|
FROM base AS final
|
||||||
|
Reference in New Issue
Block a user