Giter Club home page Giter Club logo

backend's Introduction

CircleCI Ebert Coverage Status codebeat badge

Re WebService

Pre-requisites

  • Elixir
  • PostgreSQL

Install

  • Install dependencies with mix deps.get
  • Create, migrate and seed your database with cd apps/re && mix ecto.setup
  • Rename config/dev.secret-example.exs to config/dev.secret.exs and follow instructions at the top of the file to generate necessary keys.
  • Install git hooks with mix git.hook

Setup elasticsearch (optional)

  • Download and install (comes with kibana): mix elasticsearch.install . --version 6.2.4
  • Run elasticsearch: ./elasticsearch/bin/elasticsearch and check http://localhost:9200
  • Run kibana: ./kibana/bin/kibana and check http://localhost:5601
  • Optionally, uncomment the lines in application.ex to run elasticsearch and kibana together with the application
  • Create listings index: mix elasticsearch.build listings --existing --cluster ReIntegrations.Search.Cluster (see ReIntegrations.Search for more operations)

Test

  • Run mix test

Run

  • 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

Enable https locally

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:

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.

Using docker

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 in backend service
  • mix compose build: build a new backend image.
  • mix compose up: start all services.
  • mix compose down: stop all services.
  • mix compose ps: check status for all services.

Load database backup

To restore a database backup execute the command:

pg_restore -d re_dev --clean --no-owner --no-acl <path-to-backup-file>

Production

To see backend endpoint in production: https://api.emcasa.com/

Possible issues

Use asdf or check the tools versions in .tools-version

backend's People

Contributors

beligante avatar gabriel-laet avatar gusaiani avatar joaodubas avatar nathanqueija avatar pmargreff avatar rhnonose avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.