This is the first in a series setting up a basic DevOps pipeline through local virtual machines, GitLab, a dev server, a staging server, and a production server. This first post will look at the local VM setup. The next step will move on to using this local VM in connection with GitLab for version control and CI/CD.
Oracle Linux 8 LAMP stack
The first script, provision.sh, sets up the basic VM with a LAMP stack:
That’s a nice generic LAMP stack. If you want an Oracle Linux 8 LAMP stack for some other purpose, you can stop there.
Drupal 9 local dev
In my case, the purpose of this vagrant box is for the first stage of development on a Drupal 9 website. So I’m going to go a few steps further to get it ready for the specific Drupal 9 project. That includes:
- Sync the user’s SSH key from their computer’s folder to the vagrant user’s home folder, so that it can be used to connect to GitLab
- Configures git including pulling the latest version of the code from the GitLab
- Imports a MySQL database if one is provided
- Self-signed keys so that https browsing will be possible
I may write up specific details of some of these later, but the bottom line is the code in GitHub. This part is in the provision script d9.sh, which also references a separate script specifically for the database import called importdb.sh.
The user experience
The idea is that at the end of this, the person setting up their machine has very few steps:
Git clonethe repo for building the virtual machine on their PC
- Put a copy of the database to import, if available, in the specified location
- Put a copy of the SSH key into the specified location
vagrant upto build the virtual machine
- SSH into the VM and then run the separate script for the Drupal 9 components
- Optionally add the dev URL to the hosts file of their computer so that it is browsable at the URL and not just at localhost