FROM mcr.microsoft.com/dotnet/sdk:10.0-alpine AS build
ARG NEXUS_VERSION=dev
ARG NEXUS_GIT_SHA=unknown
WORKDIR /src
COPY Nexus.Api.csproj .
RUN dotnet restore
COPY . .
RUN dotnet publish -c Release -o /app/publish \
      /p:Version="${NEXUS_VERSION}" \
      /p:InformationalVersion="${NEXUS_VERSION}+${NEXUS_GIT_SHA}"

FROM mcr.microsoft.com/dotnet/aspnet:10.0-alpine
ARG NEXUS_VERSION=dev
ARG NEXUS_GIT_SHA=unknown
LABEL org.opencontainers.image.title="Nexus API" \
      org.opencontainers.image.source="https://git.noveria.net/bao/nexus" \
      org.opencontainers.image.version="${NEXUS_VERSION}" \
      org.opencontainers.image.revision="${NEXUS_GIT_SHA}"
WORKDIR /app
COPY --from=build /app/publish .
RUN apk add --no-cache curl
RUN mkdir -p /var/lib/nexus/openclaw && chown -R "$APP_UID":"$APP_UID" /var/lib/nexus/openclaw
USER $APP_UID
EXPOSE 8080
ENTRYPOINT ["dotnet", "Nexus.Api.dll"]
