-
-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Overhaul Vagrantfile and bootstrap.sh provisioner.
- Loading branch information
Showing
9 changed files
with
334 additions
and
297 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,32 @@ | ||
Dave's Mapper | ||
============= | ||
# Dave's Mapper | ||
|
||
|
||
This is the code behind [Dave's Mapper](https://davesmapper.com). It's based on the Morph Mapper by Rob Lang, but vastly larger in scope and ambition. | ||
|
||
License | ||
------- | ||
|
||
## Development | ||
|
||
This project includes a Vagrantfile to bundle all necessary dependencies. Locally you will need: | ||
|
||
* git v2.0+ | ||
* [Vagrant](https://www.vagrantup.com/downloads) | ||
* [Virtualbox](https://www.virtualbox.org/wiki/Downloads) | ||
|
||
The included `provision/boostrap.sh` script defines all other system-level dependencies including PHP, Apache and MySQL. | ||
|
||
### Setup | ||
|
||
1. Clone the repo. | ||
2. Run `vagrant up` to download, provision and launch the development box. | ||
* This will take some time during the first execution as the base VM image needs to be downloaded from the internet. | ||
3. This local folder is mapped into the VM's `/app` folder. Changes to files in the project will be updated inside the VM nearly instantaneously. | ||
4. Visit http://localhost:4069 | ||
5. When you are done, run `vagrant down` to halt the configured VM. (Subsequent `vagrant up` commands will boot this already-provisioned VM.) | ||
|
||
Database credentials will be automatically configured in `cgi-bin/db_start.php` to work with Vagrant. This file is gitignore'd to prevent it from being committed back to the repo with sensitive credentials. | ||
|
||
## License | ||
|
||
|
||
Dave's Mapper | ||
Copyright © 2010-2018 David Millar | ||
|
@@ -22,7 +44,7 @@ License | |
You should have received a copy of the GNU General Public License | ||
along with this program. If not, see http://www.gnu.org/licenses/. | ||
|
||
Contact | ||
------- | ||
## Contact | ||
|
||
|
||
I can be reached at [email protected] or [email protected] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,70 @@ | ||
project_name = "mapper" | ||
|
||
Vagrant.configure("2") do |config| | ||
config.vm.box = "hashicorp/bionic64" | ||
config.vm.box_version = "1.0.282" | ||
config.vm.synced_folder ".", "/vagrant" | ||
config.vm.provision :shell, path: ".vagrant/bootstrap.sh" | ||
config.vm.network :forwarded_port, host: 4069, guest: 80 | ||
config.vm.provider "virtualbox" do |v| | ||
conf = { | ||
PROJECT_NAME: 'daves-mapper', | ||
PROJECT_ROOT: '/var/www/daves-mapper', | ||
PROJECT_PORT: 4069, | ||
} | ||
|
||
Vagrant.require_version '>= 2.0.0' | ||
|
||
Vagrant.configure('2') do |config| | ||
config.vm.box = 'bento/ubuntu-20.04' | ||
|
||
config.vm.network :forwarded_port, | ||
host: conf[:PROJECT_PORT], | ||
guest: 80 | ||
config.vm.network :forwarded_port, | ||
host: 3307, | ||
guest: 3306, | ||
auto_correct: true | ||
|
||
config.vm.synced_folder '.', conf[:PROJECT_ROOT] | ||
|
||
config.vm.provider 'virtualbox' do |v| | ||
v.name = "Dave's Mapper Vagrant" | ||
v.gui = false | ||
end | ||
|
||
config.vm.provision :shell, | ||
name: 'bootstrap', | ||
path: 'provision/bootstrap.sh', | ||
args: [ | ||
conf[:PROJECT_ROOT], | ||
"#{conf[:PROJECT_NAME]}.test", | ||
'vagrant' | ||
] | ||
|
||
config.vm.provision :shell, | ||
name: 'vagrant specific', | ||
privileged: false, | ||
inline: <<~VAGRANTONLYSCRIPT | ||
cd #{conf[:PROJECT_ROOT]} | ||
echo '## Creating a limited vagrant-only DB user.' | ||
cat <<SQL | mysql | ||
CREATE USER IF NOT EXISTS 'vagrant'@'%' IDENTIFIED BY 'vagrant'; | ||
GRANT ALL ON daves_mapper.* TO 'vagrant'@'%'; | ||
FLUSH PRIVILEGES; | ||
SQL | ||
if [ ! -f cgi-bin/db_start.php ]; then | ||
echo '## Copying db_start.php into place.' | ||
cp cgi-bin/db_start.php.example cgi-bin/db_start.php | ||
fi | ||
TABLE_COUNT=$(mysql --batch --skip-column-names -e 'SELECT count(*) FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA = "daves_mapper";') | ||
if [ $TABLE_COUNT -gt 0 ]; then | ||
echo '## Importing MySQL schema.' | ||
mysql daves_mapper < provision/schema.sql #TODO this sql file needs to get populated. | ||
fi | ||
echo '## Setting convenience login dir.' | ||
if grep -vq 'cd #{conf[:PROJECT_ROOT]}' ~/.profile; then | ||
echo 'cd #{conf[:PROJECT_ROOT]}' >> ~/.profile | ||
fi | ||
VAGRANTONLYSCRIPT | ||
|
||
# TODO: Define a safety trigger to export MySQL data before destroying the VM. | ||
|
||
config.vm.post_up_message = "VM is up! Visit http://localhost:#{conf[:PROJECT_PORT]}" | ||
end |
Oops, something went wrong.