docker testing + setup hosting dx app via aspnet
This commit is contained in:
6
AobaClient/.dockerignore
Normal file
6
AobaClient/.dockerignore
Normal file
@@ -0,0 +1,6 @@
|
||||
**/target
|
||||
**/dist
|
||||
LICENSES
|
||||
LICENSE
|
||||
temp
|
||||
README.md
|
||||
3323
AobaClient/Cargo.lock
generated
3323
AobaClient/Cargo.lock
generated
File diff suppressed because it is too large
Load Diff
@@ -2,8 +2,7 @@
|
||||
name = "aoba-client"
|
||||
version = "0.1.0"
|
||||
authors = ["Amatsugu <khamraj@kaisei.app>"]
|
||||
edition = "2021"
|
||||
|
||||
edition = "2024"
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
||||
@@ -16,7 +15,6 @@ tonic = { version = "*", default-features = false, features = [
|
||||
] }
|
||||
prost = "0.13"
|
||||
tonic-web-wasm-client = "0.7"
|
||||
js-sys = { version = "0.3.77" }
|
||||
web-sys = { version = "0.3.77", features = ["Storage", "Window"] }
|
||||
|
||||
[build-dependencies]
|
||||
@@ -25,8 +23,6 @@ tonic-build = { version = "*", default-features = false, features = ["prost"] }
|
||||
[features]
|
||||
default = ["web"]
|
||||
web = ["dioxus/web"]
|
||||
desktop = ["dioxus/desktop"]
|
||||
mobile = ["dioxus/mobile"]
|
||||
|
||||
[profile]
|
||||
|
||||
|
||||
44
AobaClient/Dockerfile
Normal file
44
AobaClient/Dockerfile
Normal file
@@ -0,0 +1,44 @@
|
||||
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 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
|
||||
ENTRYPOINT [ "sleep", "infinity" ]
|
||||
|
||||
|
||||
# FROM chef AS runtime
|
||||
# COPY --from=builder /app/AobaClient/target/dx/aoba-client/release/web/ /usr/local/app
|
||||
|
||||
# # set our port and make sure to listen for all connections
|
||||
# ENV PORT=8616
|
||||
# ENV IP=0.0.0.0
|
||||
|
||||
# # expose the port 8080
|
||||
# EXPOSE 8616
|
||||
|
||||
# WORKDIR /usr/local/app
|
||||
# ENTRYPOINT [ "/usr/local/app/server" ]
|
||||
|
||||
@@ -3,8 +3,8 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
.build_server(false)
|
||||
.build_client(true)
|
||||
.compile_protos(
|
||||
&["..\\AobaServer\\Proto\\Aoba.proto", "..\\AobaServer\\Proto\\Auth.proto"],
|
||||
&["..\\AobaServer\\Proto\\"],
|
||||
&["../AobaServer/Proto/Aoba.proto", "../AobaServer/Proto/Auth.proto"],
|
||||
&["../AobaServer/Proto/"],
|
||||
)?;
|
||||
|
||||
Ok(())
|
||||
|
||||
1
AobaServer/.gitignore
vendored
Normal file
1
AobaServer/.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
||||
wwwroot/*
|
||||
@@ -36,4 +36,12 @@
|
||||
<Protobuf Include="Proto\Auth.proto"></Protobuf>
|
||||
</ItemGroup>
|
||||
|
||||
<Target Name="BuildDioxusClientDebug" BeforeTargets="Build" Condition="'$(Configuration)'=='DEBUG'">
|
||||
<Exec Command="dx build --platform web" WorkingDirectory="..\AobaClient" />
|
||||
<Exec Command="rm -rf wwwroot/*" />
|
||||
<Exec Command="cp -r target\dx\aoba-client\debug\web\public\* ../AobaServer/wwwroot/" WorkingDirectory="..\AobaClient" />
|
||||
</Target>
|
||||
<Target Name="BuildDioxusClientRelease" BeforeTargets="Build" Condition="'$(Configuration)'!='DEBUG'">
|
||||
<Exec Command="dx bundle --platform web -r --out-dir ../AobaServer/wwwroot" WorkingDirectory="..\AobaClient" />
|
||||
</Target>
|
||||
</Project>
|
||||
|
||||
@@ -4,27 +4,27 @@
|
||||
FROM mcr.microsoft.com/dotnet/aspnet:9.0 AS base
|
||||
USER $APP_UID
|
||||
WORKDIR /app
|
||||
EXPOSE 8080
|
||||
EXPOSE 8081
|
||||
EXPOSE 8614
|
||||
EXPOSE 8615
|
||||
|
||||
|
||||
# This stage is used to build the service project
|
||||
FROM mcr.microsoft.com/dotnet/sdk:9.0 AS build
|
||||
ARG BUILD_CONFIGURATION=Release
|
||||
WORKDIR /src
|
||||
COPY ["AobaV2/AobaV2.csproj", "AobaV2/"]
|
||||
RUN dotnet restore "./AobaV2/AobaV2.csproj"
|
||||
COPY ["AobaServer/AobaServer.csproj", "AobaServer/"]
|
||||
RUN dotnet restore "./AobaServer/AobaServer.csproj"
|
||||
COPY . .
|
||||
WORKDIR "/src/AobaV2"
|
||||
RUN dotnet build "./AobaV2.csproj" -c $BUILD_CONFIGURATION -o /app/build
|
||||
WORKDIR "/src/AobaServer"
|
||||
RUN dotnet build "./AobaServer.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 "./AobaV2.csproj" -c $BUILD_CONFIGURATION -o /app/publish /p:UseAppHost=false
|
||||
RUN dotnet publish "./AobaServer.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 .
|
||||
ENTRYPOINT ["dotnet", "AobaV2.dll"]
|
||||
ENTRYPOINT ["dotnet", "AobaServer.dll"]
|
||||
@@ -109,15 +109,16 @@ if (!app.Environment.IsDevelopment())
|
||||
|
||||
app.UseGrpcWeb(new GrpcWebOptions { DefaultEnabled = true });
|
||||
app.UseHttpsRedirection();
|
||||
app.UseStaticFiles();
|
||||
app.UseRouting();
|
||||
|
||||
|
||||
app.UseCors();
|
||||
|
||||
|
||||
app.UseAuthentication();
|
||||
app.UseAuthorization();
|
||||
|
||||
|
||||
app.MapControllers();
|
||||
app.MapObserability();
|
||||
app.MapGrpcService<AobaRpcService>()
|
||||
@@ -125,8 +126,6 @@ app.MapGrpcService<AobaRpcService>()
|
||||
app.MapGrpcService<AobaAuthService>()
|
||||
.AllowAnonymous()
|
||||
.RequireCors("RPC");
|
||||
|
||||
|
||||
|
||||
app.MapFallbackToFile("index.html");
|
||||
|
||||
app.Run();
|
||||
|
||||
10
docker-compose.yml
Normal file
10
docker-compose.yml
Normal file
@@ -0,0 +1,10 @@
|
||||
services:
|
||||
client:
|
||||
build:
|
||||
context: .
|
||||
dockerfile: AobaClient/Dockerfile
|
||||
# server:
|
||||
# build:
|
||||
# context: .
|
||||
# dockerfile: AobaServer/Dockerfile
|
||||
|
||||
Reference in New Issue
Block a user