#FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS base
#WORKDIR /app
#EXPOSE 5002
#ENV ASPNETCORE_URLS=http://*:5002
#
#FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build
#WORKDIR /src
#COPY ["phronCare.UIBlazor.csproj", "."]
#RUN dotnet restore "./phronCare.UIBlazor.csproj"
#COPY . .
#WORKDIR "/src/."
#RUN dotnet build "phronCare.UIBlazor.csproj" -c Release -o /app/build
#
#FROM build AS publish
#RUN dotnet publish "phronCare.UIBlazor.csproj" -c Release -o /app/publish
#
#FROM nginx:alpine AS final
#WORKDIR /usr/share/nginx/html
#COPY --from=publish /app/publish/wwwroot .
#COPY nginx.conf /etc/nginx/nginx.conf
#
# Etapa base para ejecutar la aplicaci�n
FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS base
WORKDIR /app
EXPOSE 5002
ENV ASPNETCORE_URLS=http://*:5002

# Etapa de construcci�n
FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build
WORKDIR /src

# Copiar los archivos .csproj de ambos proyectos al contenedor
COPY ["phronCare.UIBlazor/phronCare.UIBlazor.csproj", "phronCare.UIBlazor/"]
COPY ["Domain/Domain.csproj", "Domain/"]

# Restaurar dependencias
RUN dotnet restore "phronCare.UIBlazor/phronCare.UIBlazor.csproj"

# Copiar todo el c�digo fuente de ambos proyectos
COPY phronCare.UIBlazor phronCare.UIBlazor/
COPY Domain Domain/

# Construir la aplicaci�n
RUN dotnet build "phronCare.UIBlazor/phronCare.UIBlazor.csproj" -c Release -o /app/build

# Etapa de publicaci�n
FROM build AS publish
RUN dotnet publish "phronCare.UIBlazor/phronCare.UIBlazor.csproj" -c Release -o /app/publish

# Usar NGINX como servidor web
FROM nginx:alpine AS final
WORKDIR /usr/share/nginx/html
COPY --from=publish /app/publish/wwwroot .
COPY phronCare.UIBlazor/nginx.conf /etc/nginx/nginx.conf
