#See https://aka.ms/containerfastmode to understand how Visual Studio uses this Dockerfile to build your images for faster debugging.

FROM mcr.microsoft.com/dotnet/aspnet:7.0 AS base
EXPOSE 80
EXPOSE 443
EXPOSE 54088
WORKDIR /app

FROM mcr.microsoft.com/dotnet/sdk:7.0 AS build
WORKDIR /src
COPY ["EVCB_OCPP.WSServer/EVCB_OCPP.WSServer.csproj", "EVCB_OCPP.WSServer/"]
COPY ["SuperWebSocket/SuperWebSocket.csproj", "SuperWebSocket/"]
COPY ["SocketBase/SuperSocket.SocketBase.csproj", "SocketBase/"]
COPY ["SocketCommon/SuperSocket.Common.csproj", "SocketCommon/"]
COPY ["SocketEngine/SuperSocket.SocketEngine.csproj", "SocketEngine/"]
RUN dotnet restore "EVCB_OCPP.WSServer/EVCB_OCPP.WSServer.csproj"
COPY . .
WORKDIR "/src/EVCB_OCPP.WSServer"
RUN dotnet build "EVCB_OCPP.WSServer.csproj" -c Release -o /app/build

FROM build AS publish
RUN dotnet publish "EVCB_OCPP.WSServer.csproj" -c Release -o /app/publish /p:UseAppHost=false

FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "EVCB_OCPP.WSServer.dll"]