Skip to content

longnd/elixir-gscraper

Repository files navigation

Introduction

This is a web application built on Elixir, using Phoenix Framework that provide the ability to scrap the Google search result and generating the report.

It is used to practice and demonstrate my learning of these two great technologies.

Project Setup

Erlang & Elixir

  • Erlang 24.0.5 and Elixir 1.12.2

  • Recommended version manager.

    • asdf Erlang & Elixir

Development

  • Install Docker for Mac

  • Setup and boot the Docker containers:

    make docker_setup
  • Install Elixir dependencies:

    mix deps.get
  • Install Node dependencies:

    npm install --prefix assets
  • Setup the databases:

    mix ecto.setup
  • Start the Phoenix app

    iex -S mix phx.server
  • Run all tests:

    mix test 
  • Run all lint:

    mix codebase 

Production

  • Build Docker image

    docker-compose build

CI/CD

This project uses Github action for CI/CD and will automatically deploy to Heroku when the code is merged to the develop & main branches.

  • Create two new Heroku apps, one for staging and the other for production environments:

    • Add a Database add-on, PostgreSQL is recommended.
    • Set the following environment variables:
      Environment Variable Description
      DATABASE_URL Will be added automatically after adding the database add-on to the Heroku app
      HOST_URL The URL host, e.g. acme.herokuapp.com
      SECRET_KEY_BASE The value generated by running the command mix phx.gen.secret
  • Define the secrets in the repository:

    Environment Variable Description
    HEROKU_API_KEY Can be found under Account settings
    HEROKU_APP_NAME_STAGING The Heroku app name created for staging environment
    HEROKU_APP_NAME_PRODUCTION The Heroku app name created for production environment