-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathVagrantfile
More file actions
273 lines (264 loc) · 11.2 KB
/
Vagrantfile
File metadata and controls
273 lines (264 loc) · 11.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
# -*- mode: ruby -*-
# vi: set ft=ruby :
#
# Welcome to PressBoxx!
#
# The EASIEST Way to Setup a Local WordPress Development
# Environment, using Vagrant
#
# Brought to you by The PressBoxx Team:
#
# - http://github/pressboxx
#
# README FIRST!:
#
# Before you jump down into the the docs in this file you should
# probably just skim the README.md first:
#
# - https://github.com/pressboxx/pressboxx/blob/master/README.md
#
# BACKGROUND:
#
# You typically find this named "Vagrantfile" as the result of
# running the followingcommands:
#
# - git clone https://github.com/pressboxx/pressboxx
# - cd pressboxx
#
# INITIAL USAGE:
#
# Once you have this Vagrantfile and assuming you have already
# VirtualBox, Vagrant and the two (2) required Vagrant plugins
# installed (see the README mentioned above if you do not) then
# you can start your PressBoxx Box with this one (1) simple command
# from your terminal window on Mac OS X or Linux or via git-bash
# or PowerShell on Windows (again, see the README):
#
# - vagrant up
# - open "pressboxx.box"
#
# The second line just opens the pressboxx.box within your default
# browser, or you can do it manually by opening your browser and
# navigating to http://pressboxx.box.
#
# If that did not work some reason that try reloading with the
# "reprovision" option:
#
# - vagrant reload --provision
# - open "pressboxx.box"
#
# If that still did not work, try our the troubleshooting FAQ:
#
# - https://github.com/pressboxx/pressboxx/blob/master/FAQ.md#troubleshooting
#
# REFERENCE:
#
# File.write('IP', "10.10.10.#{rand(10..250)}") if not File.exists?('IP')
#
# This line creates a randomly-generated and non-routable IP
# address starting with 10.10.10. and randomly selects the
# final octet between 10 and 250. It then writes the IP
# address to a file named 'IP' in the project's root folder
# which is the same folder where this Vagrantfile is found
# to ensure future runs of "vagrant up" or "vagrand reload"
# will use the same IP address.
#
# The assumption here is that it is very unlikely that this
# randomly-generated IP address will conflict with anything
# that is already on the host computer's local network, or
# at least make it less likely to see a conflict than if we
# picked a well-known static IP address that every PressBoxx Box
# would start with.
#
# Thus we believe that using a randomly-generated IP address
# will make it easier for more than 99% of developers who
# choose to at least evaluate PressBoxx Box, although someone
# may occasionally need to debug why it is not working.
#
# If we can find a better approach later, we will be happy
# to switch to it.
#
# config.vm.box = "pressboxx/pressboxx"
#
# This line specifies the VM "box" image which is hosted for
# download on Hashicorp's Atlas Vagrant Box Repository here:
#
# https://atlas.hashicorp.com/pressboxx/boxes/pressboxx
#
# This box image is a pre-provisioned Ubuntu Linux 14.04 LTS
# with nginx, MySQL, PHP5.6 and more; essentially everything
# a Linux server needs to be able to serve WordPress pages.
#
# In many ways -- compared to Vagrant boxes like VVV and VIP
# Quickstart -- this is PressBoxx's "secret sauce."
#
# config.vm.hostname = "pressboxx.box"
#
# This line specifies the domain name your browser should be
# able to load the WordPress site running inside this box.
#
# To CHANGE the domain name to use to when loading the box's
# website in your browser you only need to change this line;
# change "pressboxx.box" to your preferred local domain name and
# then run "vagrant reload" in your terminal.
#
# Of course your computer's hosts file must contain the IP
# address used by the box for your browser to use it to load
# WordPress but if you have the Vagrant hosts-updater plugin
# then it will handle updating the hosts file for you.
#
# config.vm.network 'private_network', ip: IO.read('IP').strip
#
# This line tells Vagrant what IP address to use for the VM.
# It loads the IP address from the file named "IP" that
# previously created by the script `/scripts/before-vagrant.sh`
#
# The IP file can be found in in the project root after the
# first "vagrant up"; the project root is the same directory
# that contains this Vagrantfile.
#
# If you want to specify a specfic IP address you can either
# edit the "IP" file, or you can change the line which
# contains "private_network" and instead hardcode the IP
# address into the Vagrantfile; as in the following example:
#
# config.vm.network 'private_network',ip:"192.168.99.99"
#
# config.vm.synced_folder "www", "/var/www"
#
# This line tells Vagrant to "mount" the "www" folder in the
# host computer's project's folder and on peer with this
# Vagrantfile as a symlink named "/var/www" inside the VM.
#
# The folder "/var/www" inside the virtual machine and is
# where the nginx web server running in the VM will look for
# it's website root.
#
# The upshot of this is it will allow a developer to store
# all of a project's source code on their host computer
# and yet still have the nginx server in the VM reload the
# files instantaneously after an edit (assuming the user
# presses the refresh key on the browser. We do not have any
# a fully automatic refresh built into PressBoxx Box, yet.)
#
# Further, developers will not have to worry about loosing
# uncommitted source code if the VM is delete or otherwise
# corrupted because all source will be on the developer's
# computer, where it belongs.
#
# config.ssh.forward_agent = true
#
# This line enables the virtual machine (or the provisoners
# like Ansible or Puppet if PressBoxx Box used them) to access
# Git or Bitbucket repositories on behalf of the developer's
# Git or BitBucket accounts by allowing the SSH "agent" on
# the developer's machine by 'forwarding' the user's SSH key
# stored on the developer's machine.
#
# PressBoxx Box does NOT _currently_ need this but we have plans
# that will require it so it is easier to simply include it
# now.
#
# To learn more about Vagrant and SSH Agent Forwarding here
# is a well-written blog post that explains it well:
#
# - https://www.phase2technology.com/blog/running-an-ssh-agent-with-vagrant/
#
# In addition you can find more detailed technical info on
# GitHub's website here:
#
# - https://developer.github.com/guides/using-ssh-agent-forwarding/
#
# config.ssh.insert_key = false
#
# This line tells Vagrant not to insert a new private/public
# SSH key pair and to go ahead and use the insecure SSH key
# pair published by Hashicorp to that normally simplifies
# using SSH with Vargant VMs.
#
# This configuration option is used with "forward_agent" as
# the box uses the SSN key from the host aka developer's
# machine instead of using an insecure private key pair.
#
# The security is not really the concern here since VMs used
# for development rarely need to be secure. Instead this
# option simply assumes the developer has an SSH key already
# installed on their computer so it uses it instead.
#
# See these links to learn more about "insert_key"
#
# - https://github.com/mitchellh/vagrant/tree/master/keys
# - https://twitter.com/mitchellh/status/525704721714012160
#
# config.vm.provision "shell", path: "scripts/provision.sh"
#
# This line tells Vagrant to run the bash script named
# "provision.sh" found in the "scripts" folder which is in
# the same folder where Vagrantfile is located.
#
# This provision script runs a few quick commands, such as
# importing "/sql/default.sql" which is the default MySQL
# file, and symlinking the "object-cache.php" file into the
# "/wp-content/" folder from the folder of the plugin that
# provides it.
#
# This provision script will only be run the first time a
# "vagrant up" command is run, or when the "--provision"
# option is selected when running "vagrant reload."
#
# REUSE:
#
# When you cloning the PressBoxx Box repository you are getting an
# "appliance" for WordPress local development that is designed
# to "just work" if at all possible.
#
# However once comfortable with PressBoxx Box few developers will
# want to start a problem by first using "git clone" on the
# github.com/pressboxx/pressboxx repository. In point of fact, we
# don't even use PressBoxx Box in that manner.
#
# Instead developers will want a recipe for how to use PressBoxx
# Box in their projects with the least effort required. And
# that is exactly how PressBoxx Box is intended to be used once
# a developer becomes familiar with it.
#
# TO START A NEW PROJECT using WPlib Box, or to use WPlib Box on
# and existing project is as simple as:
#
# 1. Copy this file into a new Vagrantfile in your project.
#
# 2. Change config.vm.hostname = "pressboxx.box" to replace the
# value of "pressboxx.box" with the local development domain
# of your project, e.g. "dev.example.com"
#
# 3. Either delete the link with config.vm.provision "shell"
# or copy "scripts/provision.sh" and modify it to run
# any simply provisioning you need for your project such
# as symlinking "object-cache.php", if applicable.
#
# 4. Run "vagrant up" in your projects folder where your
# Vagrantfile is located.
#
# 5. And that is it! No more steps. :-)
#
# Once you've done the above you should be able to load your
# project's URL into your browser.
#
# But if that did not work try our troubleshooting FAQ here:
#
# - https://github.com/pressboxx/pressboxx/blob/master/FAQ.md#troubleshooting
#
Vagrant.configure(2) do |config|
File.write('IP', "10.10.10.#{rand(10..250)}") if not File.exists?('IP')
config.vm.box = "PressBoxx/vm"
config.vm.hostname = "pressboxx.local"
config.hostsupdater.aliases = [
"api.pressboxx.local",
"adminer.pressboxx.local",
"mailhog.pressboxx.local"
]
config.vm.network 'private_network', ip: IO.read('IP').strip
config.vm.synced_folder "www", "/var/www"
config.ssh.forward_agent = true
config.ssh.insert_key = false
end