Ruby 2.7.1 Rails 5.2.6
rbenv or rvm recommanded
Some environment variables are needed to run this application.
DATABASE_URL=postgres://<user>:<pass>@localhost:5432 # The database URL
HOST=entourage.localhost # The Host that is used in Nginx routing if multiple app exists behind the same port
You can source these environment variables from a .env
file.
To get started : cp .env.dist .env
and fill in the missing informations!
Note that the .env
file is used for all Rails environments. If you want to target only one (e.g. the development
environment but not the test
environment), use a file named .env.{environment_name}
(e.g .env.development
).
You will find more informations about this in the dotenv
gem's README.
You can run this application using Docker.
There is a wrapper, bin/d
, that allows you to run command in the correct
container.
Example :
bin/d # Shows help
bin/d up # Setup needed containers
# bin/d gem install bundler -v '2.2.16'
# bin/d bundle install
bin/d bundle exec rake db:migrate
bin/d foreman start web
You can run below commands prepending bin/d
to them and it will run in the
container !
Note: after modifying the Dockerfile
, you might need to run
docker-compose -f docker-compose.yml -f docker-compose.dev.yml build spring
This commands mirrors what happens in bin/docker/up
to build the dev
variant of the Docker image.
TODO: there has to be a simple way to do this. We should update the bin/docker/*
script as needed or at least create one for this.
RAILS_ENV=test bin/d bundle exec rake db:drop db:create db:migrate
RAILS_ENV=test bin/d bundle exec rspec
If you want to connect directly to docker psql, use:
docker-compose exec --env RAILS_ENV=development postgresql psql postgres://guest:guest@postgresql:5432/entourage-dev
See docker-compose.yml
for more details.
gem install 'bundler:~>1'
bundle install
bundle exec rake db:create
bundle exec rake db:migrate # if any trouble with postgis, please see Postgis section below
bundle exec rails server
Or, with foreman
:
# gem install foreman
foreman start web
Scheduled jobs documentation is accessible here
bundle exec sidekiq -c 5 -q mailers -q default -q broadcast -q denorm
To access the admin panel, you need to set an entry in your /etc/hosts
:
127.0.0.1 admin.entourage.localhost
You also need to create an admin user :
echo "UserServices::PublicUserBuilder.new(params: {phone: '+33606060606', admin: true}, community: Community.new(:entourage)).create(sms_code: '123456')" | rails c
Then, browse admin.entourage.localhost:<port>
.
Setup database :
rake db:drop db:create db:migrate RAILS_ENV=test
Run tests with
$ rspec
bin/d db-restore path/to/snapshot.dump
You need to have access to the entourage-back
Heroku application.
bin/d db-pull entourage-back
bin/d rake db:strip
bin/d db-dump path/to/snapshot.dump
If you have any trouble with postgis
during db:migrate
, please install postgis
:
Using PSQL 12
sudo apt install postgis postgresql-12-postgis-3
sudo apt-get install postgresql-12-postgis-3-scripts
Using PSQL 11
sudo apt install postgis postgresql-11-postgis-3
sudo apt-get install postgresql-11-postgis-3-scripts
Then, activate postgis
in your database (DO NOT INSTALL it in the database called postgres
):
psql
\c entourage-dev
entourage-dev=# CREATE EXTENSION postgis;
entourage-dev=# SELECT PostGIS_version();
- open in a browser:
public/doc/api/index.html
- or open directly URL : https://admin.entourage.social/doc/api/index.html
To profile a request (in a puma worker):
bin/d -u root -- rbspy record --pid $(cat tmp/puma.pid) --subprocesses --file flamegraph
Test the API documentation compliance with Dredd
$ npm install -g dredd
- Reset DB to reset id sequence
- Populate database with Dredd specific seeds (cf file ./db/seeds/dredd.rb)
$ rake db:reset dredd:seeds
- Removes all newsletter subscriptions
- Removes all users
- Generates the dredd user
$ rake dredd
Dredd options are listed in dredd.yml file
Launch automatically tests with:
$ bundle exec guard
Launch automatically dredd and aglio (static documentation generation) with:
$ bundle exec guard -g apib
In order to redirect a mobile to the application from a SMS, we redirect toward a page on the website :
http://api.entourage.social/store_redirection
- If you visit this page from an iOS device you will be redirected to the Appstore
- If you visit this page from an Android device you will be redirected to the PlayStore
The logic and URL for the store can be found here : https://s3-eu-west-1.amazonaws.com/entourage-ressources/store_redirection.html