# Set the base image
FROM mcr.microsoft.com/dotnet/sdk:8.0-jammy-arm64v8 AS build

# Set the working directory
WORKDIR /src

# Copy the project files
COPY ["Expedience.Web/Expedience.Web.csproj", "Expedience.Web/"]
COPY ["Expedience.Infrastructure/Expedience.Infrastructure.csproj", "Expedience.Infrastructure/"]

# Restore the packages
RUN dotnet restore "Expedience.Web/Expedience.Web.csproj"

COPY . .

# Build the project
WORKDIR "/src/Expedience.Web"
RUN dotnet build "Expedience.Web.csproj" -c Release -o /app/build


# Publish the project
ARG TARGET_RUNTIME=linux-x64
RUN dotnet publish "Expedience.Web.csproj" -c Release -o /app/publish --no-self-contained --runtime $TARGET_RUNTIME

# Set the base image for the final runtime
FROM mcr.microsoft.com/dotnet/sdk:8.0-jammy-arm64v8

# Set the working directory
WORKDIR /app
COPY --from=build /app/publish .

# Set the ASPNETCORE_ENVIRONMENT environment variable
ENV ASPNETCORE_ENVIRONMENT=Production

# Expose the ports the application will run on
EXPOSE 80
EXPOSE 443

ENTRYPOINT ["dotnet", "Expedience.Web.dll"]