- Elixir
- PostgreSQL
- Postgis
- G++
- Install dependencies with
mix deps.get - Create, migrate and seed your core database with
cd apps/re && mix ecto.setup - Create, migrate and seed your integrations database with
cd apps/re_integration && mix ecto.setup - Rename
config/dev.secret-example.exstoconfig/dev.secret.exsand follow instructions at the top of the file to generate necessary keys. - Install git hooks with
mix git.hook
- Download and install (comes with kibana):
mix elasticsearch.install . --version 6.2.4 - Run elasticsearch:
./elasticsearch/bin/elasticsearchand checkhttp://localhost:9200 - Run kibana:
./kibana/bin/kibanaand checkhttp://localhost:5601 - Optionally, uncomment the lines in
application.exto runelasticsearchandkibanatogether with the application - Create listings index:
mix elasticsearch.build listings --existing --cluster ReIntegrations.Search.Cluster(seeReIntegrations.Searchfor more operations)
- Run
mix test
- Prepare database with
mix ecto.setup - Start Phoenix endpoint with
mix phx.server - Check
http://localhost:4000/graphql_api - WebSocket subscriptions at
ws://localhost:4000/socket
To enable https locally, it's necessary to add priv/cert/dev/dev_cert_ca.cert.pem to your trusted root certificates, this varies accordingly your OS, or browser of choice, below are links, showing how to procede:
- OSX: adding the root certificate to macOS keychain
- Windows: manage trusted root certificates in windows
- Linux (debian/ubuntu): how to import ca root certificate
- Firefox: add root to firefox
Now it's time to update our /etc/hosts (or C:\Windows\System32\drivers\etc\hosts), and add an entry mapping dev.emcasa.com, api.dev.emcasa.com, and kibana.dev.emcasa.com to 127.0.0.1.
After enabling https, the backend will be available in https://api.dev.emcasa.com.
If you prefer working with docker it's possible to use docker-compose to start all services needed with: docker-compose up -d
The first time this command is executed, it will build the emcasa/backend:dev image and install all dependecies.
To check the status of all services use the command: docker-compose ps.
If you need to rebuild the backend image (maybe because we added a new dependency), just type: docker-compose build.
At last, to start the backend use: docker-compose exec backend mix phx.server.
If you prefer, mix has some aliases for the common commands:
mix compose server: start the phoenix server inbackendservicemix compose build: build a newbackendimage.mix compose up: start all services.mix compose down: stop all services.mix compose ps: checkstatusfor all services.
To start the restoring process, first you need to copy the backup file to the db image, to do so, you have to:
docker cp <path-to-backup-file-on-your-machine> <docker-db-image-name>:<path-inside-docker-image>
After that you connect to your db-image bash console, with this command:
docker exec -it <docker-db-image-name> bashAnd then you run the restore command as defined in Load database backup section
To restore a database backup execute the command:
pg_restore -U postgres -d re_dev --clean --no-owner --no-acl <path-to-backup-file>To see backend endpoint in production: https://api.emcasa.com/
Use asdf or check the tools versions in .tools-version