# syntax=docker/dockerfile:1.7-labs

#
# StellaOps Authority – distroless container build
# Produces a minimal image containing the Authority host and its plugins.
#

ARG SDK_IMAGE=mcr.microsoft.com/dotnet/nightly/sdk:10.0
ARG RUNTIME_IMAGE=gcr.io/distroless/dotnet/aspnet:latest

FROM ${SDK_IMAGE} AS build

WORKDIR /src

# Restore & publish
COPY . .
RUN dotnet restore StellaOps.sln
RUN dotnet publish src/StellaOps.Authority/StellaOps.Authority/StellaOps.Authority.csproj \
    -c Release \
    -o /app/publish \
    /p:UseAppHost=false

FROM ${RUNTIME_IMAGE} AS runtime

WORKDIR /app

ENV ASPNETCORE_URLS=http://0.0.0.0:8080
ENV STELLAOPS_AUTHORITY__PLUGINDIRECTORIES__0=/app/plugins
ENV STELLAOPS_AUTHORITY__PLUGINS__CONFIGURATIONDIRECTORY=/app/etc/authority.plugins

COPY --from=build /app/publish ./

# Provide writable mount points for configs/keys/plugins
VOLUME ["/app/etc", "/app/plugins", "/app/keys"]

EXPOSE 8080

ENTRYPOINT ["dotnet", "StellaOps.Authority.dll"]
