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"
|
name = "aoba-client"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
authors = ["Amatsugu <khamraj@kaisei.app>"]
|
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
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
@@ -16,7 +15,6 @@ tonic = { version = "*", default-features = false, features = [
|
|||||||
] }
|
] }
|
||||||
prost = "0.13"
|
prost = "0.13"
|
||||||
tonic-web-wasm-client = "0.7"
|
tonic-web-wasm-client = "0.7"
|
||||||
js-sys = { version = "0.3.77" }
|
|
||||||
web-sys = { version = "0.3.77", features = ["Storage", "Window"] }
|
web-sys = { version = "0.3.77", features = ["Storage", "Window"] }
|
||||||
|
|
||||||
[build-dependencies]
|
[build-dependencies]
|
||||||
@@ -25,8 +23,6 @@ tonic-build = { version = "*", default-features = false, features = ["prost"] }
|
|||||||
[features]
|
[features]
|
||||||
default = ["web"]
|
default = ["web"]
|
||||||
web = ["dioxus/web"]
|
web = ["dioxus/web"]
|
||||||
desktop = ["dioxus/desktop"]
|
|
||||||
mobile = ["dioxus/mobile"]
|
|
||||||
|
|
||||||
[profile]
|
[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_server(false)
|
||||||
.build_client(true)
|
.build_client(true)
|
||||||
.compile_protos(
|
.compile_protos(
|
||||||
&["..\\AobaServer\\Proto\\Aoba.proto", "..\\AobaServer\\Proto\\Auth.proto"],
|
&["../AobaServer/Proto/Aoba.proto", "../AobaServer/Proto/Auth.proto"],
|
||||||
&["..\\AobaServer\\Proto\\"],
|
&["../AobaServer/Proto/"],
|
||||||
)?;
|
)?;
|
||||||
|
|
||||||
Ok(())
|
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>
|
<Protobuf Include="Proto\Auth.proto"></Protobuf>
|
||||||
</ItemGroup>
|
</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>
|
</Project>
|
||||||
|
|||||||
@@ -4,27 +4,27 @@
|
|||||||
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 8080
|
EXPOSE 8614
|
||||||
EXPOSE 8081
|
EXPOSE 8615
|
||||||
|
|
||||||
|
|
||||||
# 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
|
||||||
ARG BUILD_CONFIGURATION=Release
|
ARG BUILD_CONFIGURATION=Release
|
||||||
WORKDIR /src
|
WORKDIR /src
|
||||||
COPY ["AobaV2/AobaV2.csproj", "AobaV2/"]
|
COPY ["AobaServer/AobaServer.csproj", "AobaServer/"]
|
||||||
RUN dotnet restore "./AobaV2/AobaV2.csproj"
|
RUN dotnet restore "./AobaServer/AobaServer.csproj"
|
||||||
COPY . .
|
COPY . .
|
||||||
WORKDIR "/src/AobaV2"
|
WORKDIR "/src/AobaServer"
|
||||||
RUN dotnet build "./AobaV2.csproj" -c $BUILD_CONFIGURATION -o /app/build
|
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
|
# This stage is used to publish the service project to be copied to the final stage
|
||||||
FROM build AS publish
|
FROM build AS publish
|
||||||
ARG BUILD_CONFIGURATION=Release
|
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)
|
# 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
|
FROM base AS final
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
COPY --from=publish /app/publish .
|
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.UseGrpcWeb(new GrpcWebOptions { DefaultEnabled = true });
|
||||||
app.UseHttpsRedirection();
|
app.UseHttpsRedirection();
|
||||||
|
app.UseStaticFiles();
|
||||||
app.UseRouting();
|
app.UseRouting();
|
||||||
|
|
||||||
|
|
||||||
app.UseCors();
|
app.UseCors();
|
||||||
|
|
||||||
|
|
||||||
app.UseAuthentication();
|
app.UseAuthentication();
|
||||||
app.UseAuthorization();
|
app.UseAuthorization();
|
||||||
|
|
||||||
|
|
||||||
app.MapControllers();
|
app.MapControllers();
|
||||||
app.MapObserability();
|
app.MapObserability();
|
||||||
app.MapGrpcService<AobaRpcService>()
|
app.MapGrpcService<AobaRpcService>()
|
||||||
@@ -125,8 +126,6 @@ app.MapGrpcService<AobaRpcService>()
|
|||||||
app.MapGrpcService<AobaAuthService>()
|
app.MapGrpcService<AobaAuthService>()
|
||||||
.AllowAnonymous()
|
.AllowAnonymous()
|
||||||
.RequireCors("RPC");
|
.RequireCors("RPC");
|
||||||
|
app.MapFallbackToFile("index.html");
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
app.Run();
|
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