mirror of
https://github.com/spacebarchat/server.git
synced 2026-05-24 16:55:30 +00:00
Introduce CDN worker skeleton
This commit is contained in:
@@ -0,0 +1,8 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace Spacebar.Cdn.Worker.Controllers;
|
||||
|
||||
[ApiController]
|
||||
public class ImageResizeController : ControllerBase {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
using ArcaneLibs.Extensions;
|
||||
using ImageMagick;
|
||||
using Microsoft.AspNetCore.Mvc.ModelBinding.Binders;
|
||||
|
||||
namespace Spacebar.AdminApi.TestClient.Services.Helpers;
|
||||
|
||||
public class DefaultAvatarRenderer {
|
||||
public static readonly (byte r, byte g, byte b)[] DefaultAvatarColors = [
|
||||
(70, 73, 236),
|
||||
(150, 150, 150),
|
||||
(236, 52, 83),
|
||||
(211, 52, 236),
|
||||
(45, 202, 76),
|
||||
(236, 103, 52)
|
||||
];
|
||||
|
||||
public static readonly (byte r, byte g, byte b) SpacebarLogoColor = (0x01, 0x85, 0xFF);
|
||||
|
||||
// Slower at runtime, but doesnt depend on filesystem
|
||||
private static string GetDefaultAvatarSvg(byte r, byte g, byte b, byte rf = 0xff, byte gf = 0xff, byte bf = 0xff) {
|
||||
return $"""
|
||||
<svg width="512" height="512" viewBox="0 0 512 512" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<rect fill="#{r:X2}{g:X2}{b:X2}" width="512" height="512"/>
|
||||
<path fill="#{rf:X2}{gf:X2}{bf:X2}" fill-rule="evenodd" clip-rule="evenodd" d="M419.395 296.205C424.003 317.631 418.678 339.993 404.912 357.042C391.143 374.092 370.407 384 348.497 384H163.949C142.039 384 121.303 374.092 107.536 357.042C93.7677 339.993 88.4431 317.631 93.0509 296.205L125.547 145.08C127.06 138.042 131.891 132.176 138.508 129.344C145.124 126.511 152.703 127.065 158.837 130.829L256.223 190.583L353.609 130.829C359.743 127.065 367.322 126.511 373.938 129.344C380.555 132.176 385.386 138.042 386.899 145.08L419.395 296.205ZM344.729 261.348C344.729 250.399 335.855 241.523 324.91 241.523H286.727C275.782 241.523 266.91 250.399 266.91 261.348V299.542C266.91 310.491 275.782 319.365 286.727 319.365H324.91C335.855 319.365 344.729 310.491 344.729 299.542V261.348ZM245.536 261.348C245.536 250.399 236.664 241.523 225.719 241.523H187.536C176.591 241.523 167.717 250.399 167.717 261.348V299.542C167.717 310.491 176.591 319.365 187.536 319.365H225.719C236.664 319.365 245.536 310.491 245.536 299.542V261.348Z"/>
|
||||
</svg>
|
||||
""";
|
||||
}
|
||||
|
||||
public static async Task<MagickImageCollection> GetDefaultAvatarImage(byte r, byte g, byte b, byte rf = 0xff, byte gf = 0xff, byte bf = 0xff, int size = 4096) {
|
||||
var img = new MagickImageCollection(GetDefaultAvatarSvg(r, g, b, rf, gf, bf).AsBytes().ToArray(), new MagickReadSettings() {
|
||||
Width = (uint?)size,
|
||||
Height = (uint?)size,
|
||||
// Verbose = true,
|
||||
// ColorSpace = ColorSpace.RGB
|
||||
});
|
||||
return img;
|
||||
}
|
||||
|
||||
public static async Task<MemoryStream> GetDefaultAvatar(byte r, byte g, byte b, byte rf = 0xff, byte gf = 0xff, byte bf = 0xff, MagickFormat format = MagickFormat.Png,
|
||||
int size = 4096) {
|
||||
var img = await GetDefaultAvatarImage(r, g, b, rf, gf, bf, size);
|
||||
var ms = new MemoryStream();
|
||||
await img.WriteAsync(ms, format);
|
||||
ms.Position = 0;
|
||||
return ms;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
using System.ComponentModel;
|
||||
using ImageMagick;
|
||||
|
||||
namespace Spacebar.Cdn.Worker;
|
||||
|
||||
// Keep up to date with CDN!
|
||||
public static class Mimes {
|
||||
private static string PrintLogged(string msg, string mime) {
|
||||
Console.WriteLine($"{msg}: {mime}");
|
||||
return mime;
|
||||
}
|
||||
|
||||
public static MagickFormat GetFormatForExtension(string extension) {
|
||||
extension = extension.ToLower();
|
||||
// ban some values...
|
||||
// TODO: look for more
|
||||
if (extension
|
||||
// screen capture/write
|
||||
is "screenshot"
|
||||
or "win"
|
||||
or "clipboard"
|
||||
or "x" // read from/write to x11 server
|
||||
or "xwd" // x11 window dump
|
||||
or "dds" // MS DirectDraw surface
|
||||
or "open" // display image on screen, OSX only
|
||||
// printer stuff
|
||||
or "print"
|
||||
or "scan"
|
||||
or "scanx"
|
||||
// special
|
||||
or "dmr" // MagicCache media library, let's not...
|
||||
or "emf" // some microsoft meta format, windows only
|
||||
or "mpr" // Magick Persistent Registry - basically a resident in-memory image
|
||||
) throw new AccessViolationException("Disallowed extension: " + extension);
|
||||
|
||||
var matchingFormat = Enum.GetNames<MagickFormat>().FirstOrDefault(f => f.ToLower() == extension);
|
||||
if (string.IsNullOrWhiteSpace(matchingFormat)) throw new InvalidEnumArgumentException("Unknown format: " + extension);
|
||||
return Enum.TryParse(matchingFormat, out MagickFormat fmt) ? fmt : throw new InvalidEnumArgumentException("Unknown format: " + extension);
|
||||
}
|
||||
|
||||
public static string GetMime(MagickFormat fmt) => fmt switch {
|
||||
MagickFormat.Png => "image/png",
|
||||
MagickFormat.Jpeg => "image/jpeg",
|
||||
MagickFormat.Gif => "image/gif",
|
||||
MagickFormat.Bmp => "image/bmp",
|
||||
MagickFormat.Tiff => "image/tiff",
|
||||
MagickFormat.WebP => "image/webp",
|
||||
_ => PrintLogged("Unknown mime for format " + fmt.ToString() + "!", "application/octet-stream")
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,88 @@
|
||||
using System.Diagnostics;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Globalization;
|
||||
using ArcaneLibs;
|
||||
using ImageMagick;
|
||||
using Spacebar.AdminApi.TestClient.Services.Helpers;
|
||||
using Spacebar.Cdn.Worker;
|
||||
|
||||
var builder = WebApplication.CreateBuilder(args);
|
||||
|
||||
var sw = Stopwatch.StartNew();
|
||||
Console.WriteLine("Pre-initializing Magick.NET...");
|
||||
// OpenCL.IsEnabled = true;
|
||||
MagickNET.Initialize();
|
||||
// Console.WriteLine("==> Rendering default avatars...");
|
||||
// foreach (var (r, g, b) in DefaultAvatarRenderer.DefaultAvatarColors) {
|
||||
// var res = await DefaultAvatarRenderer.GetDefaultAvatar(r, g, b, size: 4096);
|
||||
// Console.WriteLine($" ==> #{r:X2}{g:X2}{b:X2} => {res.Length} bytes");
|
||||
// res.Position = 0;
|
||||
// await using (var fs = File.OpenWrite($"default-{r:X2}{g:X2}{b:X2}.png")) {
|
||||
// await res.CopyToAsync(fs);
|
||||
// fs.Flush();
|
||||
// fs.Close();
|
||||
// }
|
||||
// }
|
||||
|
||||
// byte skip = 8;
|
||||
// var re = new RainbowEnumerator(lengthFactor: 256, skip: skip);
|
||||
// var reFg = new RainbowEnumerator(lengthFactor: 512, skip: skip, offset: 128);
|
||||
// var magickCollection = new MagickImageCollection();
|
||||
// for (int i = 0; i < 255; i += skip) {
|
||||
// var sw2 = Stopwatch.StartNew();
|
||||
// var clr = re.Next();
|
||||
// var clrFg = reFg.Next();
|
||||
// var res = await DefaultAvatarRenderer.GetDefaultAvatarImage(clr.r, clr.g, clr.b, clrFg.r, clrFg.g, clrFg.b, size: 512);
|
||||
// Console.Write($" ==> #{clr.r:X2}{clr.g:X2}{clr.b:X2}/{clrFg.r:X2}{clrFg.g:X2}{clrFg.b:X2} ({i} => {magickCollection.Count + 1})... R");
|
||||
// res.Flatten();
|
||||
// Console.Write("F");
|
||||
// res.First().AnimationDelay = 4;
|
||||
// Console.Write("A");
|
||||
// magickCollection.Add(res.First());
|
||||
// Console.WriteLine(" => " + sw2.Elapsed);
|
||||
// }
|
||||
//
|
||||
// Console.WriteLine(" ==> Optimizing (1/2)...");
|
||||
// magickCollection.OptimizePlus();
|
||||
// Console.WriteLine(" ==> Optimizing (2/2)...");
|
||||
// magickCollection.OptimizeTransparency();
|
||||
// Console.WriteLine(" ==> Writing...");
|
||||
// await using (var fs = File.OpenWrite($"default-animated.gif")) {
|
||||
// await magickCollection.WriteAsync(fs, MagickFormat.Gif);
|
||||
// }
|
||||
//
|
||||
// Console.WriteLine(sw.Elapsed);
|
||||
// Environment.Exit(0);
|
||||
|
||||
// builder.WebHost.ConfigureKestrel(opts => opts.ListenUnixSocket(Environment.GetEnvironmentVariable("SOCKET_PATH")!));
|
||||
|
||||
builder.Services.AddControllers();
|
||||
var app = builder.Build();
|
||||
app.MapControllers();
|
||||
|
||||
app.MapGet("/defaultAvatar/{idx:int}.{ext}", async (HttpContext ctx, int idx, string ext) => {
|
||||
var (r, g, b) = DefaultAvatarRenderer.DefaultAvatarColors[idx % DefaultAvatarRenderer.DefaultAvatarColors.Length];
|
||||
var res = await DefaultAvatarRenderer.GetDefaultAvatar(r, g, b, size: ctx.Request.Query.ContainsKey("size") ? int.Parse(ctx.Request.Query["size"]!) : 4096,
|
||||
format: Mimes.GetFormatForExtension(ext));
|
||||
return Results.File(res, Mimes.GetMime(Mimes.GetFormatForExtension(ext)));
|
||||
});
|
||||
|
||||
// small easter egg internal stuff, maybe used someday :)
|
||||
app.MapGet("/defaultAvatar/_{bg:length(6)}.{ext}", async (HttpContext ctx, string bg, string ext) => {
|
||||
var (r, g, b) = (byte.Parse(bg[..2], NumberStyles.HexNumber), byte.Parse(bg[2..4], NumberStyles.HexNumber), byte.Parse(bg[4..6], NumberStyles.HexNumber));
|
||||
var res = await DefaultAvatarRenderer.GetDefaultAvatar(r, g, b, size: ctx.Request.Query.ContainsKey("size") ? int.Parse(ctx.Request.Query["size"]!) : 4096,
|
||||
format: Mimes.GetFormatForExtension(ext));
|
||||
return Results.File(res, Mimes.GetMime(Mimes.GetFormatForExtension(ext)));
|
||||
});
|
||||
|
||||
app.MapGet("/defaultAvatar/_{bg:length(6)}_{fg:length(6)}.{ext}", async (HttpContext ctx, string bg, string fg, string ext) => {
|
||||
var (r, g, b) = (byte.Parse(bg[..2], NumberStyles.HexNumber), byte.Parse(bg[2..4], NumberStyles.HexNumber), byte.Parse(bg[4..6], NumberStyles.HexNumber));
|
||||
var (rf, gf, bf) = (byte.Parse(fg[..2], NumberStyles.HexNumber), byte.Parse(fg[2..4], NumberStyles.HexNumber), byte.Parse(fg[4..6], NumberStyles.HexNumber));
|
||||
var res = await DefaultAvatarRenderer.GetDefaultAvatar(r, g, b, rf, gf, bf, size: ctx.Request.Query.ContainsKey("size") ? int.Parse(ctx.Request.Query["size"]!) : 4096,
|
||||
format: Mimes.GetFormatForExtension(ext));
|
||||
return Results.File(res, Mimes.GetMime(Mimes.GetFormatForExtension(ext)));
|
||||
});
|
||||
|
||||
app.MapGet("/*", async (ctx) => { });
|
||||
|
||||
app.Run();
|
||||
@@ -0,0 +1,14 @@
|
||||
{
|
||||
"$schema": "https://json.schemastore.org/launchsettings.json",
|
||||
"profiles": {
|
||||
"http": {
|
||||
"commandName": "Project",
|
||||
"dotnetRunMessages": true,
|
||||
"launchBrowser": false,
|
||||
"applicationUrl": "http://localhost:5280",
|
||||
"environmentVariables": {
|
||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net10.0</TargetFramework>
|
||||
<Nullable>enable</Nullable>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<RootNamespace>Spacebar.Cdn.Worker</RootNamespace>
|
||||
<RunAOTCompilation>true</RunAOTCompilation>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="ArcaneLibs" Version="1.0.1-preview.20260126-091403"/>
|
||||
<PackageReference Include="Magick.NET-Q16-HDRI-AnyCPU" Version="14.11.1"/>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Interop\Spacebar.Interop.Cdn.Abstractions\Spacebar.Interop.Cdn.Abstractions.csproj" Condition="'$(ContinuousIntegrationBuild)'!='true'"/>
|
||||
<PackageReference Include="Spacebar.Interop.Cdn.Abstractions" Version="*-preview*" Condition="'$(ContinuousIntegrationBuild)'=='true'"/>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Folder Include="Renderers\" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
@@ -0,0 +1,24 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net10.0</TargetFramework>
|
||||
<Nullable>enable</Nullable>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<RootNamespace>Spacebar.Cdn.Worker</RootNamespace>
|
||||
<RunAOTCompilation>true</RunAOTCompilation>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="ArcaneLibs" Version="1.0.1-preview.20260126-091403"/>
|
||||
<PackageReference Include="Magick.NET-Q16-HDRI-OpenMP-arm64" Version="14.11.1"/>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Interop\Spacebar.Interop.Cdn.Abstractions\Spacebar.Interop.Cdn.Abstractions.csproj" Condition="'$(ContinuousIntegrationBuild)'!='true'"/>
|
||||
<PackageReference Include="Spacebar.Interop.Cdn.Abstractions" Version="*-preview*" Condition="'$(ContinuousIntegrationBuild)'=='true'"/>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Folder Include="Renderers\" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
@@ -0,0 +1,24 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net10.0</TargetFramework>
|
||||
<Nullable>enable</Nullable>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<RootNamespace>Spacebar.Cdn.Worker</RootNamespace>
|
||||
<RunAOTCompilation>true</RunAOTCompilation>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="ArcaneLibs" Version="1.0.1-preview.20260126-091403"/>
|
||||
<PackageReference Include="Magick.NET-Q16-HDRI-OpenMP-x64" Version="14.11.1"/>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Interop\Spacebar.Interop.Cdn.Abstractions\Spacebar.Interop.Cdn.Abstractions.csproj" Condition="'$(ContinuousIntegrationBuild)'!='true'"/>
|
||||
<PackageReference Include="Spacebar.Interop.Cdn.Abstractions" Version="*-preview*" Condition="'$(ContinuousIntegrationBuild)'=='true'"/>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Folder Include="Renderers\" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
@@ -0,0 +1,24 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net10.0</TargetFramework>
|
||||
<Nullable>enable</Nullable>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<RootNamespace>Spacebar.Cdn.Worker</RootNamespace>
|
||||
<RunAOTCompilation>true</RunAOTCompilation>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="ArcaneLibs" Version="1.0.1-preview.20260126-091403"/>
|
||||
<PackageReference Include="Magick.NET-Q16-AnyCPU" Version="14.11.1"/>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Interop\Spacebar.Interop.Cdn.Abstractions\Spacebar.Interop.Cdn.Abstractions.csproj" Condition="'$(ContinuousIntegrationBuild)'!='true'"/>
|
||||
<PackageReference Include="Spacebar.Interop.Cdn.Abstractions" Version="*-preview*" Condition="'$(ContinuousIntegrationBuild)'=='true'"/>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Folder Include="Renderers\" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
@@ -0,0 +1,24 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net10.0</TargetFramework>
|
||||
<Nullable>enable</Nullable>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<RootNamespace>Spacebar.Cdn.Worker</RootNamespace>
|
||||
<RunAOTCompilation>true</RunAOTCompilation>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="ArcaneLibs" Version="1.0.1-preview.20260126-091403"/>
|
||||
<PackageReference Include="Magick.NET-Q16-OpenMP-arm64" Version="14.11.1"/>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Interop\Spacebar.Interop.Cdn.Abstractions\Spacebar.Interop.Cdn.Abstractions.csproj" Condition="'$(ContinuousIntegrationBuild)'!='true'"/>
|
||||
<PackageReference Include="Spacebar.Interop.Cdn.Abstractions" Version="*-preview*" Condition="'$(ContinuousIntegrationBuild)'=='true'"/>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Folder Include="Renderers\" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
@@ -0,0 +1,24 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net10.0</TargetFramework>
|
||||
<Nullable>enable</Nullable>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<RootNamespace>Spacebar.Cdn.Worker</RootNamespace>
|
||||
<RunAOTCompilation>true</RunAOTCompilation>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="ArcaneLibs" Version="1.0.1-preview.20260126-091403"/>
|
||||
<PackageReference Include="Magick.NET-Q16-OpenMP-x64" Version="14.11.1"/>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Interop\Spacebar.Interop.Cdn.Abstractions\Spacebar.Interop.Cdn.Abstractions.csproj" Condition="'$(ContinuousIntegrationBuild)'!='true'"/>
|
||||
<PackageReference Include="Spacebar.Interop.Cdn.Abstractions" Version="*-preview*" Condition="'$(ContinuousIntegrationBuild)'=='true'"/>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Folder Include="Renderers\" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
@@ -0,0 +1,24 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net10.0</TargetFramework>
|
||||
<Nullable>enable</Nullable>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<RootNamespace>Spacebar.Cdn.Worker</RootNamespace>
|
||||
<RunAOTCompilation>true</RunAOTCompilation>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="ArcaneLibs" Version="1.0.1-preview.20260126-091403"/>
|
||||
<PackageReference Include="Magick.NET-Q8-AnyCPU" Version="14.11.1"/>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Interop\Spacebar.Interop.Cdn.Abstractions\Spacebar.Interop.Cdn.Abstractions.csproj" Condition="'$(ContinuousIntegrationBuild)'!='true'"/>
|
||||
<PackageReference Include="Spacebar.Interop.Cdn.Abstractions" Version="*-preview*" Condition="'$(ContinuousIntegrationBuild)'=='true'"/>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Folder Include="Renderers\" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
@@ -0,0 +1,24 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net10.0</TargetFramework>
|
||||
<Nullable>enable</Nullable>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<RootNamespace>Spacebar.Cdn.Worker</RootNamespace>
|
||||
<RunAOTCompilation>true</RunAOTCompilation>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="ArcaneLibs" Version="1.0.1-preview.20260126-091403"/>
|
||||
<PackageReference Include="Magick.NET-Q8-OpenMP-arm64" Version="14.11.1"/>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Interop\Spacebar.Interop.Cdn.Abstractions\Spacebar.Interop.Cdn.Abstractions.csproj" Condition="'$(ContinuousIntegrationBuild)'!='true'"/>
|
||||
<PackageReference Include="Spacebar.Interop.Cdn.Abstractions" Version="*-preview*" Condition="'$(ContinuousIntegrationBuild)'=='true'"/>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Folder Include="Renderers\" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
@@ -0,0 +1,24 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net10.0</TargetFramework>
|
||||
<Nullable>enable</Nullable>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<RootNamespace>Spacebar.Cdn.Worker</RootNamespace>
|
||||
<RunAOTCompilation>true</RunAOTCompilation>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="ArcaneLibs" Version="1.0.1-preview.20260126-091403"/>
|
||||
<PackageReference Include="Magick.NET-Q8-OpenMP-x64" Version="14.11.1"/>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Interop\Spacebar.Interop.Cdn.Abstractions\Spacebar.Interop.Cdn.Abstractions.csproj" Condition="'$(ContinuousIntegrationBuild)'!='true'"/>
|
||||
<PackageReference Include="Spacebar.Interop.Cdn.Abstractions" Version="*-preview*" Condition="'$(ContinuousIntegrationBuild)'=='true'"/>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Folder Include="Renderers\" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
@@ -0,0 +1,17 @@
|
||||
{
|
||||
"Logging": {
|
||||
"LogLevel": {
|
||||
"Default": "Information",
|
||||
"Microsoft.AspNetCore.Routing.EndpointMiddleware": "Information",
|
||||
"Microsoft.AspNetCore.Routing.EndpointRoutingMiddleware": "Information",
|
||||
"Microsoft.AspNetCore": "Trace", //Warning
|
||||
"Microsoft.AspNetCore.Mvc": "Warning", //Warning
|
||||
"Microsoft.AspNetCore.HostFiltering": "Warning", //Warning
|
||||
"Microsoft.AspNetCore.Cors": "Warning", //Warning
|
||||
"Microsoft.AspNetCore.server.Kestrel": "Information",
|
||||
"Microsoft.AspNetCore.Routing.Matching.DfaMatcher": "Information",
|
||||
// "Microsoft.EntityFrameworkCore": "Warning"
|
||||
"Microsoft.EntityFrameworkCore.Database.Command": "Debug"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"Logging": {
|
||||
"LogLevel": {
|
||||
"Default": "Information",
|
||||
"Microsoft.AspNetCore": "Warning"
|
||||
}
|
||||
},
|
||||
"AllowedHosts": "*"
|
||||
}
|
||||
@@ -1,41 +1,42 @@
|
||||
<Solution>
|
||||
<Configurations>
|
||||
<Platform Name="Any CPU" />
|
||||
<Platform Name="x64" />
|
||||
<Platform Name="x86" />
|
||||
</Configurations>
|
||||
<Folder Name="/DataMappings/">
|
||||
<Project Path="DataMappings/Spacebar.DataMappings.AdminApi/Spacebar.DataMappings.AdminApi.csproj" />
|
||||
<Project Path="DataMappings/Spacebar.DataMappings.Generic/Spacebar.DataMappings.Generic.csproj" />
|
||||
</Folder>
|
||||
<Folder Name="/Interop/">
|
||||
<Project Path="Interop/Spacebar.Interop.Authentication.AspNetCore/Spacebar.Interop.Authentication.AspNetCore.csproj" />
|
||||
<Project Path="Interop/Spacebar.Interop.Authentication/Spacebar.Interop.Authentication.csproj" />
|
||||
<Project Path="Interop/Spacebar.Interop.Cdn.Abstractions/Spacebar.Interop.Cdn.Abstractions.csproj" />
|
||||
<Project Path="Interop/Spacebar.Interop.Cdn.Signing/Spacebar.Interop.Cdn.Signing.csproj" />
|
||||
<Project Path="Interop/Spacebar.Interop.Replication.Abstractions/Spacebar.Interop.Replication.Abstractions.csproj" />
|
||||
<Project Path="Interop/Spacebar.Interop.Replication.RabbitMq/Spacebar.Interop.Replication.RabbitMq.csproj" />
|
||||
<Project Path="Interop/Spacebar.Interop.Replication.UnixSocket/Spacebar.Interop.Replication.UnixSocket.csproj" />
|
||||
</Folder>
|
||||
<Folder Name="/Models/">
|
||||
<Project Path="Models/Spacebar.Models.AdminApi/Spacebar.Models.AdminApi.csproj" />
|
||||
<Project Path="Models/Spacebar.Models.Config/Spacebar.Models.Config.csproj" />
|
||||
<Project Path="Models/Spacebar.Models.Db/Spacebar.Models.Db.csproj" />
|
||||
<Project Path="Models/Spacebar.Models.Gateway/Spacebar.Models.Gateway.csproj" />
|
||||
<Project Path="Models/Spacebar.Models.Generic/Spacebar.Models.Generic.csproj" />
|
||||
</Folder>
|
||||
<Folder Name="/Utilities/">
|
||||
<Project Path="Utilities/ConfigTest/ConfigTest.csproj" />
|
||||
<Project Path="Utilities/DiscordEmojiConverter/DiscordEmojiConverter.csproj" />
|
||||
<Project Path="Utilities/Spacebar.AdminApi.PrepareTestData/Spacebar.AdminApi.PrepareTestData.csproj" />
|
||||
<Project Path="Utilities/Spacebar.AdminApi.TestClient/Spacebar.AdminApi.TestClient.csproj" />
|
||||
<Project Path="Utilities/Spacebar.AdminApiTest/Spacebar.AdminApiTest.csproj" />
|
||||
<Project Path="Utilities/Spacebar.Cdn.Fsck/Spacebar.Cdn.Fsck.csproj" />
|
||||
<Project Path="Utilities/Spacebar.Cdn.Migration/Spacebar.Cdn.Migration.csproj" />
|
||||
<Project Path="Utilities/Spacebar.CleanSettingsRows/Spacebar.CleanSettingsRows.csproj" />
|
||||
</Folder>
|
||||
<Project Path="Spacebar.AdminApi/Spacebar.AdminApi.csproj" />
|
||||
<Project Path="Spacebar.Cdn/Spacebar.Cdn.csproj" />
|
||||
<Project Path="Spacebar.Offload/Spacebar.Offload.csproj" />
|
||||
<Project Path="Spacebar.UApi/Spacebar.UApi.csproj" />
|
||||
<Configurations>
|
||||
<Platform Name="Any CPU"/>
|
||||
<Platform Name="x64"/>
|
||||
<Platform Name="x86"/>
|
||||
</Configurations>
|
||||
<Folder Name="/DataMappings/">
|
||||
<Project Path="DataMappings/Spacebar.DataMappings.AdminApi/Spacebar.DataMappings.AdminApi.csproj"/>
|
||||
<Project Path="DataMappings/Spacebar.DataMappings.Generic/Spacebar.DataMappings.Generic.csproj"/>
|
||||
</Folder>
|
||||
<Folder Name="/Interop/">
|
||||
<Project Path="Interop/Spacebar.Interop.Authentication.AspNetCore/Spacebar.Interop.Authentication.AspNetCore.csproj"/>
|
||||
<Project Path="Interop/Spacebar.Interop.Authentication/Spacebar.Interop.Authentication.csproj"/>
|
||||
<Project Path="Interop/Spacebar.Interop.Cdn.Abstractions/Spacebar.Interop.Cdn.Abstractions.csproj"/>
|
||||
<Project Path="Interop/Spacebar.Interop.Cdn.Signing/Spacebar.Interop.Cdn.Signing.csproj"/>
|
||||
<Project Path="Interop/Spacebar.Interop.Replication.Abstractions/Spacebar.Interop.Replication.Abstractions.csproj"/>
|
||||
<Project Path="Interop/Spacebar.Interop.Replication.RabbitMq/Spacebar.Interop.Replication.RabbitMq.csproj"/>
|
||||
<Project Path="Interop/Spacebar.Interop.Replication.UnixSocket/Spacebar.Interop.Replication.UnixSocket.csproj"/>
|
||||
</Folder>
|
||||
<Folder Name="/Models/">
|
||||
<Project Path="Models/Spacebar.Models.AdminApi/Spacebar.Models.AdminApi.csproj"/>
|
||||
<Project Path="Models/Spacebar.Models.Config/Spacebar.Models.Config.csproj"/>
|
||||
<Project Path="Models/Spacebar.Models.Db/Spacebar.Models.Db.csproj"/>
|
||||
<Project Path="Models/Spacebar.Models.Gateway/Spacebar.Models.Gateway.csproj"/>
|
||||
<Project Path="Models/Spacebar.Models.Generic/Spacebar.Models.Generic.csproj"/>
|
||||
</Folder>
|
||||
<Folder Name="/Utilities/">
|
||||
<Project Path="Utilities/ConfigTest/ConfigTest.csproj"/>
|
||||
<Project Path="Utilities/DiscordEmojiConverter/DiscordEmojiConverter.csproj"/>
|
||||
<Project Path="Utilities/Spacebar.AdminApi.PrepareTestData/Spacebar.AdminApi.PrepareTestData.csproj"/>
|
||||
<Project Path="Utilities/Spacebar.AdminApi.TestClient/Spacebar.AdminApi.TestClient.csproj"/>
|
||||
<Project Path="Utilities/Spacebar.AdminApiTest/Spacebar.AdminApiTest.csproj"/>
|
||||
<Project Path="Utilities/Spacebar.Cdn.Fsck/Spacebar.Cdn.Fsck.csproj"/>
|
||||
<Project Path="Utilities/Spacebar.Cdn.Migration/Spacebar.Cdn.Migration.csproj"/>
|
||||
<Project Path="Utilities/Spacebar.CleanSettingsRows/Spacebar.CleanSettingsRows.csproj"/>
|
||||
</Folder>
|
||||
<Project Path="Spacebar.AdminApi/Spacebar.AdminApi.csproj"/>
|
||||
<Project Path="Spacebar.Cdn.Worker/Spacebar.Cdn.Worker.Q16-HDRI.x86_64.csproj" DisplayName="Spacebar.Cdn.Worker"/>
|
||||
<Project Path="Spacebar.Cdn/Spacebar.Cdn.csproj"/>
|
||||
<Project Path="Spacebar.Offload/Spacebar.Offload.csproj"/>
|
||||
<Project Path="Spacebar.UApi/Spacebar.UApi.csproj"/>
|
||||
</Solution>
|
||||
|
||||
@@ -7,6 +7,29 @@ using ArcaneLibs;
|
||||
using ArcaneLibs.Extensions;
|
||||
using System.Text.Json;
|
||||
|
||||
// sync versions for CDN worker
|
||||
{
|
||||
Console.WriteLine("==> Ensuring CDN worker dependencies are in sync...");
|
||||
var origContent = await File.ReadAllTextAsync("Spacebar.Cdn.Worker/Spacebar.Cdn.Worker.Q16-HDRI.x86_64.csproj");
|
||||
var depToReplace = "Magick.NET-Q16-HDRI-OpenMP-x64";
|
||||
(string Project, string Dependency)[] replaceTargets = [
|
||||
// ("Spacebar.Cdn.Worker/Spacebar.Cdn.Worker.Q16-HDRI.x86_64.csproj", "Magick.NET-Q16-HDRI-OpenMP-x64"), // source
|
||||
("Spacebar.Cdn.Worker/Spacebar.Cdn.Worker.Q16.x86_64.csproj", "Magick.NET-Q16-OpenMP-x64"),
|
||||
("Spacebar.Cdn.Worker/Spacebar.Cdn.Worker.Q8.x86_64.csproj", "Magick.NET-Q8-OpenMP-x64"),
|
||||
("Spacebar.Cdn.Worker/Spacebar.Cdn.Worker.Q16-HDRI.aarch64.csproj", "Magick.NET-Q16-HDRI-OpenMP-arm64"),
|
||||
("Spacebar.Cdn.Worker/Spacebar.Cdn.Worker.Q16.aarch64.csproj", "Magick.NET-Q16-OpenMP-arm64"),
|
||||
("Spacebar.Cdn.Worker/Spacebar.Cdn.Worker.Q8.aarch64.csproj", "Magick.NET-Q8-OpenMP-arm64"),
|
||||
("Spacebar.Cdn.Worker/Spacebar.Cdn.Worker.Q16-HDRI.AnyCPU.csproj", "Magick.NET-Q16-HDRI-AnyCPU"),
|
||||
("Spacebar.Cdn.Worker/Spacebar.Cdn.Worker.Q16.AnyCPU.csproj", "Magick.NET-Q16-AnyCPU"),
|
||||
("Spacebar.Cdn.Worker/Spacebar.Cdn.Worker.Q8.AnyCPU.csproj", "Magick.NET-Q8-AnyCPU"),
|
||||
];
|
||||
|
||||
foreach (var target in replaceTargets) {
|
||||
Console.WriteLine($" ==> {target.Project} -> {target.Dependency}");
|
||||
await File.WriteAllTextAsync(target.Project, origContent.Replace(depToReplace, target.Dependency));
|
||||
}
|
||||
}
|
||||
|
||||
Console.WriteLine("==> Getting outputs...");
|
||||
var outs = JsonSerializer.Deserialize<string[]>(Util.GetCommandOutputSync("nix", $"eval --json .#packages.x86_64-linux --apply builtins.attrNames", silent: true, stderr: false));
|
||||
if (args.Length > 0) {
|
||||
|
||||
Reference in New Issue
Block a user