Files
AZKi/Dockerfile
2026-01-17 18:08:16 -05:00

66 lines
2.3 KiB
Docker

# Client Side build - prep deps
FROM rust:1-trixie AS chef
RUN rustup target add wasm32-unknown-unknown
RUN cargo install cargo-chef
WORKDIR /app
FROM chef AS planner
COPY . .
WORKDIR /app/client
RUN cargo chef prepare --recipe-path recipe.json
FROM chef AS client-builder
WORKDIR /app/client
COPY --from=planner /app/client/recipe.json recipe.json
RUN cargo chef cook --release --recipe-path recipe.json
COPY /client /app/client
COPY /AZKiServer/Protos /app/AZKiServer/Protos
# Install Protobuf
RUN apt update
RUN apt install -y protobuf-compiler libprotobuf-dev ffmpeg
# Install `dx`
RUN curl -L --proto '=https' --tlsv1.2 -sSf https://raw.githubusercontent.com/cargo-bins/cargo-binstall/main/install-from-binstall-release.sh | bash
RUN cargo binstall dioxus-cli --root /.cargo -y --force
ENV PATH="/.cargo/bin:$PATH"
ARG VERSION
ENV APP_VERSION=$VERSION
# Create the final bundle folder. Bundle always executes in release mode with optimizations enabled
RUN dx bundle --release --platform web
# Server Build
# This stage is used when running from VS in fast mode (Default for Debug configuration)
FROM mcr.microsoft.com/dotnet/aspnet:9.0 AS base
RUN apt-get update && apt-get install -y ffmpeg #libvips libvips-tools
USER $APP_UID
WORKDIR /app
EXPOSE 8080
EXPOSE 8081
# This stage is used to build the service project
FROM mcr.microsoft.com/dotnet/sdk:9.0-noble AS build
ARG BUILD_CONFIGURATION=Release
WORKDIR /src
COPY ["AZKiServer/AZKi Server.csproj", "AZKiServer/"]
RUN dotnet restore "./AZKiServer/AZKi Server.csproj"
COPY . .
# Copy Built bundle from client builder
COPY --from=client-builder /app/client/target/dx/azki-client/release/web/public /src/AZKiServer/wwwroot
WORKDIR "/src/AZKiServer"
# RUN dotnet build "./AZKiServer.csproj" -c $BUILD_CONFIGURATION #-o /app/build
# This stage is used to publish the service project to be copied to the final stage
FROM build AS publish
ARG BUILD_CONFIGURATION=Release
RUN dotnet publish "./AZKi Server.csproj" -c $BUILD_CONFIGURATION -o /app/publish /p:UseAppHost=false
# This stage is used in production or when running from VS in regular mode (Default when not using the Debug configuration)
FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ARG VERSION
ENV APP_VERSION=$VERSION
ENTRYPOINT ["dotnet", "AZKiServer.dll"]