Setup project on your machine

With Docker

  1. Make sure Docker is installed on your machine. If not please visit this siteopen in new window and download it.
  2. Run
docker compose up --build rails 
1

or docker-compose for older Docker versions, to build application and its dependencies.

  1. If you've started rails service in background, using -d flag, you can check logs with this command.
docker compose logs -f rails
1
  1. If you are using RubyMine, you can refer to this guideopen in new window, for VSCode - please check this oneopen in new window.
  2. To prepare database run
docker-compose exec rails bundle exec rails db:create db:migrate
1
  1. If you want to restore database from backup, run
cat your_dump.sql | docker exec -i {docker-postgres-container} psql -U {user} -d {database_name}
1

Your project may use dipopen in new window to simplify Docker commands. For example instead of docker compose up rails you will use dip rails s and result will be the same.

You can check all dip commands in dip.yml file in project root or using dip ls command.

With RVM

  1. Make sure you have rvmopen in new window installed. We use it for keeping different ruby versions for each project. You can find ruby version for your project in .ruby-version and gemset to save gems from bundle in .ruby-gemset.

  2. Make sure you have PostgreSQLopen in new window and Redisopen in new window on your system.

  3. Make sure you have Node.js installed. If you see .nvmrc file in your project directory, install nvmopen in new window and corresponding node version.

  4. Install lefthookopen in new window. We use it for pre-commit hooks and commit message validation. Don't forget to copy lefthook.yml configuration to your project directory if it is missing (Will be attached below).

  5. Clone your project from Gitlab (even if it is empty directory).

  6. Run

rvm install
1

from your console inside project directory.

  1. Pick your ruby version and gemset in Languages & Frameworks → Ruby SDK (Only if you are using RubyMine)

  2. Run

bundle check || bundle install
1
  1. Look at database.example.yml and secrets.example.yml and create new ones according to examples (without .example extension).

  2. Run

bundle exec rails db:create db:migrate
1

to setup database.

  1. Launch server with
bundle exec rails s
1

or if you have Procfile inside your project, you should run

foreman start
1

It will launch not only rails server, but other processes needed for development. For example: webpacker to build Vue.js front-end.