diff --git a/.build.Nuke/Build.Compile.cs b/.build.Nuke/Build.Compile.cs
index e784aba811db1ce7120b12cda85a8dd1d1f6bd8d..d298ccec510362cb11563af654a8d7cf5ffbbf68 100644
--- a/.build.Nuke/Build.Compile.cs
+++ b/.build.Nuke/Build.Compile.cs
@@ -27,7 +27,7 @@ sealed partial class Build : NukeBuild
});
Target Restore => td => td
- .DependsOn(Clean)
+ .After(Clean)
.Executes(() =>
{
_ = DotNetRestore(s => s
@@ -35,7 +35,7 @@ sealed partial class Build : NukeBuild
});
Target Compile => td => td
- .DependsOn(Restore)
+ .After(Restore)
.Executes(() =>
{
Log.Debug("Configuration {Configuration}", configurationSet);
diff --git a/.build.Nuke/Build.Container.cs b/.build.Nuke/Build.Container.cs
index 888d83183148df3af2195ce8538d68046ee558f9..5d7849a5b092bd7d29886d7067d707d26a37976c 100644
--- a/.build.Nuke/Build.Container.cs
+++ b/.build.Nuke/Build.Container.cs
@@ -3,6 +3,7 @@ using Nuke.Common.Tooling;
using Nuke.Common.Tools.Docker;
using Serilog;
using System;
+using System.Collections.Generic;
using System.Linq;
namespace SuCoS;
@@ -16,64 +17,72 @@ sealed partial class Build : NukeBuild
[Parameter("GitLab Project CI_REGISTRY_IMAGE")]
readonly string containerRegistryImage;
- string ContainerRegistryImage => containerRegistryImage ?? $"registry.gitlab.com/{GitLab?.ProjectPath}";
+ string ContainerRegistryImage => containerRegistryImage ?? "sucos";
[Parameter("GitLab Project Full Address")]
readonly string containerDefaultRID = "linux-x64";
+ ///
+ /// Generate the Container image
+ ///
public Target CreateContainer => td => td
- .DependsOn(Publish)
+ .After(Publish)
.DependsOn(CheckNewCommits)
.OnlyWhenStatic(() => runtimeIdentifier != "win-x64")
.Executes(() =>
{
- var tagsOriginal = new[] { "latest", Version, VersionMajorMinor, VersionMajor };
- var tags = tagsOriginal.Select(tag => $"{runtimeIdentifier}-{tag}").ToList();
- if (containerDefaultRID == runtimeIdentifier)
- {
- tags.AddRange(tagsOriginal);
- }
+ var tags = ContainerTags();
- // Build the Container image
- _ = DockerTasks.DockerBuild(dbs => dbs
- .SetPath(PublishDirectory)
- .SetFile($"./Dockerfile")
- .SetTag(tags.Select(tag => $"{ContainerRegistryImage}:{tag}").ToArray())
- .SetBuildArg([$"BASE_IMAGE={BaseImage}", $"COPY_PATH={PublishDirectory}"])
- .SetProcessLogger((outputType, output) =>
- {
- // A bug this log type value
- if (outputType != OutputType.Std)
- Log.Information(output);
- else
- Log.Error(output);
- })
- );
-
- // Log in to the Docker registry
- _ = DockerTasks.DockerLogin(_ => _
- .SetServer("registry.gitlab.com")
- .SetUsername("gitlab-ci-token")
- .SetPassword(GitLab.JobToken)
- );
-
- // Push the container images
- foreach (var tag in tags)
- {
- _ = DockerTasks.DockerPush(_ => _
- .SetName($"{ContainerRegistryImage}:{tag}")
- );
-
- // Create a link to the GitLab release
- var tagLink = GitLabAPIUrl($"?orderBy=NAME&sort=asc&search[]={tag}");
- GitLabCreateReleaseLink($"docker-{tag}", tagLink);
- }
+ // Build the Container image
+ _ = DockerTasks.DockerImageBuild(dbs => dbs
+ .SetPath(PublishDirectory)
+ .SetFile($"./Dockerfile")
+ .SetTag(tags.Select(tag => $"{ContainerRegistryImage}:{tag}").ToArray())
+ .SetBuildArg([$"BASE_IMAGE={BaseImage}", $"COPY_PATH={PublishDirectory}"])
+ .SetProcessLogger((outputType, output) =>
+ {
+ if (outputType == OutputType.Std)
+ Log.Information(output);
+ else
+ Log.Debug(output);
+ })
+ );
});
string BaseImage => runtimeIdentifier switch
{
- "linux-x64" => "ubuntu",
- "alpine-x64" => "alpine",
+ "linux-x64" => "mcr.microsoft.com/dotnet/runtime-deps:8.0-jammy-chiseled",
+ "linux-musl-x64" => "mcr.microsoft.com/dotnet/runtime-deps:8.0-alpine",
+ _ => throw new ArgumentException($"There is no container image for: {runtimeIdentifier}"),
+ };
+
+ ///
+ /// Return the proper image tag for a given OS. For the second tupple value, if the image mush be marked as "latest"
+ ///
+ (string, bool) ContainerRuntimeIdentifier => runtimeIdentifier switch
+ {
+ "linux-x64" => ("linux-x64", true),
+ "linux-musl-x64" => ("alpine", false),
_ => throw new ArgumentException($"There is no container image for: {runtimeIdentifier}"),
};
+
+ private List ContainerTags()
+ {
+ if (IsLocalBuild)
+ {
+ return ["local", $"local-{ContainerRuntimeIdentifier.Item1}"];
+ }
+ List tagsOriginal = [Version, VersionMajorMinor, VersionMajor];
+ if (ContainerRuntimeIdentifier.Item2)
+ {
+ tagsOriginal.Add("latest");
+ }
+ var tags = tagsOriginal.Select(tag => $"{ContainerRuntimeIdentifier.Item1}-{tag}").ToList();
+ if (containerDefaultRID == runtimeIdentifier)
+ {
+ tags.AddRange(tagsOriginal);
+ }
+
+ return tags;
+ }
}
diff --git a/.build.Nuke/Build.GitLab.cs b/.build.Nuke/Build.GitLab.cs
index 833d9e99b8b383f0a3d1fc3ee2b51021f8880537..8a4af32496f03fad64e00e92638da027907e0943 100644
--- a/.build.Nuke/Build.GitLab.cs
+++ b/.build.Nuke/Build.GitLab.cs
@@ -1,6 +1,7 @@
using Nuke.Common;
using Nuke.Common.CI.GitLab;
using Nuke.Common.IO;
+using Nuke.Common.Tools.Docker;
using Nuke.Common.Tools.Git;
using Serilog;
using System;
@@ -42,7 +43,7 @@ sealed partial class Build : NukeBuild
/// One for each runtime identifier.
///
///
- public Target CreatePackage => td => td
+ public Target GitLabUploadPackage => td => td
.DependsOn(Publish)
.DependsOn(CheckNewCommits)
.Requires(() => gitlabPrivateToken)
@@ -157,6 +158,34 @@ sealed partial class Build : NukeBuild
});
///
+ /// Push all images created to the Registry
+ ///
+ public Target GitLabPushContainer => td => td
+ .DependsOn(CreateContainer)
+ .Executes(() =>
+ {
+ var tags = ContainerTags();
+
+ // Log in to the Docker registry
+ _ = DockerTasks.DockerLogin(_ => _
+ .SetServer("registry.gitlab.com")
+ .SetUsername("gitlab-ci-token")
+ .SetPassword(GitLab.JobToken)
+ );
+
+ // Push the container images
+ foreach (var tag in tags)
+ {
+ _ = DockerTasks.DockerPush(_ => _
+ .SetName($"{ContainerRegistryImage}:{tag}")
+ );
+
+ // Create a link to the GitLab release
+ var tagLink = GitLabAPIUrl($"?orderBy=NAME&sort=asc&search[]={tag}");
+ GitLabCreateReleaseLink($"docker-{tag}", tagLink);
+ }
+ });
+ ///
/// Creates a HTTP client and set the authentication header.
///
/// If the job token should be used instead of the private token.
diff --git a/.build.Nuke/Build.Publish.cs b/.build.Nuke/Build.Publish.cs
index 042775ff8d15c98248a0c187e180a2d684cd72df..5894445ed20ec1dcdedfa37694f38c732516bca0 100644
--- a/.build.Nuke/Build.Publish.cs
+++ b/.build.Nuke/Build.Publish.cs
@@ -28,7 +28,7 @@ sealed partial class Build : NukeBuild
readonly bool publishTrimmed = false;
Target Publish => td => td
- .DependsOn(Restore)
+ .After(Restore)
.Executes(() =>
{
_ = DotNetPublish(s => s
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 65a0a99b550eab04ea44c4cc3350dbad5968c06f..a10b48d80e730fc3560896cde0ee165af61d4858 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -19,10 +19,6 @@ variables:
PUBLISH_SINGLE_FILE: "true"
PUBLISH_TRIMMED: "false"
-# cache:
-# paths:
-# - "**/.nuget/packages"
-
services:
- docker:dind
@@ -35,7 +31,7 @@ test:
- schedules
script:
- |
- ./build.sh TestReport Publish \
+ ./build.sh Restore Compile TestReport Publish \
--configuration "Debug" \
--publish-directory "./publish"
coverage: '/^ Line coverage: (\d*.\d*)%/'
@@ -58,7 +54,7 @@ check-and-create-release:
- web
script:
- |
- ./build.sh Compile GitLabCreateRelease \
+ ./build.sh Restore Compile GitLabCreateRelease \
--is-scheduled $CI_PIPELINE_SCHEDULED \
--gitlab-private-token $GITLAB_PRIVATE_TOKEN
@@ -78,7 +74,7 @@ publish:
- chmod +x ./build.sh
script:
- |
- ./build.sh CreatePackage CreateContainer \
+ ./build.sh Restore Publish GitLabUploadPackage GitLabPushContainer \
--runtime-identifier $RID \
--publish-directory "./publish/SuCoS-$RID" \
--publish-self-contained $PUBLISH_SELF_CONTAINED \
@@ -90,4 +86,4 @@ publish:
matrix:
- RID: "win-x64"
- RID: "linux-x64"
- # - RID: "alpine-x64"
+ - RID: "linux-musl-x64"
diff --git a/.nuke/build.schema.json b/.nuke/build.schema.json
index 7def812ce0dc0a3e51e5560b0cd87f877e9eaf09..930db2d70579deaefe5f4319137536fe0511186a 100644
--- a/.nuke/build.schema.json
+++ b/.nuke/build.schema.json
@@ -112,9 +112,10 @@
"Clean",
"Compile",
"CreateContainer",
- "CreatePackage",
"GitLabCreateRelease",
"GitLabCreateTag",
+ "GitLabPushContainer",
+ "GitLabUploadPackage",
"Publish",
"Restore",
"ShowCurrentVersion",
@@ -137,9 +138,10 @@
"Clean",
"Compile",
"CreateContainer",
- "CreatePackage",
"GitLabCreateRelease",
"GitLabCreateTag",
+ "GitLabPushContainer",
+ "GitLabUploadPackage",
"Publish",
"Restore",
"ShowCurrentVersion",
diff --git a/Dockerfile b/Dockerfile
index c6b8d17e18b566802967e286ebc6b8c290bd9a85..857ab2dacc3baba1b07377e5774316bd72573967 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -2,13 +2,7 @@ ARG BASE_IMAGE
FROM ${BASE_IMAGE}
-# Set the working directory in the container
-WORKDIR /app
-
# Copy the published output from the build stage
-COPY ./* .
+COPY ./* /usr/local/bin/
ENV DOTNET_SYSTEM_GLOBALIZATION_INVARIANT=true
-
-RUN chmod +x ./SuCoS
-RUN ln -s /app/SuCoS /usr/local/bin/SuCoS