1
0
mirror of https://github.com/bitwarden/server.git synced 2025-07-19 16:37:08 -05:00
Files
bitwarden/util/Setup/DockerComposeBuilder.cs
tangowithfoxtrot 24b7cc417f feat(self-host): [PM-14188] Add option to disable built-in MSSQL container
* Add Config Option For Disabling Built In MSSQL Container

* fix: flip bool condition and make it nullable

* fake commit to kick off an ephemeral environment

* Revert "fake commit to kick off an ephemeral environment"

This reverts commit 818f65f4d2.

* Changed the new setting to not be nullable.

---------

Co-authored-by: Justin Baur <19896123+justindbaur@users.noreply.github.com>
Co-authored-by: Todd Martin <tmartin@bitwarden.com>
2025-07-11 11:23:51 -04:00

77 lines
2.4 KiB
C#

namespace Bit.Setup;
public class DockerComposeBuilder
{
private readonly Context _context;
public DockerComposeBuilder(Context context)
{
_context = context;
}
public void BuildForInstaller()
{
_context.Config.DatabaseDockerVolume = _context.HostOS == "mac";
Build();
}
public void BuildForUpdater()
{
Build();
}
private void Build()
{
Directory.CreateDirectory("/bitwarden/docker/");
Helpers.WriteLine(_context, "Building docker-compose.yml.");
if (!_context.Config.GenerateComposeConfig)
{
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));
}
}
public class TemplateModel
{
public TemplateModel(Context context)
{
EnableBuiltInMsSql = context.Config.EnableBuiltInMsSql;
MssqlDataDockerVolume = context.Config.DatabaseDockerVolume;
EnableKeyConnector = context.Config.EnableKeyConnector;
EnableScim = context.Config.EnableScim;
HttpPort = context.Config.HttpPort;
HttpsPort = context.Config.HttpsPort;
if (!string.IsNullOrWhiteSpace(context.CoreVersion))
{
CoreVersion = context.CoreVersion;
}
if (!string.IsNullOrWhiteSpace(context.WebVersion))
{
WebVersion = context.WebVersion;
}
if (!string.IsNullOrWhiteSpace(context.KeyConnectorVersion))
{
KeyConnectorVersion = context.KeyConnectorVersion;
}
}
public bool EnableBuiltInMsSql { get; set; }
public bool MssqlDataDockerVolume { get; set; }
public bool EnableKeyConnector { get; set; }
public bool EnableScim { get; set; }
public string HttpPort { get; set; }
public string HttpsPort { get; set; }
public bool HasPort => !string.IsNullOrWhiteSpace(HttpPort) || !string.IsNullOrWhiteSpace(HttpsPort);
public string CoreVersion { get; set; } = "latest";
public string WebVersion { get; set; } = "latest";
public string KeyConnectorVersion { get; set; } = "latest";
}
}