Github repository for The Venus Project's website
Vagrant allows you to run a virtual machine (vm) on your computer and do your development work within the vm. It can automate the installation and configuration of an operating system in the vm, including the installation and configuration of any software packages you want. It also can keep folders in sync between your host OS and your guest OS (on the vm).
In the vagrant
directory here are included configuration files and shell scripts for an automated creation of a full LAMP stack with all needed configurations and software packages for running the TVP website.
To get started with Vagrant:
- Install the Vagrant package
- Install VirtualBox - this provides the vm functionality
- Go through the Vagrant Getting Started Guide (this is only for learning)
- Place the
Vagrantfile
,bootstrap.sh
andstartup.sh
files in the root Vagrant directory on your host OSVagrantfile
contains general setup instructions for your vagrant boxbootstrap.sh
instructions get executed when provisioning the vagrant box (i.e. installing or reinstalling the guest OS)startup.sh
instructions get executed each time you start the guest OS (i.e. onvagrant up
)
- Create on your host OS the directories that will be synced between host and guest OS:
- Create
var_log
inside the root Vagrant directory on your host OS. - Create
sites-available
inside the root Vagrant directory on your host OS. - Put the
000-default.conf
file insidesites-available
. This is Ubuntu's file for virtual hosts.
- Create
- Add newtvp.example.com to your hosts file on your host OS, map it to 127.0.0.1 (instructions)
- Create
newtvp
directory inside the root Vagrant directory on your host OS.
Troubleshooting
- If you get the error Errno::EADDRNOTAVAIL when doing
vagrant up
, see this comment.
Debugging:
- How to configure Xdebug in PhpStorm through Vagrant
- Some more info on debugging webhooks
- Debugging with PHPStorm and the PODS framework
Path mappings:
Q: In phpstorm, I have to set up path mappings. does this mean that I have to keep two repositories - one in my host OS and one in the guest OS? even though the one in the guest OS is shared between the two?
A: Vagrant shares the folders, so you only maintain one repo, but for the remote debugging to work, it needs to know where to map them to inside of vagrant
If you choose to use Docker for your working environment you'll need first to install Docker in your machine: https://docs.docker.com/engine/installation/
Afterwards you should follow these steps for using Docker in your The Venus Project development site:
- Copy
.env.dist
file to.env
and fill in missing values which you can find in your originalwp-config.php
. - Copy your original
wp-content
directory from server or backup todocker/www/wp-content/
directory. - Run
$ docker-compose up
. You should see thatwordpress
container has been started successfully:NOTICE: ready to handle connections
. - Import DB backups as follows (order matters, because dumps overlap on
civicrm_*
tables):docker-compose run --rm -v /full/path/to/_wordpressdb.sql:/dump.sql db sh -c 'mysql -hdb -uroot -p"$MYSQL_ROOT_PASSWORD" "$MYSQL_DATABASE" < /dump.sql'
docker-compose run --rm -v /full/path/to/_civicrmdb.sql:/dump.sql db sh -c 'mysql -hdb -uroot -p"$MYSQL_ROOT_PASSWORD" "$MYSQL_DATABASE" < /dump.sql'
- Run
$ docker-compose run --rm wordpress php tools/init.php
. - Run
$ docker-compose run --rm wordpress php tools/update-site-domain.php localhost:8080
. - Grant write permissions to the web-server, e.g.:
HTTPDUSER=www-data
sudo setfacl -dR -m u:"$HTTPDUSER":rwX -m u:$(whoami):rwX docker/www
sudo setfacl -R -m u:"$HTTPDUSER":rwX -m u:$(whoami):rwX docker/www
Now you have several endpoints to work with:
http://localhost:8080/
- The Venus Project development website.http://localhost:8081/
- Adminer DB interface to make DB administration easier.http://localhost:8082/
- MailHog, mail debugger. All emails from WordPress and CiviCRM are redirected to MailHog SMTP server (seemail
container) and are displayed on this nice web interface.
To setup your admin password go to My Account -> Lost password and restore password for the user thevenusproject
. Check your inbox in MailHog and follow the instructions.
More info in these tutorials:
- https://codeable.io/wordpress-developers-intro-docker/
- https://codeable.io/wordpress-developers-intro-to-docker-part-two/
The file tvp-auto.php
automates the creation of the TVP website from filesystem and database backups.
The file ngrok-auto.php
automates the changing of the TVP website's domain (on your local environment). This becomes useful when you need to often change the local domain that the site runs on, for example when you are using a tool like ngrok (since ngrok runs on a new domain every time you start it). ngrok comes quite handy when you are testing webhooks (e.g. from Stripe and Paypal) and you need to expose the local website to the Internet in order for the webhooks to reach it. For more information on ngrok, see their docs.
If you use docker, you can run ngrok
from a docker image:
- Run
$ docker run --rm -it --net=host wernight/ngrok ngrok http localhost:8080
- Run
$ docker-compose run --rm wordpress php tools/update-site-domain.php yourtempdomain.ngrok.io
ngrok
web interface is accessible by visitinghttp://localhost:4040
- When you are done using
ngrok
, restore your site URL to localhost:$ docker-compose run --rm wordpress php tools/update-site-domain.php localhost:8080
The tests.zip
file contains a backup of the git repository that we have on Bitbucket. It contains our automated acceptance tests.