Repository navigation
Add ddev config command - #63
Conversation
|
Gave it a quick spin.
|
|
@rfay "version" was stolen from docker-compose. Of course, that doesn't make it automatically right. It may even make it more confusing! Potential alternatives:
And probably 1000 others. I'm not too partial to any of them. Generally, I prefer dashes to underscores, but I'm not sure I have a valid reason even for that.. |
|
I'd vote for APIVersion. |
|
This still needs tests before merge, but as it's a big (and important) change, I'd love a smoketest from both a code perspective (from @tannerjfco or @rfay), and a functional perspective (cc @rickmanelius) before starting down that path. Testing instructions are up to date. Just wanna make sure we all agree it's close to the mark. |
|
config cmd worked great for me, but I hit the following error trying to run start after: |
tannerjfco
left a comment
There was a problem hiding this comment.
This mostly seems to work for me. Great work!
I did encounter some unexpected behavior with ddev rm, though removal still succeeded. Looks like the env vars aren't getting set:
tannerjfco sites/drud-d7 ‹staging*› » ddev rm
DEBU[0000] Starting Config Read Existing config={
APIVersion: "1",
Name: "",
AppType: "",
Docroot: "",
WebImage: "drud/nginx-php-fpm7-local:0.2.0",
DBImage: "drud/mysql-docker-local-57:v0.2.0",
ConfigPath: "/Users/tannerjfco/sites/drud-d7/.ddev/config.yaml",
AppRoot: "/Users/tannerjfco/sites/drud-d7",
Platform: "local"
}
DEBU[0000] Finished config read Existing config={
APIVersion: "1",
Name: "drud-d7",
AppType: "drupal7",
Docroot: "docroot",
WebImage: "drud/nginx-php-fpm7-local:0.2.0",
DBImage: "drud/mysql-docker-local-57:v0.2.0",
ConfigPath: "/Users/tannerjfco/sites/drud-d7/.ddev/config.yaml",
AppRoot: "/Users/tannerjfco/sites/drud-d7",
Platform: "local"
}
WARNING: The DDEV_SITENAME variable is not set. Defaulting to a blank string.
WARNING: The DDEV_WEBIMAGE variable is not set. Defaulting to a blank string.
WARNING: The DDEV_URL variable is not set. Defaulting to a blank string.
WARNING: The DDEV_DOCROOT variable is not set. Defaulting to a blank string.
WARNING: The DDEV_APPROOT variable is not set. Defaulting to a blank string.
WARNING: The DDEV_HOSTNAME variable is not set. Defaulting to a blank string.
WARNING: The DDEV_DBIMAGE variable is not set. Defaulting to a blank string.
ERROR: Service 'local-drud-d7-web' depends on service 'local--db' which is undefined.
INFO[0000] Running Command Command=docker stop 667db801f10c9914f00e7aba13dc811bdf69cd35e02add022e9f637e27101112
DEBU[0011] Command Result Result=667db801f10c9914f00e7aba13dc811bdf69cd35e02add022e9f637e27101112
INFO[0011] Running Command Command=docker rm 667db801f10c9914f00e7aba13dc811bdf69cd35e02add022e9f637e27101112
DEBU[0011] Command Result Result=667db801f10c9914f00e7aba13dc811bdf69cd35e02add022e9f637e27101112
INFO[0011] Running Command Command=docker stop cbc5115b1076f47a9dc5bd4a70247d2080fdaf872763fa1d6d8295530f6bce5f
DEBU[0014] Command Result Result=cbc5115b1076f47a9dc5bd4a70247d2080fdaf872763fa1d6d8295530f6bce5f
INFO[0014] Running Command Command=docker rm cbc5115b1076f47a9dc5bd4a70247d2080fdaf872763fa1d6d8295530f6bce5f
DEBU[0014] Command Result Result=cbc5115b1076f47a9dc5bd4a70247d2080fdaf872763fa1d6d8295530f6bce5f
Successfully removed the drud-d7 application.
I hit a similar issue with ddev logs, in this case the command fails with no helpful information beyond the warnings seen above for dddev rm.
| defaultLocations := map[string]string{ | ||
| "scripts/drupal.sh": "drupal7", | ||
| "core/scripts/drupal.sh": "drupal8", | ||
| "wp": "wordpress", |
There was a problem hiding this comment.
we'll need a better check for wp - this one would only work for newmedia wp repos
There was a problem hiding this comment.
Well dang. you are correct.
There was a problem hiding this comment.
i'm not sure we can provide a foolproof check for this w/ a simple path check. We could easily search for one of the wp- prefixed files, but if a codebase has moved core to its own folder, that folder could be named anything. I think we could check for maybe wp-activate.php and call it a day. The user can still manually define it if detection fails.
| container_name: {{ .plugin }}-${DDEV_SITENAME}-web | ||
| image: $DDEV_WEBIMAGE | ||
| volumes: | ||
| - "{{ .docroot }}/:/var/www/html/docroot" |
There was a problem hiding this comment.
should we make this /var/www/html now, or rename from docroot? my concern is if a user had a differently named docroot like htdocs, if they were to run an ssh cmd i could see them potentially becoming disoriented.
There was a problem hiding this comment.
Agree we should do it. Wanna make a case for why it should be now? :)
| appName := label["com.drud.site-name"] | ||
| appType := label["com.drud.app-type"] | ||
| containerType := label["com.drud.container-type"] | ||
| appName := label["com.ddev.site-name"] |
There was a problem hiding this comment.
if we follow the documented recommendation, these should use a real domain that we own:
Authors of third-party tools should prefix each label key with the reverse DNS notation of a domain they own, such as `com.example.some-label`.
There was a problem hiding this comment.
But... ddev.com is available for only $10,000 !!!
| }).Debug("Setting DockerEnv variable") | ||
|
|
||
| err := os.Setenv(k, v) | ||
| // @ TODO: I have no idea what a Setenv error would even look like, so I'm not sure what |
There was a problem hiding this comment.
i'm not certain there's anything more to do here - i figure if we can't set an env var something really weird must be going on, and there are bigger problems to solve. perhaps we should fatal in that case and call it a day?
There was a problem hiding this comment.
Basically, we need a standard way of handling errors-that-cant-happen, instead of the standard oh-so-wordy golang metaphor. Agreed this doesn't need handling. _ = os.Setenv() would be OK.
There was a problem hiding this comment.
However, despite both these comments, thanks for noting and handling and reporting errors!
| Status string | ||
| } | ||
|
|
||
| // AppOptions .. |
There was a problem hiding this comment.
glad to see this go, along w/ the rest of the clean up here
| const DDevDefaultPlatform = "local" | ||
|
|
||
| // DDevTLD defines the tld to use for DDev site URLs. | ||
| const DDevTLD = "ddev.local" |
|
|
||
| // DockerEnv sets environment variables for a docker-compose run. | ||
| func (l LocalApp) DockerEnv() { | ||
| envVars := map[string]string{ |
There was a problem hiding this comment.
what's the motivation behind using env vars for this data?
|
A couple questions/comments:
My concern is if we require these configurations and have users commit them to repos, that they would have to update that configuration any time we pushed an update. This is manageable for a small number of sites, but not as much for a large number of sites. |
rfay
left a comment
There was a problem hiding this comment.
I had a problem doing an install.php on drud-d7 (staging). In the second step of the install.php it redirected to the wrong hostname - http://local-drud-d7/install.php?profile=standard - and that got a 503. I imagine that's because the old hostname formula is still embedded in there somewhere?
| "-f", app.DockerComposeYAMLPath(), | ||
| "exec", | ||
| "-T", nameContainer, | ||
| } |
There was a problem hiding this comment.
I like the DockerComposeYAMLPath() but would prefer to see the whole docker compose command execution packaged as a function.
There was a problem hiding this comment.
agreed. There's a lot of things (like this) that would have been nice to do, but this PR was already pretty big and we have less test coverage than would be ideal.
If we think important enough to do now I'm happy to do it, but I tried to avoid rewriting more than I had to.
There was a problem hiding this comment.
OK by me, but thanks for getting the DockerComposeYAMLPath() in!
| appName := label["com.drud.site-name"] | ||
| appType := label["com.drud.app-type"] | ||
| containerType := label["com.drud.container-type"] | ||
| appName := label["com.ddev.site-name"] |
There was a problem hiding this comment.
But... ddev.com is available for only $10,000 !!!
|
@rfay could your error have been because an existing That is a bit of weirdness in the way we are currently doing things that I had noticed. If you have previously installed and are using the same codebase, you would need to remove it. |
|
Yes, the existing settings.php will be the problem - the existing settings.php has that hostname in it. And drupal 7's .gitignore (which I am probably responsible for) ignores settings.php. I knew I had a clean repo... but didn't remember that. |
|
I was able to bring up a site where the docroot was the main dir by leaving docroot empty. That results in the var being set correctly. It's not very intuitive of course. In the process of learning that I tried a rooted docroot - that doesn't work at all (and I would think it should). I think a relative path is fine, but most command-line type apps know the difference between a relative path and a rooted full path. So if you put in /Users/rfay/workspace/d7git for the docroot, it will not go well. |
rfay
left a comment
There was a problem hiding this comment.
ddev logs seems to be broken, see https://gist.github.com/rfay/8e683d66092021310ca4a023a20f92ca - I thought it was working before.
ddev config says it has flags in the --help but there are none that I can find.
…make ddev restart work
…efault', and add more parameters to the docker-compose file
|
@rfay I took a stab at the docroot change: Thoughts? |
|
To close the loop, here's what we ended up going with for now: |
|
🎉 🎈 |
The Problem:
The problem is outlined in #57
The Fix:
This introduces a
ddev configcommand. It still requires an app-name and env-name, but those values are not used. The need for them should be removed alongside the working-directory based changes that are coming.The Test:
This changes (and relies) on container labels, so any existing ddev sites you have running should be stopped/removed.
ddev configfrom the repository root directory.config.yamlddev startAlso worth noting, I went pretty heavy on DRUD_DEBUG output (maybe too heavy). Enabling it will show you lots about what is happening internally, but it can be very distracting.
Automation Overview:
There is no automation at the time of opening this PR. This absolutely need automation before merging.
Related Issue Link(s):
#57