Skip to content

Commit

Permalink
Try build container image
Browse files Browse the repository at this point in the history
  • Loading branch information
miroljub1995 committed Dec 3, 2024
1 parent 47a742a commit ee4d57a
Show file tree
Hide file tree
Showing 7 changed files with 150 additions and 2 deletions.
29 changes: 27 additions & 2 deletions .github/workflows/deploy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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"
47 changes: 47 additions & 0 deletions backend/ResQueue/ResQueue.Standalone/Program.cs
Original file line number Diff line number Diff line change
@@ -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<ResQueueSqlEngine>(sqlEngineConfig);

builder.Services.AddResQueue(opt => opt.SqlEngine = sqlEngine);

builder.Services.AddOptions<SqlTransportOptions>().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();
Original file line number Diff line number Diff line change
@@ -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"
}
}
}
}
24 changes: 24 additions & 0 deletions backend/ResQueue/ResQueue.Standalone/ResQueue.Standalone.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>net9.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>

<EnableSdkContainerSupport>true</EnableSdkContainerSupport>
<ContainerFamily>alpine</ContainerFamily>

<ContainerImageTag Condition="'$(PublishToGithubRegistry)' != 'true'">1.0.9</ContainerImageTag>
<Arch Condition="'$(RuntimeIdentifier)' != ''">$(RuntimeIdentifier.Split('-')[1])</Arch>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\ResQueue\ResQueue.csproj"/>
</ItemGroup>

<ItemGroup>
<PackageReference Include="MassTransit.SqlTransport.PostgreSQL" Version="8.3.2"/>
<PackageReference Include="MassTransit.SqlTransport.SqlServer" Version="8.3.2"/>
</ItemGroup>

</Project>
14 changes: 14 additions & 0 deletions backend/ResQueue/ResQueue.Standalone/appsettings.Development.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
},
"SqlTransport": {
"ConnectionString": "Host=localhost;Database=sandbox100;Username=postgres;Password=postgres;"
},
"ResQueue": {
"SqlEngine": "Postgres"
}
}
9 changes: 9 additions & 0 deletions backend/ResQueue/ResQueue.Standalone/appsettings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"Logging": {
"LogLevel": {
"Default": "Warning",
"Microsoft.AspNetCore": "Warning"
}
},
"AllowedHosts": "*"
}
6 changes: 6 additions & 0 deletions backend/ResQueue/ResQueue.sln
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

0 comments on commit ee4d57a

Please sign in to comment.