fix building frontend
This commit is contained in:
17
Dockerfile
17
Dockerfile
@@ -1,14 +1,19 @@
|
||||
# Stage 1: Build frontend
|
||||
FROM node:20-alpine AS frontend-build
|
||||
WORKDIR /app
|
||||
COPY ./src/GreenHome.Web/package*.json ./
|
||||
RUN npm ci --ignore-scripts || npm install
|
||||
COPY ./src/GreenHome.Web/ .
|
||||
RUN npm run build
|
||||
|
||||
# Stage 2: Build backend
|
||||
FROM mcr.microsoft.com/dotnet/sdk:9.0 AS build
|
||||
WORKDIR /src
|
||||
|
||||
# Install Node.js and build tools for native modules
|
||||
RUN apt-get update && apt-get install -y nodejs npm python3 make g++ && rm -rf /var/lib/apt/lists/*
|
||||
|
||||
COPY ./src/ .
|
||||
|
||||
# Use npm ci for clean install based on package-lock.json
|
||||
RUN cd ./GreenHome.Web && \
|
||||
npm ci
|
||||
# Copy built frontend from previous stage
|
||||
COPY --from=frontend-build /app/dist /src/GreenHome.Api/wwwroot/
|
||||
|
||||
RUN dotnet restore --verbosity detailed
|
||||
RUN dotnet publish -c Release -o /app
|
||||
|
||||
@@ -28,12 +28,4 @@
|
||||
<ProjectReference Include="..\GreenHome.AI.DeepSeek\GreenHome.AI.DeepSeek.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<Target Name="BuildFrontend" BeforeTargets="Build" Condition="'$(Configuration)' == 'Release' And Exists('..\GreenHome.Web\package.json')">
|
||||
<Exec Command="npm run build" WorkingDirectory="..\GreenHome.Web" />
|
||||
<ItemGroup>
|
||||
<FrontendDist Include="..\GreenHome.Web\dist\**\*" />
|
||||
</ItemGroup>
|
||||
<Copy SourceFiles="@(FrontendDist)" DestinationFiles="@(FrontendDist->'wwwroot\%(RecursiveDir)%(Filename)%(Extension)')" SkipUnchangedFiles="true" />
|
||||
</Target>
|
||||
|
||||
</Project>
|
||||
|
||||
Reference in New Issue
Block a user