Complete Docker Build

This commit is contained in:
2025-05-18 14:06:11 -04:00
parent 24ddb19013
commit 541cdd0b57
4 changed files with 42 additions and 15 deletions

1
AobaServer/.dockerignore Normal file
View File

@@ -0,0 +1 @@
wwwroot

View File

@@ -41,7 +41,4 @@
<Exec Command="rm -rf wwwroot/*" /> <Exec Command="rm -rf wwwroot/*" />
<Exec Command="cp -r target\dx\aoba-client\debug\web\public\* ../AobaServer/wwwroot/" WorkingDirectory="..\AobaClient" /> <Exec Command="cp -r target\dx\aoba-client\debug\web\public\* ../AobaServer/wwwroot/" WorkingDirectory="..\AobaClient" />
</Target> </Target>
<Target Name="BuildDioxusClientRelease" BeforeTargets="Build" Condition="'$(Configuration)'!='DEBUG'">
<Exec Command="dx bundle --platform web -r --out-dir ../AobaServer/wwwroot" WorkingDirectory="..\AobaClient" />
</Target>
</Project> </Project>

View File

@@ -1,12 +1,40 @@
# See https://aka.ms/customizecontainer to learn how to customize your debug container and how Visual Studio uses this Dockerfile to build your images for faster debugging. # Client Side build - prep deps
FROM rust:1 AS chef
RUN rustup target add wasm32-unknown-unknown
RUN cargo install cargo-chef
WORKDIR /app
FROM chef AS planner
COPY . .
WORKDIR /app/AobaClient
RUN cargo chef prepare --recipe-path recipe.json
FROM chef AS client-builder
WORKDIR /app/AobaClient
COPY --from=planner /app/AobaClient/recipe.json recipe.json
RUN cargo chef cook --release --recipe-path recipe.json
COPY /AobaClient /app/AobaClient
COPY /AobaServer/Proto /app/AobaServer/Proto
# Install Protobuf
RUN apt update
RUN apt install -y protobuf-compiler libprotobuf-dev
# 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"
# Create the final bundle folder. Bundle always executes in release mode with optimizations enabled
RUN dx bundle --platform web
# Server Build
# This stage is used when running from VS in fast mode (Default for Debug configuration) # 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 FROM mcr.microsoft.com/dotnet/aspnet:9.0 AS base
USER $APP_UID USER $APP_UID
WORKDIR /app WORKDIR /app
EXPOSE 8614 EXPOSE 8080
EXPOSE 8615 EXPOSE 8081
# This stage is used to build the service project # This stage is used to build the service project
FROM mcr.microsoft.com/dotnet/sdk:9.0 AS build FROM mcr.microsoft.com/dotnet/sdk:9.0 AS build
@@ -15,6 +43,8 @@ WORKDIR /src
COPY ["AobaServer/AobaServer.csproj", "AobaServer/"] COPY ["AobaServer/AobaServer.csproj", "AobaServer/"]
RUN dotnet restore "./AobaServer/AobaServer.csproj" RUN dotnet restore "./AobaServer/AobaServer.csproj"
COPY . . COPY . .
# Copy Built bundle from client builder
COPY --from=client-builder /app/AobaClient/target/dx/aoba-client/release/web/public /src/AobaServer/wwwroot
WORKDIR "/src/AobaServer" WORKDIR "/src/AobaServer"
RUN dotnet build "./AobaServer.csproj" -c $BUILD_CONFIGURATION -o /app/build RUN dotnet build "./AobaServer.csproj" -c $BUILD_CONFIGURATION -o /app/build
@@ -27,4 +57,4 @@ RUN dotnet publish "./AobaServer.csproj" -c $BUILD_CONFIGURATION -o /app/publish
FROM base AS final FROM base AS final
WORKDIR /app WORKDIR /app
COPY --from=publish /app/publish . COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "AobaServer.dll"] ENTRYPOINT ["dotnet", "AobaServer.dll"]

View File

@@ -1,10 +1,9 @@
services: services:
client: # client:
build:
context: .
dockerfile: AobaClient/Dockerfile
# server:
# build: # build:
# context: . # context: .
# dockerfile: AobaServer/Dockerfile # dockerfile: AobaClient/Dockerfile
server:
build:
context: .
dockerfile: AobaServer/Dockerfile