mudancinhas
All checks were successful
Mindforge API Build and Deploy / Build Mindforge API Image (push) Successful in 2m12s
Mindforge API Build and Deploy / Deploy Mindforge API (internal) (push) Successful in 8s
Mindforge Web Build and Deploy (internal) / Build Mindforge Web Image (push) Successful in 3m41s
Mindforge Web Build and Deploy (internal) / Deploy Mindforge Web (internal) (push) Successful in 8s

This commit is contained in:
2026-06-11 20:26:08 -03:00
parent b29ae991c8
commit 21186c9270
13 changed files with 927 additions and 82 deletions

View File

@@ -5,9 +5,11 @@ ARG TARGETOS
WORKDIR /app
COPY Mindforge.API.csproj ./
RUN dotnet restore -a $TARGETARCH
RUN if [ "$TARGETARCH" = "amd64" ]; then DOTNET_ARCH="x64"; else DOTNET_ARCH="$TARGETARCH"; fi && \
dotnet restore -a "$DOTNET_ARCH"
COPY . .
RUN dotnet publish -c Release -a $TARGETARCH --no-restore -o /app/publish
RUN if [ "$TARGETARCH" = "amd64" ]; then DOTNET_ARCH="x64"; else DOTNET_ARCH="$TARGETARCH"; fi && \
dotnet publish -c Release -a "$DOTNET_ARCH" --no-restore -o /app/publish
FROM mcr.microsoft.com/dotnet/aspnet:9.0-alpine
WORKDIR /app

View File

@@ -10,14 +10,13 @@ namespace Mindforge.API.Providers
{
public class OpenAIApiProvider : ILlmApiProvider
{
private readonly HttpClient _httpClient;
private readonly IHttpClientFactory _httpClientFactory;
private readonly IConfiguration _configuration;
private readonly ILogger<OpenAIApiProvider> _logger;
public OpenAIApiProvider(HttpClient httpClient, IConfiguration configuration, ILogger<OpenAIApiProvider> logger)
public OpenAIApiProvider(IHttpClientFactory httpClientFactory, IConfiguration configuration, ILogger<OpenAIApiProvider> logger)
{
_httpClient = httpClient;
_httpClient.Timeout = TimeSpan.FromMinutes(5);
_httpClientFactory = httpClientFactory;
_configuration = configuration;
_logger = logger;
}
@@ -52,6 +51,9 @@ namespace Mindforge.API.Providers
Exception? lastErr = null;
using var httpClient = _httpClientFactory.CreateClient();
httpClient.Timeout = TimeSpan.FromMinutes(5);
for (int i = 0; i < 5; i++)
{
using var request = new HttpRequestMessage(HttpMethod.Post, url);
@@ -60,7 +62,7 @@ namespace Mindforge.API.Providers
try
{
var response = await _httpClient.SendAsync(request);
var response = await httpClient.SendAsync(request);
var responseBody = await response.Content.ReadAsStringAsync();
if (!response.IsSuccessStatusCode)

View File

@@ -9,7 +9,7 @@ namespace Mindforge.API.Services
{
public class GiteaService : IGiteaService
{
private readonly HttpClient _httpClient;
private readonly IHttpClientFactory _httpClientFactory;
private readonly string _baseUrl = string.Empty;
private readonly string _owner = string.Empty;
private readonly string _repo = string.Empty;
@@ -21,9 +21,9 @@ namespace Mindforge.API.Services
PropertyNameCaseInsensitive = true
};
public GiteaService(HttpClient httpClient, IConfiguration configuration)
public GiteaService(IHttpClientFactory httpClientFactory, IConfiguration configuration)
{
_httpClient = httpClient;
_httpClientFactory = httpClientFactory;
var repoUrl = configuration["GITEA_REPO_URL"];
var token = configuration["GITEA_ACCESS_TOKEN"];
@@ -78,7 +78,8 @@ namespace Mindforge.API.Services
$"{_baseUrl}/api/v1/repos/{_owner}/{_repo}/raw/{path}?ref=master");
request.Headers.Add("Authorization", $"token {_token}");
var response = await _httpClient.SendAsync(request);
var httpClient = _httpClientFactory.CreateClient();
var response = await httpClient.SendAsync(request);
if (response.StatusCode == System.Net.HttpStatusCode.NotFound)
throw new UserException($"File not found in repository: {path}");
@@ -90,9 +91,10 @@ namespace Mindforge.API.Services
{
EnsureConfigured();
var httpClient = _httpClientFactory.CreateClient();
var request = new HttpRequestMessage(HttpMethod.Get, $"{_baseUrl}{endpoint}");
request.Headers.Add("Authorization", $"token {_token}");
var response = await _httpClient.SendAsync(request);
var response = await httpClient.SendAsync(request);
response.EnsureSuccessStatusCode();
return await response.Content.ReadAsStringAsync();
}