This commit is contained in:
mmrbnjd
2025-10-03 23:30:01 +03:30
parent ef2cf5ff30
commit 4df6c87012
34 changed files with 908 additions and 555 deletions

View File

@@ -0,0 +1,10 @@
 from run E:\TaxPayerFULL
docker build -f TaxPayerFULL\Dockerfile -t app_moadiran .
docker run --name app_moadiran -d -p 82:5107 app_moadiran
--------------------------------------------------------------------------------------------
in local => docker build -f TaxPayerFULL\Dockerfile -t mmrbnjd/app_moadiran:latest .
in local => docker push mmrbnjd/app_moadiran:latest
in server => docker pull mmrbnjd/app_moadiran:latest
in server => docker run -d -p 3102:5107 --restart always mmrbnjd/app_moadiran:latest

98
TaxPayerFull/Dockerfile Normal file
View File

@@ -0,0 +1,98 @@
# مرحله ۱: Build پروژه Blazor WASM با .NET 9
# اینجا باید از SDK استفاده کنید نه aspnet
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 TaxPayerFull/Front.csproj Front/
COPY Shared/Shared.csproj Shared/
COPY . .
# پاک‌سازی workloadهای قدیمی (اختیاری)
RUN dotnet workload clean
# نصب wasm-tools برای Blazor
RUN dotnet workload install wasm-tools
# انتشار (Publish) خروجی در حالت Release
RUN dotnet publish "TaxPayerFull/Front.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 5107;\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 /assets/ {\n\
expires 7d;\n\
add_header Cache-Control "public";\n\
}\n\
\n\
location /css/ {\n\
expires 7d;\n\
add_header Cache-Control "public";\n\
}\n\
\n\
location /fonts/ {\n\
expires 7d;\n\
add_header Cache-Control "public";\n\
}\n\
\n\
location /img/ {\n\
expires 7d;\n\
add_header Cache-Control "public";\n\
}\n\
\n\
location /js/ {\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 5107
CMD ["nginx", "-g", "daemon off;"]

View File

@@ -31,13 +31,14 @@ builder.Services.AddScoped(sp => new UserAuthenticationDTO()
enterDate =new DateTime(),
exitDate = new DateTime(),
}) ;
string BaseAddress = builder.Configuration.GetSection("BaseAddress").Value;
builder.Services.AddScoped(sp => new HttpClient { BaseAddress = new Uri(BaseAddress) });
// Server
//builder.Services.AddScoped(sp => new HttpClient { BaseAddress = new Uri("http://195.88.208.142:7075/api/") });
//builder.Services.AddScoped(sp => new HttpClient { BaseAddress = new Uri("https://moadiran.ir:444/api/") });
//Home
builder.Services.AddScoped(sp => new HttpClient { BaseAddress = new Uri("http://localhost:5271/api/") });
//builder.Services.AddScoped(sp => new HttpClient { BaseAddress = new Uri("http://localhost:5271/api/") });
//farzan
//builder.Services.AddScoped(sp => new HttpClient { BaseAddress = new Uri("https://localhost:7075/api/") });

21
TaxPayerFull/default.conf Normal file
View File

@@ -0,0 +1,21 @@
server {
listen 8084;
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
TaxPayerFull/nginx.conf Normal file
View 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;
}

View File

@@ -0,0 +1,10 @@
{
"BaseAddress": "http://192.168.1.14:3201/api/",
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
},
"AllowedHosts": "*"
}