Setup project on your machine
With Docker
- Make sure Docker is installed on your machine. If not please visit this siteopen in new window and download it.
- Run
docker compose up --build rails
or docker-compose
for older Docker versions, to build application and its dependencies.
- If you've started rails service in background, using
-d
flag, you can check logs with this command.
docker compose logs -f rails
- If you are using RubyMine, you can refer to this guideopen in new window, for VSCode - please check this oneopen in new window.
- To prepare database run
docker-compose exec rails bundle exec rails db:create db:migrate
- 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}
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
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.
Make sure you have PostgreSQLopen in new window and Redisopen in new window on your system.
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.
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).
Clone your project from Gitlab (even if it is empty directory).
Run
rvm install
from your console inside project directory.
Pick your ruby version and gemset in
Languages & Frameworks → Ruby SDK
(Only if you are using RubyMine)Run
bundle check || bundle install
Look at database.example.yml and secrets.example.yml and create new ones according to examples (without .example extension).
Run
bundle exec rails db:create db:migrate
to setup database.
- Launch server with
bundle exec rails s
or if you have Procfile inside your project, you should run
foreman start
It will launch not only rails server, but other processes needed for development. For example: webpacker to build Vue.js front-end.