1
0
mirror of https://github.com/bitwarden/server.git synced 2024-12-27 17:47:37 +01:00
bitwarden-server/util/Setup/DockerComposeBuilder.cs

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

81 lines
2.8 KiB
C#
Raw Normal View History

namespace Bit.Setup
{
public class DockerComposeBuilder
{
2018-08-30 17:35:44 +02:00
private readonly Context _context;
2017-11-07 16:54:00 +01:00
2018-08-30 17:35:44 +02:00
public DockerComposeBuilder(Context context)
{
_context = context;
}
2018-08-30 17:35:44 +02:00
public void BuildForInstaller()
{
2018-08-30 17:35:44 +02:00
_context.Config.DatabaseDockerVolume = _context.HostOS == "mac";
Build();
}
public void BuildForUpdater()
{
Build();
}
private void Build()
{
Directory.CreateDirectory("/bitwarden/docker/");
2019-03-12 15:26:14 +01:00
Helpers.WriteLine(_context, "Building docker-compose.yml.");
if (!_context.Config.GenerateComposeConfig)
{
2019-03-12 15:26:14 +01:00
Helpers.WriteLine(_context, "...skipped");
2018-08-30 17:35:44 +02:00
return;
}
2018-08-30 17:35:44 +02:00
var template = Helpers.ReadTemplate("DockerCompose");
var model = new TemplateModel(_context);
using (var sw = File.CreateText("/bitwarden/docker/docker-compose.yml"))
2018-08-30 17:35:44 +02:00
{
sw.Write(template(model));
}
}
2018-08-30 17:35:44 +02:00
public class TemplateModel
{
public TemplateModel(Context context)
{
if (!string.IsNullOrWhiteSpace(context.Config.ComposeVersion))
2018-08-31 05:32:18 +02:00
{
ComposeVersion = context.Config.ComposeVersion;
}
2018-08-30 17:35:44 +02:00
MssqlDataDockerVolume = context.Config.DatabaseDockerVolume;
EnableKeyConnector = context.Config.EnableKeyConnector;
[EC-261] SCIM (#2105) * scim project stub * some scim models and v2 controllers * implement some v2 scim endpoints * fix spacing * api key auth * EC-261 - SCIM Org API Key and connection type config * EC-261 - Fix lint errors/formatting * updates for okta implementation testing * fix var ref * updates from testing with Okta * implement scim context via provider parsing * support single and list of ids for add/remove groups * log ops not handled * touch up scim context * group list filtering * EC-261 - Additional SCIM provider types * EC-265 - UseScim flag and license update * EC-265 - SCIM provider type of default (0) * EC-265 - Add Scim URL and update connection validation * EC-265 - Model validation and cleanup for SCIM keys * implement scim org connection * EC-265 - Ensure ServiceUrl is not persisted to DB * EC-265 - Exclude provider type from DB if not configured * EC-261 - EF Migrations for SCIM * add docker builds for scim * EC-261 - Fix failing permissions tests * EC-261 - Fix unit tests and pgsql migrations * Formatting fixes from linter * EC-265 - Remove service URL from scim config * EC-265 - Fix unit tests, removed wayward validation * EC-265 - Require self-hosted for billing sync org conn * EC-265 - Fix formatting issues - whitespace * EC-261 - PR feedback and cleanup * scim constants rename * no scim settings right now * update project name * delete package lock * update appsettings configs for scim * use default scim provider for context Co-authored-by: Kyle Spearrin <kyle.spearrin@gmail.com>
2022-07-14 21:58:48 +02:00
EnableScim = context.Config.EnableScim;
2018-08-30 17:35:44 +02:00
HttpPort = context.Config.HttpPort;
HttpsPort = context.Config.HttpsPort;
if (!string.IsNullOrWhiteSpace(context.CoreVersion))
2018-08-31 05:32:18 +02:00
{
CoreVersion = context.CoreVersion;
}
if (!string.IsNullOrWhiteSpace(context.WebVersion))
2018-08-31 05:32:18 +02:00
{
WebVersion = context.WebVersion;
}
if (!string.IsNullOrWhiteSpace(context.KeyConnectorVersion))
{
KeyConnectorVersion = context.KeyConnectorVersion;
}
}
2018-08-30 17:35:44 +02:00
2018-08-31 05:32:18 +02:00
public string ComposeVersion { get; set; } = "3";
2018-08-30 17:35:44 +02:00
public bool MssqlDataDockerVolume { get; set; }
public bool EnableKeyConnector { get; set; }
[EC-261] SCIM (#2105) * scim project stub * some scim models and v2 controllers * implement some v2 scim endpoints * fix spacing * api key auth * EC-261 - SCIM Org API Key and connection type config * EC-261 - Fix lint errors/formatting * updates for okta implementation testing * fix var ref * updates from testing with Okta * implement scim context via provider parsing * support single and list of ids for add/remove groups * log ops not handled * touch up scim context * group list filtering * EC-261 - Additional SCIM provider types * EC-265 - UseScim flag and license update * EC-265 - SCIM provider type of default (0) * EC-265 - Add Scim URL and update connection validation * EC-265 - Model validation and cleanup for SCIM keys * implement scim org connection * EC-265 - Ensure ServiceUrl is not persisted to DB * EC-265 - Exclude provider type from DB if not configured * EC-261 - EF Migrations for SCIM * add docker builds for scim * EC-261 - Fix failing permissions tests * EC-261 - Fix unit tests and pgsql migrations * Formatting fixes from linter * EC-265 - Remove service URL from scim config * EC-265 - Fix unit tests, removed wayward validation * EC-265 - Require self-hosted for billing sync org conn * EC-265 - Fix formatting issues - whitespace * EC-261 - PR feedback and cleanup * scim constants rename * no scim settings right now * update project name * delete package lock * update appsettings configs for scim * use default scim provider for context Co-authored-by: Kyle Spearrin <kyle.spearrin@gmail.com>
2022-07-14 21:58:48 +02:00
public bool EnableScim { get; set; }
2018-08-30 17:35:44 +02:00
public string HttpPort { get; set; }
public string HttpsPort { get; set; }
2018-09-26 22:53:37 +02:00
public bool HasPort => !string.IsNullOrWhiteSpace(HttpPort) || !string.IsNullOrWhiteSpace(HttpsPort);
2018-08-30 17:35:44 +02:00
public string CoreVersion { get; set; } = "latest";
public string WebVersion { get; set; } = "latest";
public string KeyConnectorVersion { get; set; } = "latest";
}
}
}