Compare commits

..

19 Commits

Author SHA1 Message Date
2b7ed3e451 .net10 and few fixes
Some checks failed
Build Docker Images / build-and-push (push) Failing after 11s
2025-11-21 16:37:47 +01:00
a631cd6b3e update .net version 2025-11-21 14:19:44 +01:00
cef0f73dbb some cleanup 2025-11-21 14:09:06 +01:00
Michał Zieliński
9e15afc1c2 temporary disable hangfire auth
All checks were successful
Build Docker Images / build-and-push (push) Successful in 1m23s
2025-10-19 12:09:06 +02:00
Michał Zieliński
36dc42239a API url fix
All checks were successful
Build Docker Images / build-and-push (push) Successful in 1m20s
2025-10-19 12:01:10 +02:00
Michał Zieliński
decc72c554 Fix login issues
All checks were successful
Build Docker Images / build-and-push (push) Successful in 1m23s
2025-10-19 11:04:14 +02:00
Michał Zieliński
e086a919c3 install wget in docker image
All checks were successful
Build Docker Images / build-and-push (push) Successful in 1m20s
2025-10-18 16:42:44 +02:00
Michał Zieliński
da43860c61 install curl in dockerfile
All checks were successful
Build Docker Images / build-and-push (push) Successful in 1m27s
2025-10-18 12:53:51 +02:00
Michał Zieliński
5441e280e0 Auto apply EF migrations on startup
All checks were successful
Build Docker Images / build-and-push (push) Successful in 1m25s
2025-10-18 10:04:47 +02:00
Michał Zieliński
8fd8a79d75 tokenize
All checks were successful
Build Docker Images / build-and-push (push) Successful in 1m18s
2025-10-13 22:17:05 +02:00
Michał Zieliński
04174fff3b tokenize
All checks were successful
Build Docker Images / build-and-push (push) Successful in 1m19s
2025-10-13 22:15:23 +02:00
Michał Zieliński
27433d1bd5 release
All checks were successful
Build Docker Images / build-and-push (push) Successful in 1m19s
2025-10-13 22:08:44 +02:00
Michał Zieliński
bc3a76b82b release
All checks were successful
Build Docker Images / build-and-push (push) Successful in 1m18s
2025-10-13 21:45:08 +02:00
Michał Zieliński
41c18590d8 build
All checks were successful
Build Docker Images / build-and-push (push) Successful in 1m17s
2025-10-13 21:40:09 +02:00
Michał Zieliński
1be0866c69 WIP: release
All checks were successful
Build Docker Images / build-and-push (push) Successful in 1m26s
2025-10-13 21:31:44 +02:00
Michał Zieliński
730eb6c3b7 build
All checks were successful
Build Docker Images / build-and-push (push) Successful in 1m42s
2025-10-12 20:22:21 +02:00
Michał Zieliński
140ece8080 WIP: build production images
Some checks failed
Build Docker Images / build-and-push (push) Failing after 1m30s
2025-10-12 20:17:33 +02:00
Michał Zieliński
b24aaab679 Add hangfire 2025-10-12 18:28:14 +02:00
Michał Zieliński
de5b8fbe16 Encrypt development settings with git-crypt
Some checks failed
Build Bimix / Build WebAPI and WebUI (push) Failing after 1m2s
2025-10-11 11:45:12 +02:00
34 changed files with 952 additions and 377 deletions

View File

@@ -1,4 +0,0 @@
# Do not edit this file. To specify the files to encrypt, create your own
# .gitattributes file in the directory where your files are.
* !filter !diff
*.gpg binary

2
.gitattributes vendored
View File

@@ -1,2 +0,0 @@
Bimix.API/appsettings.Development.json filter=git-crypt diff=git-crypt
Bimix.UI.Web/appsettings.Development.json filter=git-crypt diff=git-crypt

View File

@@ -0,0 +1,72 @@
// .gitea/scripts/replaceTokens.js
// Skanuje:
// - artifacts/api/appsettings.Production.json (jeśli jest)
// - artifacts/ui/appsettings.Production.json (jeśli jest)
// Tokeny: #{NAME}# -> wartość z VARIABLES/SECRETS (NAME: uppercased, '-'->'_')
// Dodatkowo: #{BUILDID}# -> RUN_ID (z ENV)
const fs = require('fs');
const path = require('path');
function replaceInFile(file, mapToken) {
let data = fs.readFileSync(file, 'utf8');
const re = /#\{(.*?)\}#/g;
let changed = false;
data = data.replace(re, (_, raw) => {
const token = (raw || '').replace(/-/g, '_').toUpperCase();
const val = mapToken(token);
if (val == null || val === '') return `#{${raw}}#`; // zostaw bez zmian, podbijemy błąd później
changed = true;
return String(val);
});
fs.writeFileSync(file, data, 'utf8');
return changed;
}
(async () => {
const secrets = JSON.parse(process.env.SECRETS || '{}');
const variables = JSON.parse(process.env.VARIABLES || '{}');
const RUN_ID = process.env.RUN_ID || process.env.GITHUB_RUN_ID || '';
const mapToken = (token) => {
if (token === 'BUILDID') return RUN_ID;
return (variables[token] != null ? variables[token] : secrets[token]);
};
const beRoot = path.resolve('artifacts');
const beFiles = [];
['api/appsettings.Production.json', 'ui/appsettings.Production.json'].forEach((name) => {
const p = path.join(beRoot, name);
if (fs.existsSync(p)) beFiles.push(p);
});
const files = beFiles;
if (files.length === 0) {
console.error('❌ No candidate files found to tokenize (artifacts/api or artifacts/ui appsettings.Production.json).');
process.exit(1);
}
console.log(`🔎 Tokenizing ${files.length} file(s)`);
const missing = new Set();
for (const file of files) {
replaceInFile(file, mapToken);
}
for (const file of files) {
const content = fs.readFileSync(file, 'utf8');
const reLeft = /#\{(.*?)\}#/g;
let m;
while ((m = reLeft.exec(content))) {
const token = (m[1] || '').replace(/-/g, '_').toUpperCase();
missing.add(token);
}
}
if (missing.size > 0) {
console.error(`❌ Missing values for tokens: ${Array.from(missing).join(', ')}`);
process.exit(1);
}
console.log('✅ Tokenization complete.');
})();

View File

@@ -0,0 +1,65 @@
name: Build Docker Images
on:
push:
branches:
- main
concurrency:
group: build-${{ github.ref }}
cancel-in-progress: false
jobs:
build-and-push:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: https://github.com/actions/checkout@v4
- name: Set up Docker Buildx
uses: https://github.com/docker/setup-buildx-action@v3
- name: Log in to Gitea Container Registry
run: |
echo "${{ secrets.REGISTRY_TOKEN }}" | docker login code.bim-it.pl -u "${{ secrets.REGISTRY_USER }}" --password-stdin
- name: Build and push API image
run: |
docker buildx build \
--platform linux/amd64 \
--label "org.opencontainers.image.source=https://code.bim-it.pl/mz/BimAI" \
-f BimAI.API/Dockerfile \
-t code.bim-it.pl/mz/bimai-api:latest \
-t code.bim-it.pl/mz/bimai-api:build-${{ github.run_id }} \
--push \
.
- name: Build and push UI image
run: |
docker buildx build \
--platform linux/amd64 \
--label "org.opencontainers.image.source=https://code.bim-it.pl/mz/BimAI" \
-f BimAI.UI.Web/Dockerfile \
-t code.bim-it.pl/mz/bimai-ui:latest \
-t code.bim-it.pl/mz/bimai-ui:build-${{ github.run_id }} \
--push \
.
- name: Output build info
run: |
echo "## Docker Images Built" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "**Build ID:** ${{ github.run_id }}" >> $GITHUB_STEP_SUMMARY
echo "**Commit:** ${{ github.sha }}" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "### Images pushed:" >> $GITHUB_STEP_SUMMARY
echo '```bash' >> $GITHUB_STEP_SUMMARY
echo "# Latest (for release)" >> $GITHUB_STEP_SUMMARY
echo "docker pull code.bim-it.pl/mz/bimai-api:latest" >> $GITHUB_STEP_SUMMARY
echo "docker pull code.bim-it.pl/mz/bimai-ui:latest" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "# Specific build (for rollback)" >> $GITHUB_STEP_SUMMARY
echo "docker pull code.bim-it.pl/mz/bimai-api:build-${{ github.run_id }}" >> $GITHUB_STEP_SUMMARY
echo "docker pull code.bim-it.pl/mz/bimai-ui:build-${{ github.run_id }}" >> $GITHUB_STEP_SUMMARY
echo '```' >> $GITHUB_STEP_SUMMARY

View File

@@ -0,0 +1,116 @@
name: Release Docker Images
on:
workflow_dispatch: {}
jobs:
release:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: https://github.com/actions/checkout@v4
- name: Setup Node.js
uses: https://github.com/actions/setup-node@v4
with:
node-version: 20
- name: Log in to Gitea Container Registry
run: |
echo "${{ secrets.REGISTRY_TOKEN }}" | docker login code.bim-it.pl -u "${{ secrets.REGISTRY_USER }}" --password-stdin
- name: Pull latest build artifacts (images)
run: |
echo "Pulling latest build images..."
docker pull code.bim-it.pl/mz/bimai-api:latest
docker pull code.bim-it.pl/mz/bimai-ui:latest
- name: Extract appsettings from images
run: |
mkdir -p artifacts/api artifacts/ui
# Extract from API image
docker create --name temp-api code.bim-it.pl/mz/bimai-api:latest
docker cp temp-api:/app/appsettings.Production.json artifacts/api/
docker rm temp-api
# Extract from UI image
docker create --name temp-ui code.bim-it.pl/mz/bimai-ui:latest
docker cp temp-ui:/app/appsettings.Production.json artifacts/ui/
docker rm temp-ui
- name: Show extracted configs (before tokenization)
run: |
echo "::group::API appsettings.Production.json (with placeholders)"
cat artifacts/api/appsettings.Production.json
echo "::endgroup::"
echo "::group::UI appsettings.Production.json (with placeholders)"
cat artifacts/ui/appsettings.Production.json
echo "::endgroup::"
- name: Tokenize appsettings
env:
SECRETS: ${{ toJson(secrets) }}
VARIABLES: ${{ toJson(vars) }}
RUN_ID: ${{ github.run_id }}
run: |
node .gitea/scripts/replaceTokens.js
- name: Show tokenized configs (after tokenization)
run: |
echo "::group::API appsettings.Production.json (tokenized, passwords hidden)"
cat artifacts/api/appsettings.Production.json | sed 's/Password=[^;]*/Password=***/g' | sed 's/"SecretKey":"[^"]*"/"SecretKey":"***"/g'
echo "::endgroup::"
echo "::group::UI appsettings.Production.json (tokenized)"
cat artifacts/ui/appsettings.Production.json
echo "::endgroup::"
- name: Rebuild images with tokenized configs
run: |
# API
cat > Dockerfile.release.api <<'EOF'
FROM code.bim-it.pl/mz/bimai-api:latest
LABEL org.opencontainers.image.source=https://code.bim-it.pl/mz/BimAI
COPY artifacts/api/appsettings.Production.json /app/
EOF
docker build -f Dockerfile.release.api \
-t code.bim-it.pl/mz/bimai-api:prod \
-t code.bim-it.pl/mz/bimai-api:release-${{ github.run_id }} \
.
# UI
cat > Dockerfile.release.ui <<'EOF'
FROM code.bim-it.pl/mz/bimai-ui:latest
LABEL org.opencontainers.image.source=https://code.bim-it.pl/mz/BimAI
COPY artifacts/ui/appsettings.Production.json /app/
EOF
docker build -f Dockerfile.release.ui \
-t code.bim-it.pl/mz/bimai-ui:prod \
-t code.bim-it.pl/mz/bimai-ui:release-${{ github.run_id }} \
.
- name: Push final images
run: |
docker push code.bim-it.pl/mz/bimai-api:prod
docker push code.bim-it.pl/mz/bimai-api:release-${{ github.run_id }}
docker push code.bim-it.pl/mz/bimai-ui:prod
docker push code.bim-it.pl/mz/bimai-ui:release-${{ github.run_id }}
- name: Output release info
run: |
echo "## Docker Images Released" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "**Release ID:** ${{ github.run_id }}" >> $GITHUB_STEP_SUMMARY
echo "**Commit:** ${{ github.sha }}" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "### 🚀 Production images ready to deploy:" >> $GITHUB_STEP_SUMMARY
echo '```bash' >> $GITHUB_STEP_SUMMARY
echo "# Production (latest release)" >> $GITHUB_STEP_SUMMARY
echo "docker pull code.bim-it.pl/mz/bimai-api:prod" >> $GITHUB_STEP_SUMMARY
echo "docker pull code.bim-it.pl/mz/bimai-ui:prod" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "# Specific release (for rollback)" >> $GITHUB_STEP_SUMMARY
echo "docker pull code.bim-it.pl/mz/bimai-api:release-${{ github.run_id }}" >> $GITHUB_STEP_SUMMARY
echo "docker pull code.bim-it.pl/mz/bimai-ui:release-${{ github.run_id }}" >> $GITHUB_STEP_SUMMARY
echo '```' >> $GITHUB_STEP_SUMMARY

View File

@@ -1,53 +0,0 @@
name: Build Bimix
on:
push:
branches:
- main
jobs:
build:
name: Build WebAPI and WebUI
runs-on: ubuntu-latest
env:
DOTNET_VERSION: '8.0.x'
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: ${{ env.DOTNET_VERSION }}
- name: Restore WebAPI
run: dotnet restore Bimix.API/Bimix.API.csproj
- name: Restore WebUI
run: dotnet restore Bimix.UI.Web/Bimix.UI.Web.csproj
- name: Build WebAPI
run: dotnet build Bimix.API/Bimix.API.csproj --configuration Release --no-restore
- name: Build WebUI
run: dotnet build Bimix.UI.Web/Bimix.UI.Web.csproj --configuration Release --no-restore
- name: Publish WebAPI
run: |
dotnet publish Bimix.API/Bimix.API.csproj \
--configuration Release \
--output ./publish/Bimix-WebAPI
- name: Publish Web (Blazor Server)
run: |
dotnet publish Bimix.UI.Web/Bimix.UI.Web.csproj \
--configuration Release \
--output ./publish/Bimix-Web
- name: Upload publish artifact
uses: actions/upload-artifact@v4
with:
name: bimix-artifacts
path: ./publish

9
.gitignore vendored
View File

@@ -24,10 +24,6 @@ Generated/
*.db-shm
*.db-wal
# Visual Studio Code
.vscode/
.vscode/*
# MAUI / Mobile (Xcode/iOS)
**/bin/
**/obj/
@@ -86,3 +82,8 @@ nunit-*.xml
.idea/indexLayout.xml
.idea/tasks.xml
.idea/.idea_modules
# VSCode - ignore personal settings but keep shared configs
.vscode/*
!.vscode/launch.json
!.vscode/tasks.json

47
.vscode/launch.json vendored Normal file
View File

@@ -0,0 +1,47 @@
{
"version": "0.2.0",
"configurations": [
{
"name": "API",
"type": "coreclr",
"request": "launch",
"preLaunchTask": "build-api",
"program": "${workspaceFolder}/BimAI.API/bin/Debug/net10.0/BimAI.API.dll",
"args": [],
"cwd": "${workspaceFolder}/BimAI.API",
"stopAtEntry": false,
"env": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
{
"name": "Web",
"type": "coreclr",
"request": "launch",
"preLaunchTask": "build-web",
"program": "${workspaceFolder}/BimAI.UI.Web/bin/Debug/net10.0/BimAI.UI.Web.dll",
"args": [],
"cwd": "${workspaceFolder}/BimAI.UI.Web",
"stopAtEntry": false,
"serverReadyAction": {
"action": "openExternally",
"pattern": "\\bNow listening on:\\s+(https?://\\S+)",
"uriFormat": "%s"
},
"env": {
"ASPNETCORE_ENVIRONMENT": "Development"
},
"launchBrowser": {
"enabled": true,
"args": "${auto-detect-url}",
"browser": [
{
"osx": "Google Chrome",
"linux": "chrome",
"windows": "chrome"
}
]
}
}
]
}

77
.vscode/tasks.json vendored Normal file
View File

@@ -0,0 +1,77 @@
{
"version": "2.0.0",
"tasks": [
{
"label": "build-api",
"command": "dotnet",
"type": "process",
"args": [
"build",
"${workspaceFolder}/BimAI.API/BimAI.API.csproj",
"/property:GenerateFullPaths=true",
"/consoleloggerparameters:NoSummary;ForceNoAlign"
],
"problemMatcher": "$msCompile"
},
{
"label": "build-web",
"command": "dotnet",
"type": "process",
"args": [
"build",
"${workspaceFolder}/BimAI.UI.Web/BimAI.UI.Web.csproj",
"/property:GenerateFullPaths=true",
"/consoleloggerparameters:NoSummary;ForceNoAlign"
],
"problemMatcher": "$msCompile"
},
{
"label": "publish-api",
"command": "dotnet",
"type": "process",
"args": [
"publish",
"${workspaceFolder}/BimAI.API/BimAI.API.csproj",
"/property:GenerateFullPaths=true",
"/consoleloggerparameters:NoSummary;ForceNoAlign"
],
"problemMatcher": "$msCompile"
},
{
"label": "publish-web",
"command": "dotnet",
"type": "process",
"args": [
"publish",
"${workspaceFolder}/BimAI.UI.Web/BimAI.UI.Web.csproj",
"/property:GenerateFullPaths=true",
"/consoleloggerparameters:NoSummary;ForceNoAlign"
],
"problemMatcher": "$msCompile"
},
{
"label": "watch-api",
"command": "dotnet",
"type": "process",
"args": [
"watch",
"run",
"--project",
"${workspaceFolder}/BimAI.API/BimAI.API.csproj"
],
"problemMatcher": "$msCompile"
},
{
"label": "watch-web",
"command": "dotnet",
"type": "process",
"args": [
"watch",
"run",
"--project",
"${workspaceFolder}/BimAI.UI.Web/BimAI.UI.Web.csproj"
],
"problemMatcher": "$msCompile"
}
]
}

View File

@@ -1,26 +1,27 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Google.Apis.Auth" Version="1.70.0" />
<PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="8.0.17" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="8.0.17">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.6.2" />
<PackageReference Include="System.IdentityModel.Tokens.Jwt" Version="8.12.1" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="8.0.10" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\BimAI.Application\BimAI.Application.csproj" />
<ProjectReference Include="..\BimAI.Infrastructure\BimAI.Infrastructure.csproj" />
</ItemGroup>
</Project>
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net10.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Google.Apis.Auth" Version="1.70.0" />
<PackageReference Include="Hangfire.AspNetCore" Version="1.8.21" />
<PackageReference Include="Hangfire.Core" Version="1.8.21" />
<PackageReference Include="Hangfire.SqlServer" Version="1.8.21" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="10.0.0-rc.1.25451.107">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="System.IdentityModel.Tokens.Jwt" Version="8.12.1" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="10.0.0-rc.1.25451.107" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\BimAI.Application\BimAI.Application.csproj" />
<ProjectReference Include="..\BimAI.Infrastructure\BimAI.Infrastructure.csproj" />
</ItemGroup>
</Project>

View File

@@ -1,6 +1,6 @@
@BimAI.API_HostAddress = http://localhost:5090
GET {{BimAI.API_HostAddress}}/weatherforecast/
Accept: application/json
###
@BimAI.API_HostAddress = http://localhost:5090
GET {{BimAI.API_HostAddress}}/weatherforecast/
Accept: application/json
###

48
BimAI.API/Dockerfile Normal file
View File

@@ -0,0 +1,48 @@
# Stage 1: Build
FROM mcr.microsoft.com/dotnet/sdk:10.0 AS build
WORKDIR /src
# Copy solution and all project files for restore
COPY BimAI.sln ./
COPY BimAI.API/BimAI.API.csproj BimAI.API/
COPY BimAI.Domain/BimAI.Domain.csproj BimAI.Domain/
COPY BimAI.Application/BimAI.Application.csproj BimAI.Application/
COPY BimAI.Infrastructure/BimAI.Infrastructure.csproj BimAI.Infrastructure/
# Restore dependencies
RUN dotnet restore BimAI.API/BimAI.API.csproj
# Copy all source code
COPY . .
# Build and publish
WORKDIR /src/BimAI.API
RUN dotnet publish -c Release -o /app/publish --no-restore
# Stage 2: Runtime
FROM mcr.microsoft.com/dotnet/aspnet:10.0 AS runtime
WORKDIR /app
# Install wget for health checks
RUN apt-get update && apt-get install -y wget && rm -rf /var/lib/apt/lists/*
# Set timezone
ENV TZ=Europe/Warsaw
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
# Copy published files
COPY --from=build /app/publish .
# Set environment variables
ENV ASPNETCORE_ENVIRONMENT=Production
ENV ASPNETCORE_URLS=http://0.0.0.0:7142
# Expose port
EXPOSE 7142
# Health check
HEALTHCHECK --interval=30s --timeout=3s --start-period=10s --retries=3 \
CMD wget --no-verbose --tries=1 --spider http://localhost:7142/health || exit 1
# Run the application
ENTRYPOINT ["dotnet", "BimAI.API.dll"]

View File

@@ -1,71 +1,138 @@
using System.Text;
using BimAI.API.Services;
using BimAI.Infrastructure.Data;
using BimAI.Infrastructure.Sync;
using Microsoft.EntityFrameworkCore;
using Microsoft.AspNetCore.Authentication.JwtBearer;
using Microsoft.IdentityModel.Tokens;
var builder = WebApplication.CreateBuilder(args);
var connectionString = builder.Configuration.GetConnectionString("DefaultConnection");
builder.Services.AddDbContext<BimAIDbContext>(options => options.UseSqlServer(connectionString));
builder.Services.AddScoped<ProductSyncService>();
builder.Services.AddHttpClient();
builder.Services.AddControllers();
builder.Services.AddEndpointsApiExplorer();
builder.Services.AddSwaggerGen();
// Start auth section
var jwtSettings = builder.Configuration.GetSection("JwtSettings");
var secretKey = jwtSettings["SecretKey"];
var issuer = jwtSettings["Issuer"];
var audience = jwtSettings["Audience"];
builder.Services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme)
.AddJwtBearer(options =>
{
options.TokenValidationParameters = new TokenValidationParameters
{
ValidateIssuer = true,
ValidateAudience = true,
ValidateLifetime = true,
ValidateIssuerSigningKey = true,
ValidIssuer = issuer,
ValidAudience = audience,
IssuerSigningKey = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(secretKey)),
ClockSkew = TimeSpan.Zero,
};
});
builder.Services.AddAuthentication();
builder.Services.AddScoped<GoogleAuthService>();
builder.Services.AddScoped<JwtTokenService>();
builder.Services.AddCors(options =>
{
options.AddPolicy("AllowAll", policy =>
{
policy.AllowAnyOrigin()
.AllowAnyMethod()
.AllowAnyHeader();
});
});
// End auth section
var app = builder.Build();
if (app.Environment.IsDevelopment())
{
app.UseSwagger();
app.UseSwaggerUI();
}
app.UseHttpsRedirection();
app.UseCors("AllowAll");
app.UseAuthorization();
app.UseAuthorization();
app.MapControllers();
using System.Text;
using BimAI.API.Services;
using BimAI.Infrastructure.Data;
using BimAI.Infrastructure.Jobs;
using BimAI.Infrastructure.Sync;
using Hangfire;
using Hangfire.SqlServer;
using Microsoft.EntityFrameworkCore;
using Microsoft.AspNetCore.Authentication.JwtBearer;
using Microsoft.IdentityModel.Tokens;
var builder = WebApplication.CreateBuilder(args);
var connectionString = builder.Configuration.GetConnectionString("DefaultConnection");
builder.Services.AddDbContext<BimAIDbContext>(options => options.UseSqlServer(connectionString));
builder.Services.AddScoped<ProductSyncService>();
builder.Services.AddHttpClient();
builder.Services.AddControllers();
// Start Hangfire section
builder.Services.AddHangfire(configuration => configuration
.SetDataCompatibilityLevel(CompatibilityLevel.Version_180)
.UseSimpleAssemblyNameTypeSerializer()
.UseRecommendedSerializerSettings()
.UseSqlServerStorage(builder.Configuration.GetConnectionString("HangfireConnection"),
new SqlServerStorageOptions
{
CommandBatchMaxTimeout = TimeSpan.FromMinutes(5),
SlidingInvisibilityTimeout = TimeSpan.FromMinutes(5),
QueuePollInterval = TimeSpan.Zero,
UseRecommendedIsolationLevel = true,
DisableGlobalLocks = true,
SchemaName = "Hangfire"
}
)
);
builder.Services.AddHangfireServer(options =>
{
options.ServerName = builder.Configuration["Hangfire:ServerName"];
options.WorkerCount = builder.Configuration.GetValue<int>("Hangfire:WorkerCount", 5);
});
// End Hangfire section
// Start auth section
var jwtSettings = builder.Configuration.GetSection("JwtSettings");
var secretKey = jwtSettings["SecretKey"];
var issuer = jwtSettings["Issuer"];
var audience = jwtSettings["Audience"];
builder.Services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme)
.AddJwtBearer(options =>
{
options.TokenValidationParameters = new TokenValidationParameters
{
ValidateIssuer = true,
ValidateAudience = true,
ValidateLifetime = true,
ValidateIssuerSigningKey = true,
ValidIssuer = issuer,
ValidAudience = audience,
IssuerSigningKey = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(secretKey)),
ClockSkew = TimeSpan.Zero,
};
});
builder.Services.AddAuthentication();
builder.Services.AddScoped<GoogleAuthService>();
builder.Services.AddScoped<JwtTokenService>();
builder.Services.AddCors(options =>
{
options.AddPolicy("AllowAll", policy =>
{
policy.AllowAnyOrigin()
.AllowAnyMethod()
.AllowAnyHeader();
});
});
// End auth section
var app = builder.Build();
// Auto-apply migrations on startup
using (var scope = app.Services.CreateScope())
{
var db = scope.ServiceProvider.GetRequiredService<BimAIDbContext>();
try
{
var pending = await db.Database.GetPendingMigrationsAsync();
if (pending.Any())
{
app.Logger.LogWarning("Applying {Count} pending migrations: {List}",
pending.Count(), string.Join(", ", pending));
await db.Database.MigrateAsync();
app.Logger.LogInformation("Migrations applied successfully.");
}
else
{
app.Logger.LogInformation("No pending migrations.");
}
}
catch (Exception ex)
{
app.Logger.LogCritical(ex, "Migration failed - application will not start.");
throw; // stop startup
}
}
app.UseHttpsRedirection();
app.UseCors("AllowAll");
app.UseHangfireDashboard(builder.Configuration["Hangfire:DashboardPath"] ?? "/hangfire", new DashboardOptions
{
AsyncAuthorization = new[] { new HangfireAuthorizationFilter() },
DashboardTitle = "BimAI - Job Dashboard"
});
app.UseAuthorization();
app.UseAuthorization();
app.MapControllers();
app.MapGet("/health", () => Results.Ok(new { status = "OK", timestamp = DateTime.UtcNow }))
.AllowAnonymous();
RecurringJob.AddOrUpdate<ProductSyncJob>(
"product-sync",
job => job.ExecuteAsync(),
Cron.Daily(2, 0), // Every day at 2:00 AM
new RecurringJobOptions
{
TimeZone = TimeZoneInfo.Local,
MisfireHandling = app.Environment.IsDevelopment()
? MisfireHandlingMode.Relaxed
: MisfireHandlingMode.Strict
});
app.Run();

View File

@@ -1,14 +1,14 @@
{
"profiles": {
"dev": {
"commandName": "Project",
"dotnetRunMessages": true,
"launchBrowser": true,
"launchUrl": "swagger",
"applicationUrl": "http://localhost:7142;http://0.0.0.0:7142",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
}
}
{
"profiles": {
"dev": {
"commandName": "Project",
"dotnetRunMessages": true,
"launchBrowser": true,
"launchUrl": "swagger",
"applicationUrl": "http://localhost:7142;http://0.0.0.0:7142",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
}
}
}

View File

@@ -0,0 +1,20 @@
using Hangfire.Dashboard;
namespace BimAI.API.Services;
public class HangfireAuthorizationFilter: IDashboardAsyncAuthorizationFilter
{
public Task<bool> AuthorizeAsync(DashboardContext context)
{
var httpContext = context.GetHttpContext();
var env = httpContext.RequestServices.GetService<IWebHostEnvironment>();
if (env != null && env.IsDevelopment())
{
return Task.FromResult(true);
}
var isAuthenticated = httpContext.User.Identity?.IsAuthenticated ?? false;
return Task.FromResult(isAuthenticated);
}
}

View File

@@ -1,27 +1,18 @@
{
"AllowedHosts": "*",
"ConnectionStrings": {
"DefaultConnection": "Server=localhost,1433;Database=bimai;User Id=sa;Password=9832&^*&huihj;TrustServerCertificate=True;"
},
"E5_CRM": {
"ApiKey": "7e50a8a5-f01f-4fbc-8c1b-59f3fc474bb5"
},
"GoogleAuth": {
"ClientId": "1037727384847-t1l2au6du34kdckamro81guklk17cjah.apps.googleusercontent.com"
},
"JwtSettings": {
"SecretKey": "BimAISuperSecretKeyThatMustBeAtLeast32CharactersLong123456789",
"Issuer": "BimAI.API",
"Audience": "BimAI.Clients",
"ExpiryDays": 7
},
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning",
"Microsoft.EntityFrameworkCore": "Warning",
"Microsoft.EntityFrameworkCore.Database.Command": "Warning",
"Microsoft.EntityFrameworkCore.Infrastructure": "Warning"
}
}
}
{
"ConnectionStrings": {
"DefaultConnection": "Server=localhost,1433;Database=bimai;User Id=sa;Password=BimAI_SA_2025x@;TrustServerCertificate=True;Encrypt=False",
"HangfireConnection": "Server=localhost,1433;Database=bimai;User Id=sa;Password=BimAI_SA_2025x@;TrustServerCertificate=True;Encrypt=False"
},
"E5_CRM": {
"ApiKey": "7e50a8a5-f01f-4fbc-8c1b-59f3fc474bb5"
},
"GoogleAuth": {
"ClientId": "896226687615-rhmqk06t1hvll1hh2gtje2u6nbadtras.apps.googleusercontent.com"
},
"JwtSettings": {
"SecretKey": "BimAISuperSecretKeyThatMustBeAtLeast32CharactersLong123456789"
},
"Hangfire": {
"ServerName": "BimAI-Development"
}
}

View File

@@ -0,0 +1,25 @@
{
"ConnectionStrings": {
"DefaultConnection": "",
"HangfireConnection": ""
},
"E5_CRM": {
"ApiKey": ""
},
"GoogleAuth": {
"ClientId": ""
},
"JwtSettings": {
"SecretKey": ""
},
"Hangfire": {
"ServerName": "BimAI-Production"
},
"Kestrel": {
"Endpoints": {
"Http": {
"Url": "http://0.0.0.0:7142"
}
}
}
}

View File

@@ -1,9 +1,21 @@
{
"AllowedHosts": "*",
"JwtSettings": {
"Issuer": "BimAI.API",
"Audience": "BimAI.Clients",
"ExpiryDays": 7
},
"Hangfire": {
"WorkerCount": 5,
"DashboardPath": "/hangfire"
},
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
"Microsoft.AspNetCore": "Warning",
"Microsoft.EntityFrameworkCore": "Warning",
"Microsoft.EntityFrameworkCore.Database.Command": "Warning",
"Microsoft.EntityFrameworkCore.Infrastructure": "Warning"
}
},
"AllowedHosts": "*"
}
}

View File

@@ -1,13 +1,13 @@
<Project Sdk="Microsoft.NET.Sdk">
<ItemGroup>
<ProjectReference Include="..\BimAI.Domain\BimAI.Domain.csproj" />
</ItemGroup>
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
</Project>
<Project Sdk="Microsoft.NET.Sdk">
<ItemGroup>
<ProjectReference Include="..\BimAI.Domain\BimAI.Domain.csproj" />
</ItemGroup>
<PropertyGroup>
<TargetFramework>net10.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
</Project>

View File

@@ -1,9 +1,9 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
</Project>
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net10.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
</Project>

View File

@@ -1,23 +1,23 @@
<Project Sdk="Microsoft.NET.Sdk">
<ItemGroup>
<ProjectReference Include="..\BimAI.Domain\BimAI.Domain.csproj" />
<ProjectReference Include="..\BimAI.Application\BimAI.Application.csproj" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="8.0.17" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="8.0.17" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="8.0.17">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
</ItemGroup>
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
</Project>
<Project Sdk="Microsoft.NET.Sdk">
<ItemGroup>
<ProjectReference Include="..\BimAI.Domain\BimAI.Domain.csproj" />
<ProjectReference Include="..\BimAI.Application\BimAI.Application.csproj" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="10.0.0-rc.1.25451.107" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="10.0.0-rc.1.25451.107" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="10.0.0-rc.1.25451.107">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
</ItemGroup>
<PropertyGroup>
<TargetFramework>net10.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
</Project>

View File

@@ -0,0 +1,31 @@
using BimAI.Infrastructure.Sync;
using Microsoft.Extensions.Logging;
namespace BimAI.Infrastructure.Jobs;
public class ProductSyncJob
{
private readonly ProductSyncService _productSyncService;
private readonly ILogger<ProductSyncJob> _logger;
public ProductSyncJob(ProductSyncService productSyncService, ILogger<ProductSyncJob> logger)
{
_productSyncService = productSyncService;
_logger = logger;
}
public async Task ExecuteAsync()
{
_logger.LogInformation("Starting product sync...");
try
{
await _productSyncService.RunAsync();
_logger.LogInformation("Product sync finished.");
} catch (Exception ex)
{
_logger.LogError(ex, "Error during product sync.");
throw;
}
}
}

View File

@@ -1,11 +1,11 @@
<Project Sdk="Microsoft.NET.Sdk.Razor">
<PropertyGroup>
<TargetFramework>net8.0-ios</TargetFramework>
<TargetFramework>net10.0-ios</TargetFramework>
<GenerateXcodeProject>true</GenerateXcodeProject>
<!-- Uncomment to also build the tizen app. You will need to install tizen by following this: https://github.com/Samsung/Tizen.NET -->
<!-- <TargetFrameworks>$(TargetFrameworks);net8.0-tizen</TargetFrameworks> -->
<!-- <TargetFrameworks>$(TargetFrameworks);net10.0-tizen</TargetFrameworks> -->
<!-- Note for MacCatalyst:
The default runtime is maccatalyst-x64, except in Release config, in which case the default is maccatalyst-x64;maccatalyst-arm64.
@@ -70,14 +70,14 @@
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Configuration" Version="9.0.9"/>
<PackageReference Include="Microsoft.Extensions.Configuration.Binder" Version="9.0.9"/>
<PackageReference Include="Microsoft.Extensions.Configuration.EnvironmentVariables" Version="9.0.9"/>
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="9.0.9"/>
<PackageReference Include="Microsoft.Extensions.Configuration" Version="10.0.0"/>
<PackageReference Include="Microsoft.Extensions.Configuration.Binder" Version="10.0.0"/>
<PackageReference Include="Microsoft.Extensions.Configuration.EnvironmentVariables" Version="10.0.0"/>
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="10.0.0"/>
<PackageReference Include="Microsoft.Maui.Controls" Version="$(MauiVersion)"/>
<PackageReference Include="Microsoft.Maui.Controls.Compatibility" Version="$(MauiVersion)"/>
<PackageReference Include="Microsoft.AspNetCore.Components.WebView.Maui" Version="$(MauiVersion)"/>
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="8.0.1"/>
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="10.0.0"/>
<PackageReference Include="MudBlazor" Version="8.8.0"/>
<PackageReference Include="ZXing.Net.MAUI" Version="0.4.0"/>
<PackageReference Include="ZXing.Net.MAUI.Controls" Version="0.4.0"/>

View File

@@ -1,30 +1,30 @@
<Project Sdk="Microsoft.NET.Sdk.Razor">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>
<ItemGroup>
<SupportedPlatform Include="browser" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Components.Web" Version="8.0.17" />
<PackageReference Include="MudBlazor" Version="8.8.0" />
<PackageReference Include="Microsoft.AspNetCore.WebUtilities" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Http" Version="8.0.0" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\BimAI.Domain\BimAI.Domain.csproj" />
<ProjectReference Include="..\BimAI.Application\BimAI.Application.csproj" />
</ItemGroup>
<ItemGroup>
<Folder Include="wwwroot\images\" />
</ItemGroup>
</Project>
<Project Sdk="Microsoft.NET.Sdk.Razor">
<PropertyGroup>
<TargetFramework>net10.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>
<ItemGroup>
<SupportedPlatform Include="browser" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Components.Web" Version="10.0.0-rc.1.25451.107" />
<PackageReference Include="MudBlazor" Version="8.8.0" />
<PackageReference Include="Microsoft.AspNetCore.WebUtilities" Version="10.0.0-rc.1.25451.107" />
<PackageReference Include="Microsoft.Extensions.Http" Version="10.0.0-rc.1.25451.107" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\BimAI.Domain\BimAI.Domain.csproj" />
<ProjectReference Include="..\BimAI.Application\BimAI.Application.csproj" />
</ItemGroup>
<ItemGroup>
<Folder Include="wwwroot\images\" />
</ItemGroup>
</Project>

View File

@@ -1,12 +1,12 @@
@using System.Net.Http
@using System.Net.Http.Json
@using Microsoft.AspNetCore.Components.Forms
@using Microsoft.AspNetCore.Components.Routing
@using Microsoft.AspNetCore.Components.Web
@using static Microsoft.AspNetCore.Components.Web.RenderMode
@using Microsoft.AspNetCore.Components.Web.Virtualization
@using Microsoft.JSInterop
@using BimAI.UI.Shared
@using System.Net.Http
@using System.Net.Http.Json
@using Microsoft.AspNetCore.Components.Forms
@using Microsoft.AspNetCore.Components.Routing
@using Microsoft.AspNetCore.Components.Web
@using static Microsoft.AspNetCore.Components.Web.RenderMode
@using Microsoft.AspNetCore.Components.Web.Virtualization
@using Microsoft.JSInterop
@using BimAI.UI.Shared
@using MudBlazor@using BimAI.Application.DTOModels
@using BimAI.Application.DTOModels.Common
@using BimAI.UI.Shared.Components

View File

@@ -28,7 +28,7 @@ async function handleAuthError(error, context = '') {
const errorMessage = error?.message || error?.type || error?.toString() || 'Unknown error';
const fullError = `${context}: ${errorMessage}`;
console.error('Google Auth Error:', { context, error, fullError });
await DotNet.invokeMethodAsync('Bimai.UI.Shared', 'OnGoogleSignInError', fullError);
await DotNet.invokeMethodAsync('BimAI.UI.Shared', 'OnGoogleSignInError', fullError);
}
async function fetchUserInfo(accessToken) {
@@ -39,7 +39,7 @@ async function fetchUserInfo(accessToken) {
if (!response.ok) {
const errorText = await response.text();
console.error('Failed to fetch user info:', errorText);
await DotNet.invokeMethodAsync('Bimai.UI.Shared', 'OnGoogleSignInError',
await DotNet.invokeMethodAsync('BimAI.UI.Shared', 'OnGoogleSignInError',
`Failed to fetch user info: HTTP ${response.status}`);
return null;
}
@@ -62,7 +62,7 @@ window.initGoogleSignIn = async function(clientId) {
try {
if (tokenResponse.error) {
console.error('Token response error:', tokenResponse.error);
await DotNet.invokeMethodAsync('Bimai.UI.Shared', 'OnGoogleSignInError',
await DotNet.invokeMethodAsync('BimAI.UI.Shared', 'OnGoogleSignInError',
tokenResponse.error);
return;
}
@@ -70,7 +70,7 @@ window.initGoogleSignIn = async function(clientId) {
const userInfo = await fetchUserInfo(tokenResponse.access_token);
if (!userInfo) return;
await DotNet.invokeMethodAsync('Bimai.UI.Shared', 'OnGoogleSignInSuccess',
await DotNet.invokeMethodAsync('BimAI.UI.Shared', 'OnGoogleSignInSuccess',
tokenResponse.access_token,
userInfo.name || '',
userInfo.email || '',
@@ -78,7 +78,7 @@ window.initGoogleSignIn = async function(clientId) {
);
} catch (error) {
console.error('Callback error:', error);
await DotNet.invokeMethodAsync('Bimai.UI.Shared', 'OnGoogleSignInError',
await DotNet.invokeMethodAsync('BimAI.UI.Shared', 'OnGoogleSignInError',
error.message || 'Unknown callback error');
} finally {
isSigningIn = false;
@@ -86,7 +86,7 @@ window.initGoogleSignIn = async function(clientId) {
},
error_callback: async (error) => {
console.error('OAuth flow error:', error);
await DotNet.invokeMethodAsync('Bimai.UI.Shared', 'OnGoogleSignInError',
await DotNet.invokeMethodAsync('BimAI.UI.Shared', 'OnGoogleSignInError',
error.type || 'OAuth flow error');
isSigningIn = false;
}
@@ -95,7 +95,7 @@ window.initGoogleSignIn = async function(clientId) {
return googleClient;
} catch (error) {
console.error('Initiaxcrun xctrace list deviceslization error:', error);
await DotNet.invokeMethodAsync('Bimai.UI.Shared', 'OnGoogleSignInError',
await DotNet.invokeMethodAsync('BimAI.UI.Shared', 'OnGoogleSignInError',
error.message || 'Failed to initialize Google Sign-In');
isSigningIn = false;
}
@@ -109,7 +109,7 @@ window.requestGoogleSignIn = async function() {
if (!googleClient) {
console.error('Google Sign-In not initialized');
await DotNet.invokeMethodAsync('Bimai.UI.Shared', 'OnGoogleSignInError',
await DotNet.invokeMethodAsync('BimAI.UI.Shared', 'OnGoogleSignInError',
'Google Sign-In not initialized. Call initGoogleSignIn first.');
return;
}

View File

@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<TargetFramework>net10.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>

48
BimAI.UI.Web/Dockerfile Normal file
View File

@@ -0,0 +1,48 @@
# Stage 1: Build
FROM mcr.microsoft.com/dotnet/sdk:10.0 AS build
WORKDIR /src
# Copy solution and all project files for restore
COPY BimAI.sln ./
COPY BimAI.UI.Web/BimAI.UI.Web.csproj BimAI.UI.Web/
COPY BimAI.UI.Shared/BimAI.UI.Shared.csproj BimAI.UI.Shared/
COPY BimAI.Domain/BimAI.Domain.csproj BimAI.Domain/
COPY BimAI.Application/BimAI.Application.csproj BimAI.Application/
# Restore dependencies
RUN dotnet restore BimAI.UI.Web/BimAI.UI.Web.csproj
# Copy all source code
COPY . .
# Build and publish
WORKDIR /src/BimAI.UI.Web
RUN dotnet publish -c Release -o /app/publish --no-restore
# Stage 2: Runtime
FROM mcr.microsoft.com/dotnet/aspnet:10.0 AS runtime
WORKDIR /app
# Install wget for health checks
RUN apt-get update && apt-get install -y wget && rm -rf /var/lib/apt/lists/*
# Set timezone
ENV TZ=Europe/Warsaw
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
# Copy published files
COPY --from=build /app/publish .
# Set environment variables
ENV ASPNETCORE_ENVIRONMENT=Production
ENV ASPNETCORE_URLS=http://0.0.0.0:7143
# Expose port
EXPOSE 7143
# Health check
HEALTHCHECK --interval=30s --timeout=3s --start-period=10s --retries=3 \
CMD wget --no-verbose --tries=1 --spider http://localhost:7143/health || exit 1
# Run the application
ENTRYPOINT ["dotnet", "BimAI.UI.Web.dll"]

View File

@@ -11,13 +11,14 @@ builder.Services.AddRazorComponents()
.AddInteractiveServerComponents();
builder.Services.AddMudServices();
builder.Services.AddSharedServices("http://localhost:7142");
var apiBaseUrl = builder.Configuration["ApiSettings:BaseUrl"]
?? throw new InvalidOperationException("ApiSettings:BaseUrl is not configured");
builder.Services.AddSharedServices(apiBaseUrl);
builder.Services.AddSingleton<IScannerService, NoOpScannerService>();
builder.Services.AddScoped<AuthService>();
var app = builder.Build();
if (!app.Environment.IsDevelopment())
@@ -30,6 +31,8 @@ app.UseHttpsRedirection();
app.UseStaticFiles();
app.UseAntiforgery();
app.MapGet("/health", () => Results.Ok(new { status = "OK", timestamp = DateTime.UtcNow }));
app.MapRazorComponents<App>()
.AddInteractiveServerRenderMode()
.AddAdditionalAssemblies(typeof(MainLayout).Assembly);

View File

@@ -1,11 +1,8 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
},
"GoogleAuth": {
"ClientId": "1037727384847-t1l2au6du34kdckamro81guklk17cjah.apps.googleusercontent.com"
"ClientId": "896226687615-rhmqk06t1hvll1hh2gtje2u6nbadtras.apps.googleusercontent.com"
},
"ApiSettings": {
"BaseUrl": "http://localhost:7142"
}
}

View File

@@ -0,0 +1,15 @@
{
"GoogleAuth": {
"ClientId": ""
},
"ApiSettings": {
"BaseUrl": ""
},
"Kestrel": {
"Endpoints": {
"Http": {
"Url": "http://0.0.0.0:7143"
}
}
}
}

View File

@@ -1,9 +1,9 @@
{
"AllowedHosts": "*",
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
},
"AllowedHosts": "*"
}
}

114
BimAI.sln
View File

@@ -1,58 +1,56 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.0.31903.59
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BimAI.Domain", "BimAI.Domain\BimAI.Domain.csproj", "{190E3B1F-C91F-430F-BE32-4E7221574D36}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BimAI.Application", "BimAI.Application\BimAI.Application.csproj", "{2E61A11C-851F-47D6-A8B6-329078CF1AFC}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BimAI.Infrastructure", "BimAI.Infrastructure\BimAI.Infrastructure.csproj", "{1049E8B5-6965-4CCD-A989-88E44D40BF48}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BimAI.API", "BimAI.API\BimAI.API.csproj", "{02FF9A1C-6D22-4CD1-8FE6-DD5BCDD621DA}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BimAI.UI.Shared", "BimAI.UI.Shared\BimAI.UI.Shared.csproj", "{0EB8CFFF-97BA-48D1-BEC1-2DFD6C934946}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BimAI.UI.Web", "BimAI.UI.Web\BimAI.UI.Web.csproj", "{7ACBFE74-E72C-4033-9172-30512233A518}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BimAI.UI.Mobile", "BimAI.UI.Mobile\BimAI.UI.Mobile.csproj", "{12FB8E56-08C1-47CF-B0FC-4BE9F01F020A}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{190E3B1F-C91F-430F-BE32-4E7221574D36}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{190E3B1F-C91F-430F-BE32-4E7221574D36}.Debug|Any CPU.Build.0 = Debug|Any CPU
{190E3B1F-C91F-430F-BE32-4E7221574D36}.Release|Any CPU.ActiveCfg = Release|Any CPU
{190E3B1F-C91F-430F-BE32-4E7221574D36}.Release|Any CPU.Build.0 = Release|Any CPU
{2E61A11C-851F-47D6-A8B6-329078CF1AFC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{2E61A11C-851F-47D6-A8B6-329078CF1AFC}.Debug|Any CPU.Build.0 = Debug|Any CPU
{2E61A11C-851F-47D6-A8B6-329078CF1AFC}.Release|Any CPU.ActiveCfg = Release|Any CPU
{2E61A11C-851F-47D6-A8B6-329078CF1AFC}.Release|Any CPU.Build.0 = Release|Any CPU
{1049E8B5-6965-4CCD-A989-88E44D40BF48}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{1049E8B5-6965-4CCD-A989-88E44D40BF48}.Debug|Any CPU.Build.0 = Debug|Any CPU
{1049E8B5-6965-4CCD-A989-88E44D40BF48}.Release|Any CPU.ActiveCfg = Release|Any CPU
{1049E8B5-6965-4CCD-A989-88E44D40BF48}.Release|Any CPU.Build.0 = Release|Any CPU
{02FF9A1C-6D22-4CD1-8FE6-DD5BCDD621DA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{02FF9A1C-6D22-4CD1-8FE6-DD5BCDD621DA}.Debug|Any CPU.Build.0 = Debug|Any CPU
{02FF9A1C-6D22-4CD1-8FE6-DD5BCDD621DA}.Release|Any CPU.ActiveCfg = Release|Any CPU
{02FF9A1C-6D22-4CD1-8FE6-DD5BCDD621DA}.Release|Any CPU.Build.0 = Release|Any CPU
{0EB8CFFF-97BA-48D1-BEC1-2DFD6C934946}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{0EB8CFFF-97BA-48D1-BEC1-2DFD6C934946}.Debug|Any CPU.Build.0 = Debug|Any CPU
{0EB8CFFF-97BA-48D1-BEC1-2DFD6C934946}.Release|Any CPU.ActiveCfg = Release|Any CPU
{0EB8CFFF-97BA-48D1-BEC1-2DFD6C934946}.Release|Any CPU.Build.0 = Release|Any CPU
{7ACBFE74-E72C-4033-9172-30512233A518}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{7ACBFE74-E72C-4033-9172-30512233A518}.Debug|Any CPU.Build.0 = Debug|Any CPU
{7ACBFE74-E72C-4033-9172-30512233A518}.Release|Any CPU.ActiveCfg = Release|Any CPU
{7ACBFE74-E72C-4033-9172-30512233A518}.Release|Any CPU.Build.0 = Release|Any CPU
{12FB8E56-08C1-47CF-B0FC-4BE9F01F020A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{12FB8E56-08C1-47CF-B0FC-4BE9F01F020A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{12FB8E56-08C1-47CF-B0FC-4BE9F01F020A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{12FB8E56-08C1-47CF-B0FC-4BE9F01F020A}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
EndGlobal

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.0.31903.59
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BimAI.Domain", "BimAI.Domain\BimAI.Domain.csproj", "{190E3B1F-C91F-430F-BE32-4E7221574D36}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BimAI.Application", "BimAI.Application\BimAI.Application.csproj", "{2E61A11C-851F-47D6-A8B6-329078CF1AFC}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BimAI.Infrastructure", "BimAI.Infrastructure\BimAI.Infrastructure.csproj", "{1049E8B5-6965-4CCD-A989-88E44D40BF48}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BimAI.API", "BimAI.API\BimAI.API.csproj", "{02FF9A1C-6D22-4CD1-8FE6-DD5BCDD621DA}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BimAI.UI.Shared", "BimAI.UI.Shared\BimAI.UI.Shared.csproj", "{0EB8CFFF-97BA-48D1-BEC1-2DFD6C934946}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BimAI.UI.Web", "BimAI.UI.Web\BimAI.UI.Web.csproj", "{7ACBFE74-E72C-4033-9172-30512233A518}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BimAI.UI.Mobile", "BimAI.UI.Mobile\BimAI.UI.Mobile.csproj", "{12FB8E56-08C1-47CF-B0FC-4BE9F01F020A}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{190E3B1F-C91F-430F-BE32-4E7221574D36}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{190E3B1F-C91F-430F-BE32-4E7221574D36}.Debug|Any CPU.Build.0 = Debug|Any CPU
{190E3B1F-C91F-430F-BE32-4E7221574D36}.Release|Any CPU.ActiveCfg = Release|Any CPU
{190E3B1F-C91F-430F-BE32-4E7221574D36}.Release|Any CPU.Build.0 = Release|Any CPU
{2E61A11C-851F-47D6-A8B6-329078CF1AFC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{2E61A11C-851F-47D6-A8B6-329078CF1AFC}.Debug|Any CPU.Build.0 = Debug|Any CPU
{2E61A11C-851F-47D6-A8B6-329078CF1AFC}.Release|Any CPU.ActiveCfg = Release|Any CPU
{2E61A11C-851F-47D6-A8B6-329078CF1AFC}.Release|Any CPU.Build.0 = Release|Any CPU
{1049E8B5-6965-4CCD-A989-88E44D40BF48}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{1049E8B5-6965-4CCD-A989-88E44D40BF48}.Debug|Any CPU.Build.0 = Debug|Any CPU
{1049E8B5-6965-4CCD-A989-88E44D40BF48}.Release|Any CPU.ActiveCfg = Release|Any CPU
{1049E8B5-6965-4CCD-A989-88E44D40BF48}.Release|Any CPU.Build.0 = Release|Any CPU
{02FF9A1C-6D22-4CD1-8FE6-DD5BCDD621DA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{02FF9A1C-6D22-4CD1-8FE6-DD5BCDD621DA}.Debug|Any CPU.Build.0 = Debug|Any CPU
{02FF9A1C-6D22-4CD1-8FE6-DD5BCDD621DA}.Release|Any CPU.ActiveCfg = Release|Any CPU
{02FF9A1C-6D22-4CD1-8FE6-DD5BCDD621DA}.Release|Any CPU.Build.0 = Release|Any CPU
{0EB8CFFF-97BA-48D1-BEC1-2DFD6C934946}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{0EB8CFFF-97BA-48D1-BEC1-2DFD6C934946}.Debug|Any CPU.Build.0 = Debug|Any CPU
{0EB8CFFF-97BA-48D1-BEC1-2DFD6C934946}.Release|Any CPU.ActiveCfg = Release|Any CPU
{0EB8CFFF-97BA-48D1-BEC1-2DFD6C934946}.Release|Any CPU.Build.0 = Release|Any CPU
{7ACBFE74-E72C-4033-9172-30512233A518}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{7ACBFE74-E72C-4033-9172-30512233A518}.Debug|Any CPU.Build.0 = Debug|Any CPU
{7ACBFE74-E72C-4033-9172-30512233A518}.Release|Any CPU.ActiveCfg = Release|Any CPU
{7ACBFE74-E72C-4033-9172-30512233A518}.Release|Any CPU.Build.0 = Release|Any CPU
{12FB8E56-08C1-47CF-B0FC-4BE9F01F020A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{12FB8E56-08C1-47CF-B0FC-4BE9F01F020A}.Release|Any CPU.ActiveCfg = Release|Any CPU
EndGlobalSection
EndGlobal