###### generated-by: Ablera.Serdica.CiJobsBuilder 1.0.0 ######
###### Build & Publish ########################################################
FROM mirrors.ablera.dev/docker-mirror/dotnet/sdk:9.0-alpine AS build
WORKDIR /
COPY . .
WORKDIR /src/Serdica/Ablera.Serdica.Authority/Ablera.Serdica.Authority
RUN dotnet restore "Ablera.Serdica.Authority.csproj"
RUN dotnet publish "Ablera.Serdica.Authority.csproj" -c Release -o /app/publish

###### Run stage ##############################################################
FROM mirrors.ablera.dev/docker-mirror/dotnet/aspnet:9.0-alpine AS final
ENV DOTNET_SYSTEM_GLOBALIZATION_INVARIANT=false
ENV TZ=UTC
RUN apk add --no-cache curl icu-data-full icu-libs tzdata
WORKDIR /app
COPY --from=build /app/publish .
CMD ["dotnet","Ablera.Serdica.Authority.dll"]

# port should match a port the web server is listening on
ENV HEALTHCHECK_PORT=80 \
    HEALTHCHECK_HOST=localhost \
    HEALTHCHECK_PROTOCOL=http \
    HEALTHCHECK_ENDPOINT="health"

HEALTHCHECK --interval=15s --timeout=5s --start-period=10s --retries=3 \
  CMD curl -sSLf ${HEALTHCHECK_PROTOCOL}://${HEALTHCHECK_HOST}:${HEALTHCHECK_PORT}/${HEALTHCHECK_ENDPOINT} || (echo 'Health check failed!' && exit 1)