Skip to content
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

WIP Docker PR #2537

Closed

Conversation

tomjn
Copy link
Member

@tomjn tomjn commented Oct 12, 2021

I don't expect to merge this PR as we'll create new PRs that take subsets of it out, or implement it differently. This will be similar to when we had M1 support, eventually this PR will have little to nothing in it and we can declare success!

Checks

  • I've updated the changelog.
  • I've tested this PR
  • This PR is for the develop branch not the stable branch.
  • This PR is complete and ready for review.

Copy link
Member Author

@tomjn tomjn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some notes

README.md Outdated Show resolved Hide resolved
README.md Outdated
vagrant plugin install --local

# MAC Only ( see: https://docs.docker.com/desktop/mac/networking/#per-container-ip-addressing-is-not-possible )
sudo ifconfig lo0 alias 192.168.50.4/24
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suspect this could be done from the vagrant file, though is the IP always the same?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i was thinking to add it to Vagrantfile, but not quite sure in which part and how to add it properly, basically we can sub 192.168.50.4/24 with vvv_config['vm_config']['private_network_ip'] to make it auto adjust.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The link in the comment doesn't mention the command here, I'm unsure how this is meant to work or where it comes from.

It's also not how I've seen other docker set ups work, how do other docker environments get around this?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

docker in linux have network bridge accessible in host, so we can assign an IP address to a container, and ping or connect to that IP address from host. Meanwhile in Mac, this network bridge is not accessible by the host, so we can't ping or connect to that IP address ( 192.168.50.4 ) and basically the custom domain we added *.test is inaccessible, because goodhosts mapped it to 192.168.50.4

Vagrantfile Outdated Show resolved Hide resolved
Vagrantfile Outdated Show resolved Hide resolved
@@ -432,6 +451,21 @@ Vagrant.configure('2') do |config|
override.vm.box = 'bento/ubuntu-20.04'
end

# Docker use image.
config.vm.provider :docker do |d|
d.image = 'pentatonicfunk/vagrant-ubuntu-base-images:20.04'
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm guessing this image gets built as a part of provisioning?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this image is "built" image already. provisioning only pulling it in.
https://github.com/pentatonicfunk/docker-vagrant-ubuntu-base-images
https://hub.docker.com/repository/docker/pentatonicfunk/vagrant-ubuntu-base-images
what do you think about these ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm happy to completely remove Ubuntu 18 as an option, it's only there for longterm compatibility at the moment, and at some point Ondrej packages for 18 will disappear. As for prebuilt images I'm not sure

provision/core/nginx/config/nginx.conf Outdated Show resolved Hide resolved
Comment on lines +62 to +66
# not included in docker images by default, lets add
iputils-ping
net-tools
nano
less
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

are these needed or are they just useful for developing this?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

less is the most required ( for wp cli ) and its not included in my docker image yet.
i will add these packages to docker image pentatonicfunk/docker-vagrant-ubuntu-base-images#1

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd rather we were explicit about these things for portability

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@pentatonicfunk I added most of these a while back, just added nano in a draft PR seeing if I can take any more of this PR back into VVV core. At least less/net-tools/etc are all listed twice here

provision/core/vvv/provision.sh Outdated Show resolved Hide resolved
provision/provision-helpers.sh Outdated Show resolved Hide resolved
Comment on lines 550 to 555
function get_vvv_sites() {
local sites=$(shyaml -q keys "sites" <${VVV_CONFIG})
echo "${sites}"
}

function re_init_etc_hosts() {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

vvv_get_sites and vvv_update_guest_hosts

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tomjn added a commit that referenced this pull request Oct 12, 2021
@tomjn tomjn mentioned this pull request Oct 12, 2021
4 tasks
tomjn added a commit that referenced this pull request Oct 12, 2021
It seems it's already disabled

Taken from #2537:

```
        # text/html Responses with the “text/html” type are always compressed. https://nginx.org/en/docs/http/ngx_http_gzip_module.html#gzip_types
```

https://nginx.org/en/docs/http/ngx_http_gzip_module.html#gzip_types
@pentatonicfunk
Copy link
Contributor

@tomjn totally agree with you, this fork and PR merely a PoC and reference for the future when we actually start to fully support docker -- that if we really want to, and won't be a pain point to maintain.

And if there are any stuff here that can improve VVV in general, we can can just cherry pick it and make mini separate PRs like you already did. I don't even expect this to be merged at all, my main intention was to experiment, see how VVV will behave ( especially the provision part ) if i do use it with docker in certain way ( monolithic way ), and push my self to make it somewhat usable, and hopefully some good things get picked up after that.

As for services based containers ( docker-compose kind of ? ), that seems like the standard / ideal way in docker world. Although for development, based on my own personal experience, i can't say that i am comfortable with multi containers, having to interact with different container for different task is tedious. e.g. when i need to interact with mysql i need to go to mysql container, but if i wanna quick modify nginx config i need to interact with nginx container and so on. Meanwhile in development phase, these kind of tasks are often needed to be done and done quickly. Again, its just me. I am not familiar and not get used to it. One of the nice thing i love about VVV / vagrant, is that vagrant ssh and hack everything i want inside that single shell instance, be it modify nginx config or just tailing specific logs.

PS: i really got great input and insights from here, thanks a lot for doing it!

@tomjn tomjn mentioned this pull request Nov 12, 2021
4 tasks
tomjn and others added 8 commits November 15, 2021 11:03
# Conflicts:
#	config/homebin/vagrant_provision
#	config/homebin/vagrant_up
#	provision/core/env/provision.sh
#	provision/core/mailhog/provision.sh
#	provision/core/mariadb/provision.sh
#	provision/core/nginx/config/nginx.conf
#	provision/provision-helpers.sh
#	provision/provision.sh
…beta

# Conflicts:
#	README.md
#	provision/provision-helpers.sh
@tomjn tomjn mentioned this pull request Sep 1, 2022
4 tasks
if [ "${VVV_DOCKER}" != 1 ]; then
check_mysql_root_password
fi

# 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
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this doesn't work on Parallels based VMs and maybe others, would it not be better to check for running or active?

if [ "${VVV_DOCKER}" != 1 ]; then
service mailhog restart
fi
killall mailhog; /usr/bin/env /usr/local/bin/mailhog > /dev/null 2>&1 &
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what happens if you run sudo service mailhog restart on the docker VM?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

at the moment it saysmailhog: unrecognized service

vagrant@vvv:~$ sudo service mailhog restart
mailhog: unrecognized service
vagrant@vvv:~$

@@ -1,7 +1,7 @@
# Create the unit tests DB.
CREATE DATABASE IF NOT EXISTS `wordpress_unit_tests`;
GRANT ALL PRIVILEGES ON `wordpress_unit_tests`.* TO 'wp'@'localhost' IDENTIFIED BY 'wp';
GRANT ALL PRIVILEGES ON `wordpress_unit_tests`.* TO 'wp'@'192.168.50.1' IDENTIFIED BY 'wp';
GRANT ALL PRIVILEGES ON `wordpress_unit_tests`.* TO 'wp'@'192.168.56.1' IDENTIFIED BY 'wp';
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could these lines co-exist rather than requiring an IP change? Is there a specific reason the IP is needed? E.g. for external use?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

to be honest i dont know what should be the correct one here, i think the only reason i changed it is we changed the default private ip network here: 39ee551

adding both / co-exists also fine

GRANT ALL PRIVILEGES ON `wordpress_unit_tests`.* TO 'wp'@'192.168.50.1' IDENTIFIED BY 'wp';
GRANT ALL PRIVILEGES ON `wordpress_unit_tests`.* TO 'wp'@'192.168.56.1' IDENTIFIED BY 'wp';

not sure if thats the correct thing though.

external use, no. and its not required by / related with docker

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah in that case lets kill the 50.1 line, but I wouldn't expect local loopback to go over that network inside the container

Comment on lines +40 to +48
vvv_info " * Restarting PHP-FPM"
find /etc/init.d/ -name "php*-fpm" -exec bash -c 'sudo service "$(basename "$0")" restart' {} \;

vvv_info " * Restarting Memcache"
sudo service memcached restart

vvv_info " * Restarting Mailhog"
/usr/bin/env /usr/local/bin/mailhog > /dev/null 2>&1 &

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

these could be separate functions so that we don't have to introduce docker specifics in these files, and can put them all in one place without duplication

@tomjn
Copy link
Member Author

tomjn commented Sep 1, 2022

@pentatonicfunk I've started a PR to see what more I can merge into VVV core, and left some more comments to try and clarify or suggest some things, I'm a little strapped for time today but intend to give this a proper run test sometime this week

@pentatonicfunk
Copy link
Contributor

thanks @tomjn, i'll try to update my repo as per your suggestions

@tomjn
Copy link
Member Author

tomjn commented Sep 13, 2022

@pentatonicfunk I've started #2632 as I couldn't modify this branch, and merged some changes and made others compatible with non-docker.

Would you like to continue there if I add you as a repo member? We're not far from getting this in and it's a big milestone

@pentatonicfunk
Copy link
Contributor

yes for sure

@tomjn
Copy link
Member Author

tomjn commented Nov 13, 2022

closing this as we have #2632

@tomjn tomjn closed this Nov 13, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants