Follow these instructions in order to set up a development environment, build and deploy this project on your machine.
This project uses Git submodules, so please ensure you include them by simply adding --recurse-submodules
:
git clone --recurse-submodules https://github.com/3scale/porta.git
We provide a dockerized environment that you can use to run the test suite or to run this project locally on your machine, without needing to install anything on your host OS (e.g. if you are not planning to do long term development work).
The project relies on a Makefile
for its build process. Check a complete list of available tasks by running:
make help
Download and build all the images and run the test suite in the container:
make test
Download and build all the images and start a shell session inside the container:
make bash
All the source and dependencies for this project will be in place, making possible to run porta and the tests from inside the container. See Run Porta
The project supports Ruby 2.3.x.
Verify you have a proper version by running on your terminal:
ruby -v
Mac OS X 10.13 comes with 2.3.7 but you might also use rbenv or rvm to install your own ruby version.
The project supports Version: 8.X.X.
You might want to use nvm to install and work with specific Node versions:
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.11/install.sh | bash
Restart the terminal and install Node:
nvm install 8
nvm use 8
brew install node@8
Install Xcode from the App Store. You can download all Xcode versions from the Apple's developer site.
Make sure you have Homebrew in your machine in order to install the following dependencies:
brew tap homebrew/cask
brew cask install chromedriver
brew install imagemagick@6 [email protected] gs pkg-config openssl geckodriver postgresql memcached
brew link [email protected] --force
brew link imagemagick@6 --force
brew services start [email protected]
Optionally, depending on your needs you can launch memcached and postgresql services
brew services start memcached postgresql
Spring is a Rails application preloader. It speeds up development by keeping your application running in the background so you don't need to boot it every time you run a test, rake task or migration.
This is not required but still recommended. Install it via gem:
gem install spring -v 2.0.0
Sphinx has to be installed with [email protected]:
sed -i '' -e 's|depends_on "mysql"|depends_on "[email protected]"|g' /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core/Formula/sphinx.rb
brew install sphinx
Redis has to be running for the application to work. The easiest way to do it is in a Docker container by simply running:
docker run -d -p 6379:6379 redis
Alternatively you can run Redis directly on your machine by using brew
:
brew install redis
brew services start redis
Eventmachine has to be installed with --with-cppflags=-I/usr/local/opt/openssl/include
. Simply run:
bundle config build.eventmachine --with-cppflags=-I/usr/local/opt/openssl/include
Copy example config files from the examples folder:
cp config/examples/* config/
Run Bundler to install all required Ruby gems:
bundle install
Finally initialize the database with some seed data by running:
bundle exec rake db:setup
You may need to set the database up from scratch again, in that case use db:reset
to drop it first too:
bundle exec rake db:reset # This will drop and setup the database
Start up the rails server by running the following command:
$ UNICORN_WORKERS=2 rails server -b 0.0.0.0 # Runs the server, available at localhost:3000
The number of unicorn workers is variable and sometimes it will need more than 2. In case the server is slow or start suffering from timeouts, try restarting porta with a higher number like 8.