1
0
mirror of https://github.com/bitwarden/server.git synced 2024-11-27 13:05:23 +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.

75 lines
2.3 KiB
C#
Raw Normal View History

namespace Bit.Setup;
2022-08-29 22:06:55 +02:00
public class DockerComposeBuilder
{
2018-08-30 17:35:44 +02:00
private readonly Context _context;
2022-08-29 22:06:55 +02:00
public DockerComposeBuilder(Context context)
2022-08-29 20:53:16 +02:00
{
2018-08-30 17:35:44 +02:00
_context = context;
2022-08-29 22:06:55 +02:00
}
2018-08-30 17:35:44 +02:00
public void BuildForInstaller()
2022-08-29 22:06:55 +02:00
{
2018-08-30 17:35:44 +02:00
_context.Config.DatabaseDockerVolume = _context.HostOS == "mac";
2022-08-29 20:53:16 +02:00
Build();
}
public void BuildForUpdater()
2022-08-29 22:06:55 +02:00
{
Build();
}
private void Build()
2022-08-29 22:06:55 +02:00
{
Directory.CreateDirectory("/bitwarden/docker/");
Helpers.WriteLine(_context, "Building docker-compose.yml.");
if (!_context.Config.GenerateComposeConfig)
{
2018-08-30 17:35:44 +02:00
Helpers.WriteLine(_context, "...skipped");
return;
}
var template = Helpers.ReadTemplate("DockerCompose");
var model = new TemplateModel(_context);
using (var sw = File.CreateText("/bitwarden/docker/docker-compose.yml"))
{
sw.Write(template(model));
}
2022-08-29 22:06:55 +02:00
}
2018-08-30 17:35:44 +02:00
public class TemplateModel
2022-08-29 22:06:55 +02:00
{
public TemplateModel(Context context)
{
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-30 17:35:44 +02:00
{
2018-08-31 05:32:18 +02:00
CoreVersion = context.CoreVersion;
}
if (!string.IsNullOrWhiteSpace(context.WebVersion))
{
2019-03-12 15:26:14 +01:00
WebVersion = context.WebVersion;
}
if (!string.IsNullOrWhiteSpace(context.KeyConnectorVersion))
{
KeyConnectorVersion = context.KeyConnectorVersion;
}
}
2022-08-29 22:06:55 +02:00
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";
}
}