Skip to content

Freehub Developer Guide

Alon Salant edited this page Dec 5, 2019 · 10 revisions

This developer guide is a work in progress with information added as we need to capture it.

Contributors

To contribute to Freehub, feel free to send a pull request or join the freehub-users google group. We'll take it from there.

You can check Freehub out from GitHub.

See Where To Find Things to start getting familiar with Freehub.

Development

Freehub was originally created in 2008 and is worked on part time or not at all for long stretches of time (like years!). For this reason, it has a number of dependencies that are out of date. For example, it uses Ruby 1.9.3 and Rails 2.3. If anyone wants to help update to more modern versions of Ruby and Rails, let us know ;-)

Freehub is set up for development using Docker in order to make it easy to get set up with the correct versions of Ruby, Rails, and MySQL.

To get set up developing Freehub with Docker, first install Docker and Docker Compose (Compose is included with Docker Desktop for Mac and Windows).

Then checkout Freehub:

git clone http://github.com/asalant/freehub.git freehub
cd freehub

Bootstrap the Docker images, create the development databases, and load test data:

docker-compose up -d mysql
docker-compose run app rake db:create db:migrate db:fixtures:load
docker-compose run app rake db:create RAILS_ENV=test

Once you have done this you can start the app, log in, and play around. You can log in as the sfbk test user with password test:

docker-compose up
open http://localhost:3000

To run the test suite:

docker-compose run app rake test

To get a console into the docker MySQL instance (the development root password is password):

docker-compose run app mysql freehub_for_all_development -h mysql -u root -p

To shut down the containers (but not lose database data):

docker-compose stop

To stop and remove the containers (losing database data):

docker-compose down

What's going on here is that we are using docker-compose to manage two docker containers, one that runs the Rails app and one that runs MySQL. The container running the app is started with your local freehub working directory mapped to /app in the container where Rails is run from. You can make changes locally and they will be picked up immediately.

To run any rake tasks or scripts in the Rails container, just prefix with docker-compose run app. If you make changes to gem dependencies, you'll need to rebuild the app container with docker-compose build.

For background and more info on this Docker setup, see "this post":https://blog.codeship.com/running-rails-development-environment-docker/.

Deployment

For "http://freehub.bikekitchen.org":http://freehub.bikekitchen.org Freehub is deployed on Engine Yard AppCloud from the 'release' branch of this GitHub project. Use the "AppCloud dashboard":https://cloud.engineyard.com/dashboard to trigger new stage and production deploys.

Command Line

You may also trigger deploys with "GitHub post-commit hooks":http://docs.engineyard.com/howtos/howto-deploy-your-app-from-github-with-a-post-commit-hook.

To merge master to the stable release branch and deploy to staging:

git checkout release
git merge -m"[deploy Freehub_Staging migrate] Deploy release branch to staging" master 
git push origin release

To release the stable release branch to production:

git checkout release
git commit --allow-empty -m"[deploy Freehub_Production migrate] Deploy release branch to production" 
git push origin release

Related Projects/Tools

Freehub uses:

References and Tutorials

License

Freehub is licensed for use under the "Apache 2.0 License":http://www.apache.org/licenses/LICENSE-2.0.

Clone this wiki locally