-
Notifications
You must be signed in to change notification settings - Fork 848
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Monolithic Docker provider #2632
Conversation
Prepare v3.6 release
3.7.1 release
- use direct binary call
- docker use same clock as host
- Docker doesn't support persistent /etc/hosts
- By default its always compressed
- I guess backward compat ?
With that change I can load the dashboard, the 2 sites fail to provision though with Nginx issues though |
It looks like the Nginx config didn't have proper search replacements, here's the
There's lots of unreadable temporary files in the provision folder too: the log suggests that
|
The |
Hmm, that problem is common for me in volumes with Docker on Mac. I always have to go with explicit temp files, which makes all commands more complicated to write.
The need to destroy and recreate the container should be on the docker provider for Vagrant. I've implemented the "magic" (not really, as it didn't work for you) port mapping to avoid conflicts with other containers that may be using that port already. We can remove the function that is not used anymore (if you didn't remove it already) and just force it to collide with anything else you may have running. |
Honestly I'm happy to just document it as that's what all the other docker local environments do, fully stop your other environments before starting ours is very common to see. In the long run it might be nice to explore reusing their Traefik proxies but for now this is reasonable, and more user friendly than switching ports |
Could that be wrapped in a function? I was mulling using |
I asked ChatGPT and forgot to specify replace_variables_in_file() {
local file="$1"
local token="$2"
local value="$3"
# Read the file contents and replace the token with the value
local content
if [[ -f "$file" ]]; then
content=$(<"$file")
content=${content//$token/$value}
echo "$content"
else
return 1
fi
} I tested on MacOS and surprisingly it worked in ZSH which I didn't expect. Need to try adjusting the provisioner and with shellcheck related changes |
We'll need this function or something with similar functionality in |
I tried working on a replacement, and we need to also replace it in the template provider, but it was late at night and got stuck in retro compatibility... we may not be able to reuse what we include in VVV docker, in case people don't update right away, so we may need to duplicate the function in VVV and the site template for some time |
Just pushed the replacement function here |
@msaggiorato I just tried to push commits and saw you'd made changes, there's a new PR with my version that relies on bash replacement and variables, there's other things that would be good to cherry pick out |
…/VVV into docker-provider
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks like I forgot to submit some comments
|
||
# Docker use image. | ||
config.vm.provider :docker do |d, override| | ||
d.image = 'pentatonicfunk/vagrant-ubuntu-base-images:20.04' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we can avoid this by using a dockerfile and layering over a general ubuntu 20 container
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That'd be preferrable for me as well
d.ports += [ "#{mailhog_port}:8025" ] | ||
|
||
## Fix goodhosts aliases format for docker | ||
override.goodhosts.aliases = { '127.0.0.1' => vvv_config['hosts'], '::1' => vvv_config['hosts'] } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
noting that if we used docker compose then traefik can be used and goodhosts becomes optional
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
traefik will not handle domains unless we have some true real life domain available, like vvv.dev or something on those lines. This is all explained here.
Traefik would be useful if we wanted to have multi-container nginx, or node apps supports or something, so that you can access different things based on, for example, paths:
Example
localhost/wp1 -> nginx container -> php8 container
localhost/wp2 -> nginx-legacy container (old version or something) -> php 5.4 container
localhost/nodeapp -> node app
In this example, and since all sites are accesed on port 80, and just different apps, traefik will forward traffic to each container, and in the case of nginx containers, they'll use the configured php upstream containers as needed.
Since i don't think we need node apps forwarding for the time being, and also, we're not thinking of supporting multiple versions of nginx in the foreseable future.
We don't need traefik, and we can just expose nginx port 80.
vvv.test will never load in traefik (or nginx) unless your machine can resolve vvv.test to 127.0.0.1. there's only a few ways this can happen:
- hostfile editing (goodhosts), which is already in place and works fine, with the added dependency
- zeroconf dns (bonjour, etc) which Chassis uses by interfacing with dbus here. This works because of the way VirtualBox handles networking. This wouldn't work on Docker for Mac or Windows (may work for Linux, with extra permissions). In any case, it requires implementation which we don't currently have, and is not straightforward.
- Real life domain (this is the lando approach), explained here. This is basically a small server somewhere on the public internet, which works as a DNS and resolves any domain you point to it to 127.0.0.1. This is why asd.test2.lndo.site test2.lndo.site vvv.lndo.site and asd.vvv.lndo.site or anything you can think of, works. Because it's a real life domain on the public internet. You can check it out on any DNS checker online.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Traefik would be useful if we wanted to have multi-container nginx, or node apps supports or something, so that you can access different things based on, for example, paths:
That is something I'd like in the future, particularly for MariaDB/ES/Mailhog. I can see an argument for there being an Nginx container too, and in the long run it also allows us to be more flexible with PHP versions and php logging on a per site basis
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
also note that Altis Local Server manages this somehow with Traefik
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can look into the code, but it's likely with one of the 3 options above.
Is the project open source for the altis solution?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As far as I can see, they are not generating entries, at least not directly in the project.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Even more so, they state this on the docs
Note: Altis does not manage the host entries for subdomains or custom domains, you'll need to manage those manually, via editing /etc/hosts in Linux / macOS, or C:\Windows\System32\Drivers\etc\hosts in Windows. Altis however tries to detect if those entries do not exist, and outputs the necessary configurations to add to your hosts file.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
that's ok, I'm not seeing any crazy hacks to map it though, they're just saying go to 127.0.0.1
essentially. The caveat being that this might mean local server isn't what responds if it's not active since it isn't that specific container it's mapped to
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the grand scheme of things though, I don't think this is the highest priority, I'd prioritise extracting improvements that aren't strictly docker related that could be merged in advance, and having a docker file to remove the need for the pentatonic docker image so we can layer things in the future
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok, so goodhosts stays for the foreseable future as it solves this problem
about the more prioritary things, totally onboard with doing those that can be merged in advance
@@ -121,7 +121,7 @@ function cleanup_vvv(){ | |||
echo "127.0.0.1 tideways.vvv.test # vvv-auto" >> "/etc/hosts" | |||
echo "127.0.0.1 xhgui.vvv.test # vvv-auto" >> "/etc/hosts" | |||
fi | |||
mv /tmp/hosts /etc/hosts | |||
echo "$(</tmp/hosts)" | sudo tee -a /etc/hosts > /dev/null |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this could be extracted into a separate PR
@@ -125,7 +129,7 @@ function mysql_setup() { | |||
# MySQL gives us an error if we restart a non running service, which | |||
# happens after a `vagrant halt`. Check to see if it's running before | |||
# deciding whether to start or restart. | |||
if [ $(service mariadb status|grep 'mysql start/running' | wc -l) -ne 1 ]; then | |||
if [ $(service mariadb status|grep 'Uptime' | wc -l) -ne 1 ]; then |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this could be extracted into a separate PR
git config --global --add safe.directory '*' # Allow git to work well under docker provider | ||
noroot git config --global --add safe.directory '*' # Allow git to work well under docker provider |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this should be extracted into a separate PR
# /etc/host doesn't survive restart on docker | ||
vvv_info " * Reinit /etc/hosts" | ||
vvv_update_guest_hosts | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
noting this would be better in a dockerfile
@Mte90 @msaggiorato shall we merge this into |
Based on the work from @pentatonicfunk, I didn't have access to their github repo for this so here's a branch
Checks
develop
branch not thestable
branch.