Skip to content

Commit

Permalink
Allow omit_containers[db], fixes ddev#1490
Browse files Browse the repository at this point in the history
  • Loading branch information
rfay committed Aug 29, 2019
1 parent 5084b14 commit 4b4d4a3
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 15 deletions.
2 changes: 1 addition & 1 deletion docs/users/extend/config_yaml.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ the .ddev/config.yaml is the primary configuration for the project.
| additional_fqdns | extra fully-qualified domain names | `additional_fqdns: ["example.com", "sub1.example.com"]` would provide http and https URLs for "example.com" and "sub1.example.com". Please take care with this because it can cause great confusion and adds extraneous items to your /etc/hosts file. |
| upload_dir | Relative path to upload directory used by `ddev import-files` | |
| working_dir | explicitly specify the working directory used by `ddev exec` and `ddev ssh` | `working_dir: { web: "/var/www", db: "/etc" }` would set the working directories for the web and db containers. |
| omit_containers | Allows the project to not load specified containers | For example, `omit_containers: ["dba", "ddev-ssh-agent"]`. Currently only these containers are supported. These containers can also be omitted globally in the ~/.ddev/global_config.yaml. |
| omit_containers | Allows the project to not load specified containers | For example, `omit_containers: ["db", dba", "ddev-ssh-agent"]`. Currently only these containers are supported. Some containers can also be omitted globally in the ~/.ddev/global_config.yaml. Note that if you omit the "db" container, several standard features of ddev that access the database container will be unusuable. |
| nfs_mount_enabled | Allows using NFS to mount the project into the container for performance reasons | See [nfsmount_enabled documentation](../../performance.md). This requires configuration on the host before it can be used. |
| host_https_port | Specify a specific and persistent https port for direct binding to the localhost interface | This is not commonly used, but a specific port can be provided here and the https URL will always remain the same. For example, if you put "59001", the project will always use "https://127.0.0.1:59001". for the localhost URL. (Note that the named URL is more commonly used and for most purposes is better.) If this is not set the port will change from `ddev start` to `ddev start` |
| host_webserver_port | Specify a specific and persistent http port for direct binding to the localhost interface | This is not commonly used, but a specific port can be provided here and the https URL will always remain the same. For example, if you put "59000", the project will always use "http://127.0.0.1:59000". for the localhost URL. (Note that the named URL is more commonly used and for most purposes is better.) If this is not set the port will change from `ddev start` to `ddev start` |
Expand Down
2 changes: 2 additions & 0 deletions pkg/ddevapp/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -589,6 +589,7 @@ type composeYAMLVars struct {
DBBuildContext string
BgsyncBuildContext string
SSHAgentBuildContext string
OmitDB bool
OmitDBA bool
OmitSSHAgent bool
WebcacheEnabled bool
Expand Down Expand Up @@ -636,6 +637,7 @@ func (app *DdevApp) RenderComposeYAML() (string, error) {
DdevGenerated: DdevFileSignature,
HostDockerInternalIP: hostDockerInternalIP,
ComposeVersion: version.DockerComposeFileFormatVersion,
OmitDB: nodeps.ArrayContainsString(app.OmitContainers, "db"),
OmitDBA: nodeps.ArrayContainsString(app.OmitContainers, "dba"),
OmitSSHAgent: nodeps.ArrayContainsString(app.OmitContainers, "ddev-ssh-agent"),
WebcacheEnabled: app.WebcacheEnabled,
Expand Down
31 changes: 18 additions & 13 deletions pkg/ddevapp/ddevapp.go
Original file line number Diff line number Diff line change
Expand Up @@ -191,18 +191,20 @@ func (app *DdevApp) Describe() (map[string]interface{}, error) {

// Only show extended status for running sites.
if app.SiteStatus() == SiteRunning {
dbinfo := make(map[string]interface{})
dbinfo["username"] = "db"
dbinfo["password"] = "db"
dbinfo["dbname"] = "db"
dbinfo["host"] = "db"
dbPublicPort, err := app.GetPublishedPort("db")
util.CheckErr(err)
dbinfo["dbPort"] = GetPort("db")
util.CheckErr(err)
dbinfo["published_port"] = dbPublicPort
dbinfo["mariadb_version"] = app.MariaDBVersion
appDesc["dbinfo"] = dbinfo
if !nodeps.ArrayContainsString(app.OmitContainers, "db") {
dbinfo := make(map[string]interface{})
dbinfo["username"] = "db"
dbinfo["password"] = "db"
dbinfo["dbname"] = "db"
dbinfo["host"] = "db"
dbPublicPort, err := app.GetPublishedPort("db")
util.CheckErr(err)
dbinfo["dbPort"] = GetPort("db")
util.CheckErr(err)
dbinfo["published_port"] = dbPublicPort
dbinfo["mariadb_version"] = app.MariaDBVersion
appDesc["dbinfo"] = dbinfo
}

appDesc["mailhog_url"] = "http://" + app.GetHostname() + ":" + app.MailhogPort
if !nodeps.ArrayContainsString(app.OmitContainers, "dba") {
Expand Down Expand Up @@ -759,7 +761,10 @@ func (app *DdevApp) Start() error {
return err
}

requiredContainers := []string{"db", "web"}
requiredContainers := []string{"web"}
if !nodeps.ArrayContainsString(app.OmitContainers, "db") {
requiredContainers = append(requiredContainers, "db")
}
if app.WebcacheEnabled {
requiredContainers = append(requiredContainers, "bgsync")
err = app.precacheWebdir()
Expand Down
3 changes: 2 additions & 1 deletion pkg/ddevapp/templates.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ package ddevapp
const DDevComposeTemplate = `version: '{{ .ComposeVersion }}'
{{ .DdevGenerated }}
services:
{{if not .OmitDB }}
db:
container_name: {{ .Plugin }}-${DDEV_SITENAME}-db
build:
Expand Down Expand Up @@ -47,6 +48,7 @@ services:
retries: 30
start_period: 20s
timeout: 120s
{{end}}
web:
container_name: {{ .Plugin }}-${DDEV_SITENAME}-web
build:
Expand Down Expand Up @@ -186,7 +188,6 @@ services:
interval: 120s
timeout: 2s
retries: 1
{{end}}
networks:
default:
Expand Down
1 change: 1 addition & 0 deletions pkg/ddevapp/values.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ const (
)

var ValidOmitContainers = map[string]bool{
DBContainer: true,
DdevSSHAgentContainer: true,
DBAContainer: true,
}
Expand Down

0 comments on commit 4b4d4a3

Please sign in to comment.