# panel-empyrion-bridge — .NET 8 sidecar that proxies Empyrion's Mod API
# (TCP/protobuf-net via the EPM mod) to a small REST surface for the panel.
#
# Build:
#   docker build -t panel-empyrion-bridge:latest modules/empyrion-bridge
#
# Run:
#   docker run --rm -p 8090:8090 panel-empyrion-bridge:latest
# then:
#   curl 'http://localhost:8090/api/v1/factions?host=<your-server-ip>&port=7028'
FROM mcr.microsoft.com/dotnet/sdk:8.0-alpine AS build
WORKDIR /src
COPY bridge/ ./bridge/
COPY lib/ ./lib/
RUN dotnet publish bridge/Bridge.csproj -c Release -o /out --no-self-contained \
    -p:DebugType=embedded -p:PublishSingleFile=false

FROM mcr.microsoft.com/dotnet/aspnet:8.0-alpine
WORKDIR /app
COPY --from=build /out/ ./
ENV BRIDGE_URLS=http://0.0.0.0:8090 \
    BRIDGE_REQUEST_TIMEOUT_S=8 \
    DOTNET_RUNNING_IN_CONTAINER=true \
    ASPNETCORE_FORWARDEDHEADERS_ENABLED=true
EXPOSE 8090
USER 1000:1000
ENTRYPOINT ["dotnet", "panel-empyrion-bridge.dll"]
