FROM mcr.microsoft.com/dotnet/sdk:10.0-alpine AS build
WORKDIR /src

COPY ["FrontAdmin/FrontAdmin.csproj", "FrontAdmin/"]
COPY ["Common/Common.csproj", "Common/"]
RUN dotnet restore -s https://api.nuget.org/v3/index.json "FrontAdmin/FrontAdmin.csproj"

COPY . .
WORKDIR "/src/FrontAdmin"

RUN find . -type d -name "bin" -o -name "obj" | xargs rm -rf

RUN dotnet publish "FrontAdmin.csproj" -c Release -o /app/publish

FROM nginx:alpine AS final
WORKDIR /usr/share/nginx/html

RUN rm -rf ./*

COPY --from=build /app/publish/wwwroot .

COPY FrontAdmin/nginx.conf /etc/nginx/nginx.conf

EXPOSE 80

CMD ["nginx", "-g", "daemon off;"]