MCPcopy Index your code
hub / github.com/ddev/ddev / RenderComposeYAML

Method RenderComposeYAML

pkg/ddevapp/config.go:847–1163  ·  view source on GitHub ↗

RenderComposeYAML renders the contents of .ddev/.ddev-docker-compose*.

()

Source from the content-addressed store, hash-verified

845
846// RenderComposeYAML renders the contents of .ddev/.ddev-docker-compose*.
847func (app *DdevApp) RenderComposeYAML() (string, error) {
848 var doc bytes.Buffer
849 var err error
850
851 hostDockerInternal := dockerutil.GetHostDockerInternal()
852 util.Debug("%s", hostDockerInternal.Message)
853
854 // The fallthrough default for hostDockerInternalIdentifier is the
855 // hostDockerInternalHostname == host.docker.internal
856
857 webEnvironment := globalconfig.DdevGlobalConfig.WebEnvironment
858 localWebEnvironment := app.WebEnvironment
859 for _, v := range localWebEnvironment {
860 // docker-compose won't accept a duplicate environment value
861 if !nodeps.ArrayContainsString(webEnvironment, v) {
862 webEnvironment = append(webEnvironment, v)
863 }
864 }
865
866 uid, gid, username := dockerutil.GetContainerUser()
867 _, err = app.GetProvider("")
868 if err != nil {
869 return "", err
870 }
871
872 timezone := app.Timezone
873 if timezone == "" {
874 timezone, err = util.GetLocalTimezone()
875 if err != nil {
876 util.Debug("Unable to autodetect timezone: %v", err.Error())
877 } else {
878 util.Debug("Using automatically detected timezone: TZ=%s", timezone)
879 }
880 }
881
882 templateVars := composeYAMLVars{
883 Name: app.Name,
884 AppType: app.Type,
885 WebserverType: app.WebserverType,
886 MailpitPort: GetInternalPort(app, "mailpit"),
887 HostMailpitPort: app.HostMailpitPort,
888 DBType: app.Database.Type,
889 DBVersion: app.Database.Version,
890 DBMountDir: "/var/lib/mysql",
891 DBPort: GetInternalPort(app, "db"),
892 DdevGenerated: nodeps.DdevFileSignature,
893 DisableSettingsManagement: app.DisableSettingsManagement,
894 OmitDB: nodeps.ArrayContainsString(app.GetOmittedContainers(), nodeps.DBContainer),
895 OmitRouter: nodeps.ArrayContainsString(app.GetOmittedContainers(), globalconfig.DdevRouterContainer),
896 OmitSSHAgent: nodeps.ArrayContainsString(app.GetOmittedContainers(), "ddev-ssh-agent"),
897 BindAllInterfaces: app.BindAllInterfaces,
898 MutagenEnabled: app.IsMutagenEnabled(),
899
900 IsWindowsFS: nodeps.IsWindows(),
901 NoProjectMount: app.NoProjectMount,
902 MountType: "bind",
903 WebMount: "../",
904 Timezone: timezone,

Callers 1

Calls 15

GetProviderMethod · 0.95
GetOmittedContainersMethod · 0.95
IsMutagenEnabledMethod · 0.95
GetWorkingDirMethod · 0.95
GetMariaDBVolumeNameMethod · 0.95
GetPostgresVolumeNameMethod · 0.95
GetDocrootMethod · 0.95
GetXHGuiHTTPPortMethod · 0.95
GetXHGuiHTTPSPortMethod · 0.95
GetXHProfModeMethod · 0.95
GetPostgresDataDirMethod · 0.95

Tested by

no test coverage detected