build: add docker-compose & NUKE buildsystem
All checks were successful
Test if Server can be built / build-server (push) Successful in 24s
All checks were successful
Test if Server can be built / build-server (push) Successful in 24s
This commit is contained in:
parent
68c1cae587
commit
2a1dec45d8
5 changed files with 95 additions and 7 deletions
|
@ -6,6 +6,11 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Benchmarks", "Benchmarks\Be
|
|||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "_build", "build\_build.csproj", "{046A3B46-FC08-4B08-A52A-1DC5D426120D}"
|
||||
EndProject
|
||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{C1303691-99F6-41CE-BAD3-2CA112D75DBF}"
|
||||
ProjectSection(SolutionItems) = preProject
|
||||
docker-compose.yml = docker-compose.yml
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
|
|
|
@ -70,7 +70,7 @@
|
|||
|
||||
<ItemGroup>
|
||||
<Content Include="settings.Development.json">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</Content>
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
|
|
30
Server/docker-compose.yml
Normal file
30
Server/docker-compose.yml
Normal file
|
@ -0,0 +1,30 @@
|
|||
services:
|
||||
server:
|
||||
image: continuity-server:latest
|
||||
environment:
|
||||
- ENVIRONMENT=Development
|
||||
- Testing:CreateAccountOnLogin=true
|
||||
- DB:Host=db
|
||||
- DB:Port=5432
|
||||
- DB:Username=continuity
|
||||
- DB:Password=continuity
|
||||
networks:
|
||||
- continuity
|
||||
ports:
|
||||
- "10001:10001"
|
||||
|
||||
db:
|
||||
image: postgres:16.0-alpine
|
||||
environment:
|
||||
- POSTGRES_USER=continuity
|
||||
- POSTGRES_DB=continuity
|
||||
- POSTGRES_PASSWORD=continuity
|
||||
networks:
|
||||
- continuity
|
||||
volumes:
|
||||
- db-data:/var/lib/postgresql/data
|
||||
|
||||
networks:
|
||||
continuity:
|
||||
volumes:
|
||||
db-data:
|
|
@ -1,10 +1,10 @@
|
|||
{
|
||||
"DB": {
|
||||
"Username": "continuitydevuser",
|
||||
"Host": "perf.rainote.dev",
|
||||
"Password": "7>CU`D2/LKw6hD/7",
|
||||
"Username": "continuity",
|
||||
"Host": "localhost",
|
||||
"Password": "continuity",
|
||||
"Database": "continuity",
|
||||
"Port": "13543"
|
||||
"Port": "5432"
|
||||
},
|
||||
"Testing": {
|
||||
"CreateAccountOnLogin": true
|
||||
|
|
|
@ -2,11 +2,18 @@ using System;
|
|||
using System.Linq;
|
||||
using Nuke.Common;
|
||||
using Nuke.Common.CI;
|
||||
using Nuke.Common.CI.GitHubActions;
|
||||
using Nuke.Common.Execution;
|
||||
using Nuke.Common.Git;
|
||||
using Nuke.Common.IO;
|
||||
using Nuke.Common.ProjectModel;
|
||||
using Nuke.Common.Tooling;
|
||||
using Nuke.Common.Tools.CodeMetrics;
|
||||
using Nuke.Common.Tools.Docker;
|
||||
using Nuke.Common.Tools.DotNet;
|
||||
using Nuke.Common.Tools.SonarScanner;
|
||||
using Nuke.Common.Utilities.Collections;
|
||||
using Serilog;
|
||||
using static Nuke.Common.EnvironmentInfo;
|
||||
using static Nuke.Common.IO.FileSystemTasks;
|
||||
using static Nuke.Common.IO.PathConstruction;
|
||||
|
@ -18,27 +25,73 @@ class Build : NukeBuild
|
|||
/// - JetBrains Rider https://nuke.build/rider
|
||||
/// - Microsoft VisualStudio https://nuke.build/visualstudio
|
||||
/// - Microsoft VSCode https://nuke.build/vscode
|
||||
|
||||
public static int Main () => Execute<Build>(x => x.Compile);
|
||||
public static int Main() => Execute<Build>(x => x.Information, x => x.Deploy);
|
||||
|
||||
[Parameter("Configuration to build - Default is 'Debug' (local) or 'Release' (server)")]
|
||||
readonly Configuration Configuration = IsLocalBuild ? Configuration.Debug : Configuration.Release;
|
||||
|
||||
GitRepository GitRepository => GitRepository.FromLocalDirectory(RootDirectory);
|
||||
|
||||
Target Information => _ => _
|
||||
.Before(Clean)
|
||||
.Executes(() =>
|
||||
{
|
||||
Log.Information("Branch Name: {BranchName}", GitRepository.Branch);
|
||||
Log.Information("Commit: {Commit}", GitRepository.Commit);
|
||||
});
|
||||
|
||||
Target Clean => _ => _
|
||||
.Before(Restore)
|
||||
.Executes(() =>
|
||||
{
|
||||
DotNetTasks.DotNetClean();
|
||||
});
|
||||
|
||||
Target Restore => _ => _
|
||||
.Executes(() =>
|
||||
{
|
||||
DotNetTasks.DotNetRestore();
|
||||
});
|
||||
|
||||
Target Compile => _ => _
|
||||
.DependsOn(Clean)
|
||||
.DependsOn(Restore)
|
||||
.Executes(() =>
|
||||
{
|
||||
DockerTasks.DockerStackRm(settings => settings.SetStacks("continuity"));
|
||||
DotNetTasks.DotNetBuild(settings => settings.SetNoRestore(true));
|
||||
});
|
||||
|
||||
Target Pack => _ => _
|
||||
.DependsOn(Compile)
|
||||
.Executes(() =>
|
||||
{
|
||||
DockerTasks.DockerBuild(settings => settings
|
||||
.SetPath(AbsolutePath.Create(RootDirectory))
|
||||
.SetFile("Server/Dockerfile")
|
||||
.SetTag("continuity-server:latest")
|
||||
.SetCompress(true)
|
||||
.SetProgress(ProgressType.auto));
|
||||
if (!IsLocalBuild)
|
||||
{
|
||||
DockerTasks.DockerPush(settings => settings.SetName("continuity-server:latest"));
|
||||
}
|
||||
});
|
||||
|
||||
Target Deploy => _ => _.DependsOn(Pack).Executes(() =>
|
||||
{
|
||||
DockerTasks.DockerPull(settings => settings.SetName("postgres:16.0-alpine"));
|
||||
if (IsLocalBuild)
|
||||
{
|
||||
var dockerComposeFile = AbsolutePath.Create(RootDirectory / "Server" / "docker-compose.yml");
|
||||
DockerTasks.DockerStackDeploy(settings => settings
|
||||
.AddComposeFile(dockerComposeFile)
|
||||
.SetStack("continuity")
|
||||
.SetPrune(true)
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
Log.Error("Deploy is only available on local builds.");
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue