diff --git a/.github/workflows/kub-deploy.yml b/.github/workflows/kub-deploy.yml new file mode 100644 index 0000000..965e695 --- /dev/null +++ b/.github/workflows/kub-deploy.yml @@ -0,0 +1,48 @@ +name: Build and Deploy to Kubernetes + +on: + push: + branches: + - kub-stage + +env: + REGISTRY: 194.5.195.53:30080 + IMAGE_NAME: admin/frontoffice-bff + +jobs: + build-and-deploy: + runs-on: ubuntu-latest + container: + image: docker:latest + options: --privileged + env: + HTTP_PROXY: http://proxyuser:87zH26nbqT2@46.249.98.211:3128 + HTTPS_PROXY: http://proxyuser:87zH26nbqT2@46.249.98.211:3128 + NO_PROXY: localhost,127.0.0.1,gitea-svc,194.5.195.53,10.0.0.0/8 + + steps: + - name: Install git + run: apk add --no-cache git + + - name: Clone repository + run: git clone --depth 1 --branch kub-stage http://gitea-svc:3000/admin/FrontOffice.BFF.git . + + - name: Start Docker daemon + run: | + mkdir -p /etc/docker + echo '{"insecure-registries": ["194.5.195.53:30080"]}' > /etc/docker/daemon.json + dockerd & + for i in $(seq 1 30); do docker info >/dev/null 2>&1 && break || sleep 2; done + + - name: Build Docker Image + run: | + docker build -t $REGISTRY/$IMAGE_NAME:${{ github.sha }} \ + -t $REGISTRY/$IMAGE_NAME:latest \ + --build-arg HTTP_PROXY=$HTTP_PROXY \ + --build-arg HTTPS_PROXY=$HTTPS_PROXY . + + - name: Push to Registry + run: | + echo "${{ secrets.REGISTRY_PASSWORD }}" | docker login $REGISTRY -u admin --password-stdin + docker push $REGISTRY/$IMAGE_NAME:${{ github.sha }} + docker push $REGISTRY/$IMAGE_NAME:latest diff --git a/Dockerfile b/Dockerfile index 441a823..4e73ea4 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,15 +1,24 @@ FROM mcr.microsoft.com/dotnet/sdk:9.0 AS build WORKDIR /src -COPY src/*.sln ./ 2>/dev/null || true -COPY src/*/*.csproj ./ -RUN for file in *.csproj; do mkdir -p "${file%.*}" && mv "$file" "${file%.*}/"; done 2>/dev/null || true -RUN dotnet restore "FrontOffice.BFF/FrontOffice.BFF.csproj" || dotnet restore + +COPY src/*.sln ./ +COPY src/FrontOffice.BFF.WebApi/*.csproj ./FrontOffice.BFF.WebApi/ +COPY src/FrontOffice.BFF.Application/*.csproj ./FrontOffice.BFF.Application/ +COPY src/FrontOffice.BFF.Infrastructure/*.csproj ./FrontOffice.BFF.Infrastructure/ +COPY src/FrontOffice.BFF.Domain/*.csproj ./FrontOffice.BFF.Domain/ +COPY src/FrontOffice.BFF.Contracts/*.csproj ./FrontOffice.BFF.Contracts/ + +RUN dotnet restore "FrontOffice.BFF.WebApi/FrontOffice.BFF.WebApi.csproj" + COPY src/ ./ -RUN dotnet publish "FrontOffice.BFF/FrontOffice.BFF.csproj" -c Release -o /app/publish + +RUN dotnet publish "FrontOffice.BFF.WebApi/FrontOffice.BFF.WebApi.csproj" -c Release -o /app/publish --no-restore FROM mcr.microsoft.com/dotnet/aspnet:9.0 AS runtime WORKDIR /app COPY --from=build /app/publish . + ENV ASPNETCORE_URLS=http://+:8080 EXPOSE 8080 -ENTRYPOINT ["dotnet", "FrontOffice.BFF.dll"] + +ENTRYPOINT ["dotnet", "FrontOffice.BFF.WebApi.dll"] diff --git a/src/FrontOffice.BFF.WebApi/appsettings.json b/src/FrontOffice.BFF.WebApi/appsettings.json index ce34cc1..7d8a76d 100644 --- a/src/FrontOffice.BFF.WebApi/appsettings.json +++ b/src/FrontOffice.BFF.WebApi/appsettings.json @@ -16,5 +16,9 @@ "Authentication": { "Authority": "https://ids.domain.com/", "Audience": "domain_api" + }, + "Seq": { + "ServerUrl": "http://seq-svc:5341", + "ApiKey": "" } } diff --git a/src/FrontOffice.BFF.WebApi/appsettings.json.bak b/src/FrontOffice.BFF.WebApi/appsettings.json.bak new file mode 100644 index 0000000..ce34cc1 --- /dev/null +++ b/src/FrontOffice.BFF.WebApi/appsettings.json.bak @@ -0,0 +1,20 @@ +{ + "JwtSecurityKey": "TvlZVx5TJaHs8e9HgUdGzhGP2CIidoI444nAj+8+g7c=", + "JwtIssuer": "https://localhost", + "JwtAudience": "https://localhost", + "JwtExpiryInDays": 365, + "AllowedHosts": "*", + "Kestrel": { + "EndpointDefaults": { + "Protocols": "Http2" + } + }, + "GrpcChannelOptions": { + "CMSMSAddress": "https://cms.kbs1.ir", + "PYMSMSAddress": "https://ipg.afrino.co" + }, + "Authentication": { + "Authority": "https://ids.domain.com/", + "Audience": "domain_api" + } +}