dockrfile wasm
This commit is contained in:
4
Presentation/HushianWebApp/DockerCommand.txt
Normal file
4
Presentation/HushianWebApp/DockerCommand.txt
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
E:\_hushian> docker build -f Presentation\HushianWebApp\Dockerfile -t hushianapp .
|
||||||
|
|
||||||
|
|
||||||
|
docker run --name hushian_app -d -p 5165:5165 sha256:cd08e4a869cb44e17fafdcf551e7eaa3f26c0c3d1420df78f695359bde08f0fb
|
74
Presentation/HushianWebApp/Dockerfile
Normal file
74
Presentation/HushianWebApp/Dockerfile
Normal file
@@ -0,0 +1,74 @@
|
|||||||
|
# مرحله ۱: Build پروژه Blazor WASM با .NET 9
|
||||||
|
FROM mcr.microsoft.com/dotnet/sdk:9.0 AS build
|
||||||
|
WORKDIR /src
|
||||||
|
|
||||||
|
# نصب وابستگیها برای emscripten (python3 + سایر ابزارها)
|
||||||
|
RUN apt-get update && apt-get install -y python3 make cmake clang zlib1g-dev \
|
||||||
|
&& rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
|
# کپی کردن فایلهای پروژه
|
||||||
|
COPY ["Presentation/HushianWebApp/HushianWebApp.csproj", "Presentation/HushianWebApp/"]
|
||||||
|
COPY ["Common/Common.csproj", "Common/"]
|
||||||
|
COPY . .
|
||||||
|
RUN dotnet workload clean
|
||||||
|
|
||||||
|
# نصب wasm-tools برای Blazor
|
||||||
|
RUN dotnet workload install wasm-tools
|
||||||
|
|
||||||
|
# انتشار (Publish) خروجی در حالت Release
|
||||||
|
RUN dotnet publish "Presentation/HushianWebApp/HushianWebApp.csproj" -c Release -o /app \
|
||||||
|
-p:TreatWarningsAsErrors=false \
|
||||||
|
-p:RunAOTCompilation=false \
|
||||||
|
-p:PublishTrimmed=false
|
||||||
|
|
||||||
|
# مرحله ۲: سرو کردن با Nginx
|
||||||
|
FROM nginx:alpine AS final
|
||||||
|
WORKDIR /usr/share/nginx/html
|
||||||
|
|
||||||
|
# حذف محتوای پیشفرض nginx
|
||||||
|
RUN rm -rf ./*
|
||||||
|
|
||||||
|
# کپی خروجی Blazor WASM
|
||||||
|
COPY --from=build /app/wwwroot ./
|
||||||
|
|
||||||
|
# فقط بلوک server داخل default.conf
|
||||||
|
RUN printf 'server {\n\
|
||||||
|
listen 5165;\n\
|
||||||
|
server_name localhost;\n\
|
||||||
|
\n\
|
||||||
|
root /usr/share/nginx/html;\n\
|
||||||
|
index index.html;\n\
|
||||||
|
\n\
|
||||||
|
location / {\n\
|
||||||
|
try_files $uri $uri/ /index.html;\n\
|
||||||
|
}\n\
|
||||||
|
\n\
|
||||||
|
location /_framework/ {\n\
|
||||||
|
expires 1y;\n\
|
||||||
|
add_header Cache-Control "public, immutable";\n\
|
||||||
|
}\n\
|
||||||
|
\n\
|
||||||
|
location /_content/ {\n\
|
||||||
|
expires 1y;\n\
|
||||||
|
add_header Cache-Control "public, immutable";\n\
|
||||||
|
}\n\
|
||||||
|
\n\
|
||||||
|
location /Before/ {\n\
|
||||||
|
expires 7d;\n\
|
||||||
|
add_header Cache-Control "public";\n\
|
||||||
|
}\n\
|
||||||
|
\n\
|
||||||
|
location ~ \\.dll$ { add_header Content-Type application/octet-stream; }\n\
|
||||||
|
location ~ \\.wasm$ { add_header Content-Type application/wasm; }\n\
|
||||||
|
location ~ \\.pdb$ { add_header Content-Type application/octet-stream; }\n\
|
||||||
|
location ~ \\.dat$ { add_header Content-Type application/octet-stream; }\n\
|
||||||
|
\n\
|
||||||
|
gzip on;\n\
|
||||||
|
gzip_types text/plain application/xml text/css application/javascript application/json application/wasm;\n\
|
||||||
|
gzip_min_length 256;\n\
|
||||||
|
\n\
|
||||||
|
error_page 404 /index.html;\n\
|
||||||
|
}' > /etc/nginx/conf.d/default.conf
|
||||||
|
|
||||||
|
EXPOSE 5165
|
||||||
|
CMD ["nginx", "-g", "daemon off;"]
|
@@ -7,7 +7,7 @@ using HushianWebApp.Service;
|
|||||||
var builder = WebAssemblyHostBuilder.CreateDefault(args);
|
var builder = WebAssemblyHostBuilder.CreateDefault(args);
|
||||||
builder.RootComponents.Add<App>("#app");
|
builder.RootComponents.Add<App>("#app");
|
||||||
builder.RootComponents.Add<HeadOutlet>("head::after");
|
builder.RootComponents.Add<HeadOutlet>("head::after");
|
||||||
string BaseAddress=builder.Configuration.GetSection("BaseAddress").Value;
|
string BaseAddress = builder.Configuration.GetSection("BaseAddress").Value;
|
||||||
builder.Services.AddScoped(sp => new HttpClient { BaseAddress = new Uri(BaseAddress) });
|
builder.Services.AddScoped(sp => new HttpClient { BaseAddress = new Uri(BaseAddress) });
|
||||||
builder.Services.AddScoped<ILocalStorageService, LocalStorageService>();
|
builder.Services.AddScoped<ILocalStorageService, LocalStorageService>();
|
||||||
builder.Services.AddScoped<BaseController>();
|
builder.Services.AddScoped<BaseController>();
|
||||||
|
21
Presentation/HushianWebApp/default.conf
Normal file
21
Presentation/HushianWebApp/default.conf
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
server {
|
||||||
|
listen 5089;
|
||||||
|
server_name localhost;
|
||||||
|
|
||||||
|
root /usr/share/nginx/html;
|
||||||
|
index index.html;
|
||||||
|
|
||||||
|
location / {
|
||||||
|
try_files $uri $uri/ /index.html;
|
||||||
|
}
|
||||||
|
|
||||||
|
location ~* \.(?:ico|css|js|gif|jpe?g|png|woff2?|eot|ttf|svg)$ {
|
||||||
|
expires 6M;
|
||||||
|
access_log off;
|
||||||
|
add_header Cache-Control "public";
|
||||||
|
}
|
||||||
|
|
||||||
|
location = /index.html {
|
||||||
|
add_header Cache-Control "no-store, no-cache, must-revalidate, proxy-revalidate, max-age=0";
|
||||||
|
}
|
||||||
|
}
|
12
Presentation/HushianWebApp/nginx.conf
Normal file
12
Presentation/HushianWebApp/nginx.conf
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
worker_processes 1;
|
||||||
|
|
||||||
|
events { worker_connections 1024; }
|
||||||
|
|
||||||
|
http {
|
||||||
|
include mime.types;
|
||||||
|
default_type application/octet-stream;
|
||||||
|
sendfile on;
|
||||||
|
keepalive_timeout 65;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
@@ -1,5 +1,5 @@
|
|||||||
{
|
{
|
||||||
"BaseAddress": "http://localhost:8080/api/",
|
"BaseAddress": "http://localhost:5089/api/",
|
||||||
"Logging": {
|
"Logging": {
|
||||||
"LogLevel": {
|
"LogLevel": {
|
||||||
"Default": "Information",
|
"Default": "Information",
|
||||||
|
Reference in New Issue
Block a user