remove everything about vagrant

This commit is contained in:
Andrew Schleifer 2018-04-04 15:04:31 -05:00 committed by Sam
parent 17f12c0ce4
commit 1ba953077e
7 changed files with 3 additions and 238 deletions

5
.gitignore vendored
View File

@ -19,8 +19,6 @@ public/tombstone/*
# Ignore bundler config
/.bundle
/.vagrant
/.vagrantfile
/cache
/coverage/*
@ -95,9 +93,6 @@ config/fog_credentials.yml
script/download_db
script/refresh_db
# temp directory for chef (used to configure vagrant VM)
chef/tmp/*
# .procfile
.procfile

View File

@ -22,7 +22,7 @@ Browse [lots more notable Discourse instances](https://www.discourse.org/custome
## Development
1. If you're **brand new to Ruby and Rails**, please see [**Discourse as Your First Rails App**](http://blog.discourse.org/2013/04/discourse-as-your-first-rails-app/) or our [**Discourse Vagrant Developer Guide**](docs/VAGRANT.md), which includes a development environment in a virtual machine.
1. If you're **brand new to Ruby and Rails**, please see [**Discourse as Your First Rails App**](http://blog.discourse.org/2013/04/discourse-as-your-first-rails-app/).
2. If you're familiar with how Rails works and are comfortable setting up your own environment, use our [**Discourse Advanced Developer Guide**](docs/DEVELOPER-ADVANCED.md).

48
Vagrantfile vendored
View File

@ -1,48 +0,0 @@
# -*- mode: ruby -*-
# vi: set ft=ruby :
# See https://github.com/discourse/discourse/blob/master/docs/VAGRANT.md
#
Vagrant.configure("2") do |config|
config.vm.box = 'discourse-16.04'
config.vm.box_url = "https://www.dropbox.com/s/2132770g1e05c6d/discourse.box?dl=1"
# Make this VM reachable on the host network as well, so that other
# VM's running other browsers can access our dev server.
config.vm.network :private_network, ip: "192.168.10.200"
# Make it so that network access from the vagrant guest is able to
# use SSH private keys that are present on the host without copying
# them into the VM.
config.ssh.forward_agent = true
config.vm.provider :virtualbox do |v|
# This setting gives the VM 1024MB of RAM instead of the default 384.
v.customize ["modifyvm", :id, "--memory", [ENV['DISCOURSE_VM_MEM'].to_i, 1024].max]
# Who has a single core cpu these days anyways?
cpu_count = 2
# Determine the available cores in host system.
# This mostly helps on linux, but it couldn't hurt on MacOSX.
if RUBY_PLATFORM =~ /linux/
cpu_count = `nproc`.to_i
elsif RUBY_PLATFORM =~ /darwin/
cpu_count = `sysctl -n hw.ncpu`.to_i
end
# Assign additional cores to the guest OS.
v.customize ["modifyvm", :id, "--cpus", cpu_count]
v.customize ["modifyvm", :id, "--ioapic", "on"]
# This setting makes it so that network access from inside the vagrant guest
# is able to resolve DNS using the hosts VPN connection.
v.customize ["modifyvm", :id, "--natdnshostresolver1", "on"]
end
config.vm.network :forwarded_port, guest: 3000, host: 4000
config.vm.network :forwarded_port, guest: 1080, host: 4080 # Mailcatcher
nfs_setting = RUBY_PLATFORM =~ /darwin/ || RUBY_PLATFORM =~ /linux/
config.vm.synced_folder ".", "/vagrant", id: "vagrant-root"
end

View File

@ -1,6 +1,6 @@
# Discourse Advanced Developer Install Guide
This guide is aimed at advanced Rails developers who have installed their own Rails apps before. If you are new to Rails, you are likely much better off with our **[Discourse Vagrant Developer Guide](VAGRANT.md)**.
This guide is aimed at advanced Rails developers who have installed their own Rails apps before.
Note: If you are developing on a Mac, you will probably want to look at [these instructions](DEVELOPMENT-OSX-NATIVE.md) as well.

View File

@ -1,4 +1,4 @@
# Developing under OS X Without Vagrant
# Developing under OS X
These instructions assume you have read and understood the **[Discourse Advanced Developer Install Guide](DEVELOPER-ADVANCED.md)**.

View File

@ -1,164 +0,0 @@
# Discourse Developer Install Guide (Vagrant)
### If you are on a Mac or PC, please try our [Discourse as Your First Rails App](http://blog.discourse.org/2013/04/discourse-as-your-first-rails-app/) blog post first!
(If you have experience setting up Rails projects, you might want to take a look at our **[Discourse Advanced Developer Guide](DEVELOPER-ADVANCED.md)**. It also contains instructions on building your own Vagrant VM.)
The following instructions will automatically download and provision a virtual machine for you to begin hacking
on Discourse with:
### Getting Started
1. Install Git: http://git-scm.com/downloads (or [GitHub for Windows](http://windows.github.com/) if you want a GUI)
2. Install VirtualBox: https://www.virtualbox.org/wiki/Downloads
3. Install Vagrant: http://www.vagrantup.com/ (We require Vagrant 1.7.2 or later)
4. Open a terminal
5. Clone the project: `git clone https://github.com/discourse/discourse.git`
6. Enter the project directory: `cd discourse`
### Using Vagrant
When you're ready to start working, boot the VM:
```
vagrant up
```
Vagrant will prompt you for your admin password. This is so it can mount your local files inside the VM for an easy workflow.
(The first time you do this, it will take a while as it downloads the VM image and installs it. Go grab a coffee.)
**Note to Linux users**: Your Discourse directory cannot be on an ecryptfs mount or you will receive an error: `exportfs: /home/your/path/to/discourse does not support NFS export`
**Note to OSX/Linux users**: Vagrant will mount your local files via an NFS share. Therefore, make sure that NFS is installed or else you'll receive the error message:
```
Mounting NFS shared folders failed. This is most often caused by the NFS
client software not being installed on the guest machine. Please verify
that the NFS client software is properly installed, and consult any resources
specific to the linux distro you're using for more information on how to
do this.
```
For example, on Ubuntu, you can install NFS support by installing nfs-kernel-server with `apt-get install`.
Once the machine has booted up, you can shell into it by typing:
```
vagrant ssh
```
The discourse code is found in the /vagrant directory in the image.
**Note to Windows users**: You cannot run ```vagrant ssh``` from a cmd prompt; you'll receive the error message:
```
`vagrant ssh` isn't available on the Windows platform. You are still able
to SSH into the virtual machine if you get a Windows SSH client (such as
PuTTY). The authentication information is shown below:
Host: 127.0.0.1
Port: 2222
Username: vagrant
Private key: C:/Users/Your Name/.vagrant.d/insecure_private_key
```
At this point, you will want to get an SSH client, and use it to connect to your Vagrant VM instead. We recommend
PuTTY:
**[PuTTY Download Link](http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html)**
You may use this client to connect to the VM by using ```vagrant/vagrant``` as your username/password, or by [using
PuTTYGen to import the insecure_private_key file](http://jason.sharonandjason.com/key_based_putty_logins_mini_how_to.htm)
(mentioned above) into a PuTTY profile to quickly access your VM.
### Keeping your VM up to date (and first install)
Now you're in a virtual machine is almost ready to start developing. It's a good idea to perform the following instructions
*every time* you pull from master to ensure your environment is still up to date.
```
cd /vagrant
bundle install
bundle exec rake db:migrate
```
### Starting Rails
Once your VM is up to date, you can start a rails instance using the following command from the /vagrant directory:
```
bundle exec rails s -b 0.0.0.0
```
In a few seconds, rails will start serving pages. To access them, open a web browser to [http://localhost:4000](http://localhost:4000) - if it all worked you should see discourse! Congratulations, you are ready to start working!
You can now edit files on your local file system, using your favorite text editor or IDE. When you reload your web browser, it should have the latest changes.
### Creating an Admin User
You'll want an admin account to be able to do anything fun on your new Discourse environment. Enter your vagrant image by using `vagrant ssh` then
run the following command and follow the instructions:
```bash
bundle exec rake admin:create
```
Your admin account should be approved. Log in in your browser and you're good to go!
### Tests
If you're actively working on Discourse, we recommend that you run rake autospec, which will run the specs. Its very, very smart. Itll abort very long test runs. So if it starts running all of the specs and then you just start editing a spec file and save it, it knows that its time to interrupt the spec suite, run this one spec for you, then itll keep running these specs until they pass as well. If you fail a spec by saving it and then go and start editing around the project to try and fix that spec, itll detect that and run that one failing spec, not a hundred of them.
To use it, follow all the above steps. Once rails is running, open a new terminal window or tab, and then do this:
```
vagrant ssh
cd /vagrant
RAILS_ENV=test bundle exec rake db:migrate
bundle exec rake autospec p l=5
```
When developing a plugin (the *poll* plugin for instance), the following can be used to only run all tests from the *spec* directory:
```
bundle exec rake plugin:spec poll
```
or just a single file with:
```
LOAD_PLUGINS=1 bundle exec rspec plugins/poll/spec/controllers/posts_controller_spec.rb
```
For more insight into testing Discourse, see [this discussion](http://rubyrogues.com/117-rr-discourse-part-2-with-sam-saffron-and-robin-ward/) with the Ruby Rogues.
### Sending Email
Mail is sent asynchronously by Sidekiq, so you'll need to have sidekiq running to process jobs. Run it with this command in the /vagrant directory:
```
bundle exec sidekiq
```
Mailcatcher is used to avoid the whole issue of actually sending emails: https://github.com/sj26/mailcatcher
Mailcatcher is already installed in the vm, and there's an alias to launch it:
```
mailcatcher --http-ip=0.0.0.0
```
Running the above command might throw out the `'method_missing'` error in the terminal. This can be fixed by upgrading rubygems to the latest version which can be done by running the following in the /vagrant directory:
```
gem update --system
```
Then in a browser, go to [http://localhost:4080](http://localhost:4080). Sent emails will be received by mailcatcher and shown in its web ui.
### Shutting down the VM
When you're done working on Discourse, you can shut down Vagrant with:
```
vagrant halt
```

View File

@ -1,18 +0,0 @@
# GNU screen configuration file for Discourse vagrant image
# Start up development support commands in detached mode:
# screen -d -m -c docs/vagrant.screen
# Start in attached mode:
# screen -m -c docs/vagrant.screen
# commands that exit hang around until you hit 'k' to kill or 'r' to restart
zombie kr
screen -t rails_s 0 bash -c 'echo Starting rails server...; cd /vagrant; bundle exec rails s -b 0.0.0.0'
screen -t rails_c 1 bash -c 'echo Starting rails console...; cd /vagrant; bundle exec rails c'
screen -t sidekiq 2 bash -c 'echo Starting sidekiq...; cd /vagrant; bundle exec sidekiq -l log/sidekiq.log'
screen -t mail 3 bash -c 'echo Starting mailcatcher...; cd /; mailcatcher --ip 0.0.0.0'
screen -t bash 4 bash
scrollback 50000