# syntax=docker/dockerfile:1.4

FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build
WORKDIR /src

# Copy the projects
COPY EonaCat.Connections/EonaCat.Connections.csproj EonaCat.Connections/
COPY EonaCat.Connections.Server/EonaCat.Connections.Server.csproj EonaCat.Connections.Server/
RUN dotnet restore EonaCat.Connections.Server/EonaCat.Connections.Server.csproj

# Copy remaining sources
COPY . .
RUN dotnet publish EonaCat.Connections.Server/EonaCat.Connections.Server.csproj -c Release -o /app/publish --no-restore

# Runtime image
FROM mcr.microsoft.com/dotnet/runtime:8.0 AS final
WORKDIR /app
COPY --from=build /app/publish .

EXPOSE 8080

# Set environment variable to signal Docker environment
ENV DOTNET_RUNNING_IN_CONTAINER=true

ENTRYPOINT ["dotnet", "EonaCat.Connections.Server.dll"]
