Skip to content

Instantly share code, notes, and snippets.

public class BuildContext : FrostingContext
{
public string ProjectName { get; internal set; }
public BuildContext(ICakeContext context)
: base(context)
{
SolutionPath = context.Arguments.GetArgument("solution_path");
ProjectName = context.Arguments.GetArgument("project_name");
}
[TaskName("Default")]
[IsDependentOn(typeof(PublishApplication))]
public class DefaultTask : FrostingTask
{
}
[TaskName("Clean Solution")]
public sealed class CleanSolution : FrostingTask<BuildContext>
{
public override void Run(BuildContext context)
{
context.GitClean(context.SolutionPath);
}
}
public static class DockerContextExtensions
{
const string DockerBinaryName = "docker";
const string ArgumentSeparator = " ";
public static async Task<bool> TryBuildDockerfileAsync(this ICakeContext context, DockerBuildOptions options)
{
var buildArgs = string.Join($"{ArgumentSeparator}--build-arg", options.BuildArguments.Select(kvp => $"{kvp.Key}={kvp.Value}"));
string arguments = string.IsNullOrWhiteSpace(buildArgs)
? string.Empty
[TaskName("Build Dockerfile")]
[IsDependentOn(typeof(CleanSolution))]
public sealed class BuildDockerfile : AsyncFrostingTask<BuildContext>
{
// Tasks can be asynchronous
public override async Task RunAsync(BuildContext context)
{
var options = new DockerBuildOptions
{
DockerfileLocation = ".",
[TaskName("Build Dockerfile")]
[IsDependentOn(typeof(CleanSolution))]
public sealed class BuildDockerfile : AsyncFrostingTask<BuildContext>
{
// Tasks can be asynchronous
public override async Task RunAsync(BuildContext context)
{
var options = new DockerBuildOptions
{
DockerfileLocation = ".",
[TaskName("Publish Application")]
[IsDependentOn(typeof(BuildDockerfile))]
public sealed class PublishApplication : AsyncFrostingTask<BuildContext>
{
// Tasks can be asynchronous
public override async Task RunAsync(BuildContext context)
{
var options = new DockerBuildOptions
{
apiVersion: v1
kind: ConfigMap
metadata:
name: game-demo
data:
# property-like keys; each key maps to a simple value
player_initial_lives: "3"
ui_properties_file_name: "user-interface.properties"
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ include "servicechart.fullname" . }}-appsettings
namespace: {{ include "servicechart.namespace" . }}
data:
appsettings.config.json: |-
{{ .Files.Get "appsettings.config.json" | indent 4 }}
apiVersion: v1
kind: Secret
metadata:
name: {{ include "servicechart.fullname" . }}-appsettings
namespace: {{ include "servicechart.namespace" . }}
type: Opaque
stringData:
appsettings.secrets.json: |-
{{ .Files.Get "appsettings.secrets.json" | indent 4 }}