fix deploy config

This commit is contained in:
motahhari
2026-06-03 03:20:16 +03:30
parent a2140fadc3
commit 1fb1081af5
3 changed files with 42 additions and 12 deletions

View File

@@ -1,29 +1,22 @@
# مرحله 1: Build
FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build
WORKDIR /app
# کپی فایل‌های پروژه به دایرکتوری کاری
COPY ["Complex.EndPoint/Complex.EndPoint.csproj", "Complex.EndPoint/"]
COPY nuget.config /
COPY Complex.EndPoint/Complex.EndPoint.csproj Complex.EndPoint/
COPY Complex.Application/Complex.Application.csproj Complex.Application/
COPY Complex.Domain/Complex.Domain.csproj Complex.Domain/
COPY Complex.Infrastructure/Complex.Infrastructure.csproj Complex.Infrastructure/
# بازیابی پکیج‌ها
RUN dotnet restore "Complex.EndPoint/Complex.EndPoint.csproj"
# کپی بقیه کدهای پروژه
COPY . .
# ساخت پروژه با حالت Release
RUN dotnet publish "Complex.EndPoint/Complex.EndPoint.csproj" -c Release -o /app/publish
# مرحله 2: Runtime
FROM mcr.microsoft.com/dotnet/aspnet:6.0 AS runtime
WORKDIR /app
# کپی خروجی Publish از مرحله Build
COPY --from=build /app/publish .
EXPOSE 80
# تعیین نقطه شروع کانتینر
ENTRYPOINT ["dotnet", "Complex.EndPoint.dll"]
# مشخص کردن پورت (اگر پروژه روی 80 یا 5000 است آن را تنظیم کن)

29
docker-compose.yml Normal file
View File

@@ -0,0 +1,29 @@
version: "3.8"
services:
complex:
build: .
container_name: ComplexApi
environment:
- TZ=Asia/Tehran
- ASPNETCORE_ENVIRONMENT=Production
- ConnectionStrings__Default=Server=sqlserver,1433;TrustServerCertificate=True;Database=ComplexDb;User Id=sa;Password=qwER12#$110;
labels:
- "traefik.enable=true"
- "traefik.http.routers.complex.rule=Host(`complex.nabaksoft.ir`)"
- "traefik.http.services.complex.loadbalancer.server.port=80"
- "traefik.http.routers.complex.entrypoints=websecure"
# - "traefik.http.routers.webapp.tls.certresolver=letsencrypt"
- "traefik.http.routers.complex.middlewares=complex-cors@docker"
- "traefik.http.middlewares.complex-cors.headers.accessControlAllowMethods=GET,POST,PUT,DELETE,OPTIONS"
- "traefik.http.middlewares.complex-cors.headers.accessControlAllowHeaders=*"
- "traefik.http.middlewares.complex-cors.headers.accessControlAllowOriginList=https://*.nabaksoft.ir,http://192.168.8.108"
- "traefik.http.middlewares.webapp-cors.headers.accessControlAllowCredentials=true"
- "traefik.http.middlewares.complex-cors.headers.addVaryHeader=true"
networks:
- services
restart: unless-stopped
networks:
services:
external: true

8
nuget.config Normal file
View File

@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageSources>
<clear />
<add key="iki" value="https://nuget.devneeds.ir/repository/nuget/index.json" />
</packageSources>
</configuration>