From ee4d57aa4c32a81be78d1f9382b61a043fae90d1 Mon Sep 17 00:00:00 2001 From: Miroljub Date: Tue, 3 Dec 2024 09:59:07 +0100 Subject: [PATCH] Try build container image --- .github/workflows/deploy.yaml | 29 +++++++++++- .../ResQueue/ResQueue.Standalone/Program.cs | 47 +++++++++++++++++++ .../Properties/launchSettings.json | 23 +++++++++ .../ResQueue.Standalone.csproj | 24 ++++++++++ .../appsettings.Development.json | 14 ++++++ .../ResQueue.Standalone/appsettings.json | 9 ++++ backend/ResQueue/ResQueue.sln | 6 +++ 7 files changed, 150 insertions(+), 2 deletions(-) create mode 100644 backend/ResQueue/ResQueue.Standalone/Program.cs create mode 100644 backend/ResQueue/ResQueue.Standalone/Properties/launchSettings.json create mode 100644 backend/ResQueue/ResQueue.Standalone/ResQueue.Standalone.csproj create mode 100644 backend/ResQueue/ResQueue.Standalone/appsettings.Development.json create mode 100644 backend/ResQueue/ResQueue.Standalone/appsettings.json diff --git a/.github/workflows/deploy.yaml b/.github/workflows/deploy.yaml index b792380..9f0a90c 100644 --- a/.github/workflows/deploy.yaml +++ b/.github/workflows/deploy.yaml @@ -7,8 +7,9 @@ jobs: Deploy: runs-on: ubuntu-latest env: - NuGetApiKey: ${{ secrets.NUGET_API_KEY }} - IsCI: "true" + ResQueueImageVersion: "1.0.9" + DockerRegistry: ghcr.io + DockerRepository: filipbekic01/resqueue steps: - name: Checkout the repository uses: actions/checkout@v2 @@ -42,3 +43,27 @@ jobs: - name: Push the NuGet package working-directory: backend/ResQueue/ResQueue run: dotnet nuget push bin/Release/*.nupkg --api-key ${{ secrets.NUGET_API_KEY }} --source https://nuget.org + + - name: Login to GitHub Container Registry + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Publish x64 image + working-directory: backend/ResQueue/ResQueue.Standalone + run: dotnet publish --os linux --arch x64 /t:PublishContainer -p:PublishToGithubRegistry=true -p:ContainerImageTag=${ResQueueImageVersion} -p:ContainerRepository=${DockerRepository} -p:ContainerRegistry=${DockerRegistry} -pContainerImageTag=${ResQueueImageVersion}-x64 + + - name: Publish arm64 image + working-directory: backend/ResQueue/ResQueue.Standalone + run: dotnet publish --os linux --arch arm64 /t:PublishContainer -p:PublishToGithubRegistry=true -p:ContainerImageTag=${ResQueueImageVersion} -p:ContainerRepository=${DockerRepository} -p:ContainerRegistry=${DockerRegistry} -pContainerImageTag=${ResQueueImageVersion}-arm64 + + - name: Publish image manifest + run: | + set -e + docker manifest create "${DockerRegistry}/${DockerRepository}:${ResQueueImageVersion}" "${DockerRegistry}/${DockerRepository}:${ResQueueImageVersion}-x64" "${DockerRegistry}/${DockerRepository}:${ResQueueImageVersion}-arm64" + docker manifest tag "${DockerRegistry}/${DockerRepository}:${ResQueueImageVersion}" "${DockerRegistry}/${DockerRepository}:latest" + + docker manifest push "${DockerRegistry}/${DockerRepository}:${ResQueueImageVersion}" + docker manifest push "${DockerRegistry}/${DockerRepository}:latest" diff --git a/backend/ResQueue/ResQueue.Standalone/Program.cs b/backend/ResQueue/ResQueue.Standalone/Program.cs new file mode 100644 index 0000000..e14a2f3 --- /dev/null +++ b/backend/ResQueue/ResQueue.Standalone/Program.cs @@ -0,0 +1,47 @@ +using MassTransit; +using ResQueue; +using ResQueue.Enums; + +var builder = WebApplication.CreateBuilder(args); + +var sqlEngineConfig = builder.Configuration.GetRequiredSection("Resqueue:SqlEngine").Value; +if (string.IsNullOrEmpty(sqlEngineConfig)) +{ + throw new Exception("Missing SqlEngine configuration in Resqueue:SqlEngine."); +} + +var sqlEngine = Enum.Parse(sqlEngineConfig); + +builder.Services.AddResQueue(opt => opt.SqlEngine = sqlEngine); + +builder.Services.AddOptions().Configure(options => +{ + builder.Configuration.Bind("SqlTransport", options); +}); + +if (sqlEngine == ResQueueSqlEngine.Postgres) +{ + builder.Services.AddPostgresMigrationHostedService(); +} +else +{ + builder.Services.AddSqlServerMigrationHostedService(); +} + +builder.Services.AddMassTransit(mt => +{ + if (sqlEngine == ResQueueSqlEngine.Postgres) + { + mt.UsingPostgres(); + } + else + { + mt.UsingSqlServer(); + } +}); + +var app = builder.Build(); + +app.UseResQueue(""); + +app.Run(); \ No newline at end of file diff --git a/backend/ResQueue/ResQueue.Standalone/Properties/launchSettings.json b/backend/ResQueue/ResQueue.Standalone/Properties/launchSettings.json new file mode 100644 index 0000000..ccd6f32 --- /dev/null +++ b/backend/ResQueue/ResQueue.Standalone/Properties/launchSettings.json @@ -0,0 +1,23 @@ +{ + "$schema": "https://json.schemastore.org/launchsettings.json", + "profiles": { + "http": { + "commandName": "Project", + "dotnetRunMessages": true, + "launchBrowser": true, + "applicationUrl": "http://localhost:5236", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + }, + "https": { + "commandName": "Project", + "dotnetRunMessages": true, + "launchBrowser": true, + "applicationUrl": "https://localhost:7227;http://localhost:5236", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + } + } +} diff --git a/backend/ResQueue/ResQueue.Standalone/ResQueue.Standalone.csproj b/backend/ResQueue/ResQueue.Standalone/ResQueue.Standalone.csproj new file mode 100644 index 0000000..9ecba31 --- /dev/null +++ b/backend/ResQueue/ResQueue.Standalone/ResQueue.Standalone.csproj @@ -0,0 +1,24 @@ + + + + net9.0 + enable + enable + + true + alpine + + 1.0.9 + $(RuntimeIdentifier.Split('-')[1]) + + + + + + + + + + + + diff --git a/backend/ResQueue/ResQueue.Standalone/appsettings.Development.json b/backend/ResQueue/ResQueue.Standalone/appsettings.Development.json new file mode 100644 index 0000000..5b770aa --- /dev/null +++ b/backend/ResQueue/ResQueue.Standalone/appsettings.Development.json @@ -0,0 +1,14 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft.AspNetCore": "Warning" + } + }, + "SqlTransport": { + "ConnectionString": "Host=localhost;Database=sandbox100;Username=postgres;Password=postgres;" + }, + "ResQueue": { + "SqlEngine": "Postgres" + } +} diff --git a/backend/ResQueue/ResQueue.Standalone/appsettings.json b/backend/ResQueue/ResQueue.Standalone/appsettings.json new file mode 100644 index 0000000..51c11b2 --- /dev/null +++ b/backend/ResQueue/ResQueue.Standalone/appsettings.json @@ -0,0 +1,9 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Warning", + "Microsoft.AspNetCore": "Warning" + } + }, + "AllowedHosts": "*" +} diff --git a/backend/ResQueue/ResQueue.sln b/backend/ResQueue/ResQueue.sln index 9b01b5e..33240be 100644 --- a/backend/ResQueue/ResQueue.sln +++ b/backend/ResQueue/ResQueue.sln @@ -4,6 +4,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ResQueue", "ResQueue\ResQue EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WebSample", "WebSample\WebSample.csproj", "{DBAAEB7E-3616-4BCD-B2C0-736EEEABF85C}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ResQueue.Standalone", "ResQueue.Standalone\ResQueue.Standalone.csproj", "{2619AD4E-B31F-4CB4-AE3B-E0B988E1F6CE}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -18,5 +20,9 @@ Global {DBAAEB7E-3616-4BCD-B2C0-736EEEABF85C}.Debug|Any CPU.Build.0 = Debug|Any CPU {DBAAEB7E-3616-4BCD-B2C0-736EEEABF85C}.Release|Any CPU.ActiveCfg = Release|Any CPU {DBAAEB7E-3616-4BCD-B2C0-736EEEABF85C}.Release|Any CPU.Build.0 = Release|Any CPU + {2619AD4E-B31F-4CB4-AE3B-E0B988E1F6CE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {2619AD4E-B31F-4CB4-AE3B-E0B988E1F6CE}.Debug|Any CPU.Build.0 = Debug|Any CPU + {2619AD4E-B31F-4CB4-AE3B-E0B988E1F6CE}.Release|Any CPU.ActiveCfg = Release|Any CPU + {2619AD4E-B31F-4CB4-AE3B-E0B988E1F6CE}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection EndGlobal