Vagrant is designed to run on multiple platforms, including Mac OS X, Microsoft Windows, Debian, Ubuntu, CentOS, RedHat and Fedora. In this document we describe how to configure and run CodeWorkout project virtual development environment through Vagrant.
- Install Vagrant
- Install VirtualBox
- Clone this repository
$ cd code-workout
$ vagrant up
$ vagrant ssh
$ . /vagrant/runservers.sh
- After the provisioning script is complete you can go to:
- https://192.168.33.20:9292 for CodeWorkout server
After you finish your work, you need to turn the virtual machine off.
- Exit the virtual machine terminal by typing
exit
$ cd code-workout
$ vagrant halt
If you decided to shut down the virtual machine using vagrant halt
, you have to re-run the servers again after you do vagrant up
.
$ cd code-workout
$ vagrant up
$ vagrant ssh
$ cd /vagrant
$ rails server
If anything went wrong or you want to reprovision your virtual machine for any reason, follow these steps.
$ cd code-workout
$ git pull
$ vagrant destroy
$ vagrant up
sudo password is vagrant
in case you need to execute any commands that require sudo.
The initial database population is defined by lib/tasks/sample_data.rake. It uses the factories defined in spec/factories/* to generate entities. If you add new modael classes and want to generate test data in the database, please add to the sample_data.rake file so that this population will happen automatically for everyone. The sample_data.rake contains only "sample/try out" data for use during development, and it won't appear on the production server. Initial database contents provided for all new installs, including the production server, is described in db/seeds.rb instead.
-
The initial database includes the following accounts:
- [email protected] (pass: adminadmin), has admin-level access
- [email protected] (pass: hokiehokie), has instructor access
- example-*@railstutorial.org (pass: hokiehokie) 50 students
It also includes the following other objects:
- six terms (spring, summer I, summer II, fall, and winter 2016),
- one organization (VT)
- one course (CS 1114)
- two offerings of 1114 (one each semester)
- one course offering is set up with the admin and instructor as instructors, and all other sample accounts as students
-
To reset the database to the initial state do the following:
$ cd code-workout
$ vagrant ssh
$ cd /vagrant
$ rake db:populate
$ rails server
During development of code-workout, other developers might add new gems to the project or add new migrations etc. To keep your local version up to date with the latest version do the following:
- Open a new terminal
$ cd code-workout
$ git pull
$ vagrant reload
$ vagrant ssh
$ cd /vagrant
$ sudo bundle install
$ rake db:populate
Note: This step will place the database in a simple starter state.$ . /vagrant/runservers.sh
- Log in using your admin account [email protected] (pass: adminadmin)
- Click "Upload Exercises" in the navigation bar, then click "Choose File". Choose your exercise file and click "Submit File".
- Click "Create Workouts" in the navigation bar to create new workouts.
- Go to the admin area by clicking on the little wrench icon to the left of the admin email address in the top menu bar. Click the "University-oriented" menu and select "Workout offerings". Click on "New Workout Offering". Create your new workout offering by choosing the course offering and the workout (the one you have just created in the previous step). Then select appropriate opening, soft deadline, and hard deadline dates for the workout offering and hit "Create Workout Offering" button to save it.
- Log in using student account [email protected] (pass: hokiehokie). Then navigate to the course offering you have chosen in the previous step, you should see the new workout in the list of workouts for this course offering.
During development it is convenient to connect to CodeWorkout database from your host machine using MySQL Workbench. Once you installed MySQL Workbench create a new connection to CodeWorkout Database in the Vagrant machine using the following setup:
- Connection Name: CodeWorkout
- Connection Method: Standard TCP/IP over SSH
- SSH Hostname: 192.168.33.20
- SSH Username: vagrant
- SSH Password: vagrant
- MySQL Hostname: 127.0.0.1
- MySQL Server Port: 3306
- Username: codeworkout
- Password: codeworkout