mirror of
https://github.com/openSUSE/osem.git
synced 2026-08-13 19:54:02 +00:00
Setup vagrant file for development
This commit is contained in:
parent
6e9a8bbd59
commit
f3549a21d9
4 changed files with 147 additions and 34 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
|
@ -30,3 +30,4 @@ pickle-email-*.html
|
||||||
/bundle
|
/bundle
|
||||||
/doc/app
|
/doc/app
|
||||||
.ruby-version
|
.ruby-version
|
||||||
|
.vagrant/
|
||||||
|
|
|
||||||
63
INSTALL.md
63
INSTALL.md
|
|
@ -3,54 +3,49 @@ You can run rails apps in different modes (development, production). For more in
|
||||||
about rails and what it can do, see the [rails guides.](http://guides.rubyonrails.org/getting_started.html)
|
about rails and what it can do, see the [rails guides.](http://guides.rubyonrails.org/getting_started.html)
|
||||||
|
|
||||||
### Run OSEM in development
|
### Run OSEM in development
|
||||||
1. Clone the git repository to the directory you want Apache to serve the content from.
|
We are using [Vagrant](https://www.vagrantup.com/) to create our development environments.
|
||||||
|
|
||||||
```
|
1. Install [Vagrant](https://www.vagrantup.com/downloads.html) and [VirtualBox](https://www.virtualbox.org/wiki/Downloads). Both tools support Linux, MacOS and Windows.
|
||||||
git clone https://github.com/openSUSE/osem.git
|
|
||||||
```
|
|
||||||
|
|
||||||
2. Install all the ruby gems.
|
2. Install [vagrant-exec](https://github.com/p0deje/vagrant-exec):
|
||||||
|
|
||||||
```
|
```
|
||||||
bundle install
|
vagrant plugin install vagrant-exec
|
||||||
```
|
vagrant plugin install vagrant-reload
|
||||||
|
```
|
||||||
|
|
||||||
3. Install [ImageMagick](http://imagemagick.org/script/binary-releases.php)
|
3. Clone this code repository:
|
||||||
|
|
||||||
4. Generate secret key for devise and the rails app with
|
```
|
||||||
|
git clone https://github.com/openSUSE/osem.git
|
||||||
|
```
|
||||||
|
|
||||||
```
|
4. Execute Vagrant:
|
||||||
rake secret
|
|
||||||
```
|
|
||||||
|
|
||||||
5. Copy the sample configuration files and adapt them
|
```
|
||||||
|
vagrant up
|
||||||
|
```
|
||||||
|
|
||||||
```
|
7. Start your OSEM rails app:
|
||||||
cp config/config.yml.example config/config.yml
|
|
||||||
cp config/database.yml.example config/database.yml
|
|
||||||
cp config/secrets.yml.example config/secrets.yml
|
|
||||||
```
|
|
||||||
|
|
||||||
6. Setup the database
|
```
|
||||||
|
vagrant exec rails s
|
||||||
|
```
|
||||||
|
|
||||||
```
|
8. Check out your OSEM rails app:
|
||||||
bundle exec rake db:setup
|
You can access the app [localhost:3000](http://localhost:3000). Whatever you change in your cloned repository will have effect in the development environment. Sign up, the first user will be automatically assigned the admin role.
|
||||||
```
|
|
||||||
|
|
||||||
7. Run OSEM
|
9. Changed something? Test your changes!:
|
||||||
|
|
||||||
```
|
```
|
||||||
rails server
|
vagrant exec rake test
|
||||||
```
|
```
|
||||||
|
|
||||||
8. Visit the APP at
|
10. Explore the development environment:
|
||||||
|
|
||||||
```
|
```
|
||||||
http://localhost:3000
|
vagrant ssh
|
||||||
```
|
```
|
||||||
9. Sign up, the first user will be automatically assigned the admin role.
|
|
||||||
|
|
||||||
10. Hack!
|
|
||||||
|
|
||||||
### Run OSEM in production
|
### Run OSEM in production
|
||||||
We recommend to run OSEM in production with [mod_passenger](https://www.phusionpassenger.com/download/#open_source)
|
We recommend to run OSEM in production with [mod_passenger](https://www.phusionpassenger.com/download/#open_source)
|
||||||
|
|
|
||||||
72
Vagrantfile
vendored
Normal file
72
Vagrantfile
vendored
Normal file
|
|
@ -0,0 +1,72 @@
|
||||||
|
# -*- mode: ruby -*-
|
||||||
|
# vi: set ft=ruby :
|
||||||
|
|
||||||
|
# All Vagrant configuration is done below. The "2" in Vagrant.configure
|
||||||
|
# configures the configuration version (we support older styles for
|
||||||
|
# backwards compatibility). Please don't change it unless you know what
|
||||||
|
# you're doing.
|
||||||
|
Vagrant.configure(2) do |config|
|
||||||
|
# The most common configuration options are documented and commented below.
|
||||||
|
# For a complete reference, please see the online documentation at
|
||||||
|
# https://docs.vagrantup.com.
|
||||||
|
|
||||||
|
# Every Vagrant development environment requires a box. You can search for
|
||||||
|
# boxes at https://atlas.hashicorp.com/search.
|
||||||
|
config.vm.box = "webhippie/opensuse-13.2"
|
||||||
|
|
||||||
|
# Disable automatic box update checking. If you disable this, then
|
||||||
|
# boxes will only be checked for updates when the user runs
|
||||||
|
# `vagrant box outdated`. This is not recommended.
|
||||||
|
# config.vm.box_check_update = false
|
||||||
|
|
||||||
|
# Create a forwarded port mapping which allows access to a specific port
|
||||||
|
# within the machine from a port on the host machine. In the example below,
|
||||||
|
# accessing "localhost:8080" will access port 80 on the guest machine.
|
||||||
|
config.vm.network "forwarded_port", guest: 3000, host: 3000
|
||||||
|
|
||||||
|
# Create a private network, which allows host-only access to the machine
|
||||||
|
# using a specific IP.
|
||||||
|
# config.vm.network "private_network", ip: "192.168.33.10"
|
||||||
|
|
||||||
|
# Create a public network, which generally matched to bridged network.
|
||||||
|
# Bridged networks make the machine appear as another physical device on
|
||||||
|
# your network.
|
||||||
|
# config.vm.network "public_network"
|
||||||
|
|
||||||
|
# Share an additional folder to the guest VM. The first argument is
|
||||||
|
# the path on the host to the actual folder. The second argument is
|
||||||
|
# the path on the guest to mount the folder. And the optional third
|
||||||
|
# argument is a set of non-required options.
|
||||||
|
# config.vm.synced_folder "../data", "/vagrant_data"
|
||||||
|
|
||||||
|
# Provider-specific configuration so you can fine-tune various
|
||||||
|
# backing providers for Vagrant. These expose provider-specific options.
|
||||||
|
# Example for VirtualBox:
|
||||||
|
#
|
||||||
|
# config.vm.provider "virtualbox" do |vb|
|
||||||
|
# # Display the VirtualBox GUI when booting the machine
|
||||||
|
# vb.gui = true
|
||||||
|
#
|
||||||
|
# # Customize the amount of memory on the VM:
|
||||||
|
# vb.memory = "1024"
|
||||||
|
# end
|
||||||
|
#
|
||||||
|
# View the documentation for the provider you are using for more
|
||||||
|
# information on available options.
|
||||||
|
|
||||||
|
# Define a Vagrant Push strategy for pushing to Atlas. Other push strategies
|
||||||
|
# such as FTP and Heroku are also available. See the documentation at
|
||||||
|
# https://docs.vagrantup.com/v2/push/atlas.html for more information.
|
||||||
|
# config.push.define "atlas" do |push|
|
||||||
|
# push.app = "YOUR_ATLAS_USERNAME/YOUR_APPLICATION_NAME"
|
||||||
|
# end
|
||||||
|
|
||||||
|
# Enable provisioning with a shell script. Additional provisioners such as
|
||||||
|
# Puppet, Chef, Ansible, Salt, and Docker are also available. Please see the
|
||||||
|
# documentation for more information about their specific syntax and use.
|
||||||
|
config.vm.provision :shell, path: "bootstrap.sh"
|
||||||
|
# config.vm.provision "shell", inline: <<-SHELL
|
||||||
|
# sudo apt-get update
|
||||||
|
# sudo apt-get install -y apache2
|
||||||
|
# SHELL
|
||||||
|
end
|
||||||
45
bootstrap.sh
Normal file
45
bootstrap.sh
Normal file
|
|
@ -0,0 +1,45 @@
|
||||||
|
#!/bin/bash
|
||||||
|
echo -e "\ninstalling required software packages...\n"
|
||||||
|
zypper -q -n install update-alternatives ruby-devel make gcc gcc-c++ libxml2-devel libxslt-devel nodejs screen mariadb libmysqld-devel sqlite3-devel imagemagick
|
||||||
|
|
||||||
|
echo -e "\ndisabling versioned gem binary names...\n"
|
||||||
|
echo 'install: --no-format-executable' >> /etc/gemrc
|
||||||
|
|
||||||
|
echo -e "\ninstalling bundler...\n"
|
||||||
|
gem install bundler
|
||||||
|
|
||||||
|
echo -e "\ninstalling your bundle...\n"
|
||||||
|
su - vagrant -c "cd /vagrant/; bundle install --quiet"
|
||||||
|
|
||||||
|
# Configure the app if it isn't
|
||||||
|
if [ ! -f /vagrant/config/options.yml ] && [ -f /vagrant/config/options.yml.example ]; then
|
||||||
|
echo "Configuring your app in config/options.yml..."
|
||||||
|
cp config/config.yml.example config/config.yml
|
||||||
|
else
|
||||||
|
echo -e "\n\nWARNING: You have already configured your app in config/options.yml."
|
||||||
|
echo -e "WARNING: Please make sure this configuration works in this vagrant box!\n\n"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Configure the app if it isn't
|
||||||
|
if [ ! -f /vagrant/config/secrets.yml ] && [ -f /vagrant/config/secrets.yml.example ]; then
|
||||||
|
echo "Configuring your app in config/secrets.yml..."
|
||||||
|
echo -e "\n\nWARNING: The keys in the generated secrets.yml are NOT secure!"
|
||||||
|
echo -e "\n\nWARNING: Please generate new secret keys with 'rake secret' and copy them to the secrets.yml if you run this app in production."
|
||||||
|
cp config/secrets.yml.example config/secrets.yml
|
||||||
|
else
|
||||||
|
echo -e "\n\nWARNING: You have already configured your app in config/secrets.yml."
|
||||||
|
echo -e "WARNING: Please make sure this configuration works in this vagrant box!\n\n"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Configure the database if it isn't
|
||||||
|
if [ ! -f /vagrant/config/database.yml ] && [ -f /vagrant/config/database.yml.example ]; then
|
||||||
|
echo -e "\nSetting up your database from config/database.yml...\n"
|
||||||
|
cp config/database.yml.example config/database.yml
|
||||||
|
bundle exec rake db:setup
|
||||||
|
else
|
||||||
|
echo -e "\nnWARNING: You have already configured your database in config/database.yml."
|
||||||
|
echo -e "WARNING: Please make sure this configuration works in this vagrant box!\n\n"
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo -e "\nProvisioning of your OSEM rails app done!"
|
||||||
|
echo -e "To start your development OSEM run: vagrant exec rails s\n"
|
||||||
Loading…
Add table
Add a link
Reference in a new issue