fix(docker): update Dockerfile
This commit is contained in:
@@ -1,17 +1,26 @@
|
|||||||
# مرحله build
|
# 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
|
FROM mcr.microsoft.com/dotnet/sdk:9.0 AS build
|
||||||
WORKDIR /src
|
WORKDIR /src
|
||||||
COPY . .
|
|
||||||
# Publish ONLY the API project: the build context contains the whole
|
COPY ./src/ .
|
||||||
# solution, and publishing the sln would dump every project's
|
|
||||||
# appsettings.json into /app (last one wins) — e.g. DataCopy's
|
# Copy built frontend from previous stage
|
||||||
# overwrote the API's and broke IppanelSms startup.
|
COPY --from=frontend-build /app/dist /src/GreenHome.Api/wwwroot/
|
||||||
|
|
||||||
RUN dotnet restore GreenHome.Api/GreenHome.Api.csproj
|
RUN dotnet restore GreenHome.Api/GreenHome.Api.csproj
|
||||||
RUN dotnet publish GreenHome.Api/GreenHome.Api.csproj -c Release -o /app
|
RUN dotnet publish GreenHome.Api/GreenHome.Api.csproj -c Release -o /app
|
||||||
|
|
||||||
# مرحله runtime
|
|
||||||
FROM mcr.microsoft.com/dotnet/aspnet:9.0 AS runtime
|
FROM mcr.microsoft.com/dotnet/aspnet:9.0 AS runtime
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
COPY --from=build /app .
|
COPY --from=build /app .
|
||||||
EXPOSE 8080
|
RUN mkdir -p /app/My_StaticFiles
|
||||||
|
RUN mkdir -p /app/files
|
||||||
ENTRYPOINT ["dotnet", "GreenHome.Api.dll"]
|
ENTRYPOINT ["dotnet", "GreenHome.Api.dll"]
|
||||||
Reference in New Issue
Block a user