PluralKit/ci/Dockerfile.dotnet
2025-10-08 21:00:51 +00:00

51 lines
1.7 KiB
Text

FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build
WORKDIR /app
RUN apt-get update && apt-get install -y curl build-essential && \
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
ENV PATH="/root/.cargo/bin:${PATH}"
ENV RUSTFLAGS='-C link-arg=-s'
# Install uniffi-bindgen-cs
RUN cargo install uniffi-bindgen-cs --git https://github.com/90-008/uniffi-bindgen-cs
# Restore/fetch dependencies excluding app code to make use of caching
COPY PluralKit.sln /app/
COPY Myriad/Myriad.csproj /app/Myriad/
COPY PluralKit.API/PluralKit.API.csproj /app/PluralKit.API/
COPY PluralKit.Bot/PluralKit.Bot.csproj /app/PluralKit.Bot/
COPY PluralKit.Core/PluralKit.Core.csproj /app/PluralKit.Core/
COPY PluralKit.Tests/PluralKit.Tests.csproj /app/PluralKit.Tests/
COPY .git/ /app/.git
COPY Serilog/ /app/Serilog/
RUN dotnet restore PluralKit.sln
# Copy the rest of the code
COPY . /app
# copy parser code
COPY Cargo.toml /app/
COPY Cargo.lock /app/
COPY crates/ /app/crates
# Generate command parser bindings
RUN mkdir -p app/obj && cargo -Z unstable-options build --package commands --lib --release --artifact-dir app/obj/
RUN uniffi-bindgen-cs "app/obj/libcommands.so" --library --out-dir="app/PluralKit.Bot"
RUN cargo run --package commands --bin write_cs_glue -- "app/PluralKit.Bot/commandtypes.cs"
# build bot
RUN dotnet build -c Release -o bin
# Build runtime stage (doesn't include SDK)
FROM mcr.microsoft.com/dotnet/aspnet:8.0
LABEL org.opencontainers.image.source = "https://github.com/PluralKit/PluralKit"
WORKDIR /app
COPY --from=build /app ./
# Allow overriding CMD from eg. docker-compose to run API layer too
ENTRYPOINT ["dotnet"]
CMD ["bin/PluralKit.Bot.dll"]