Edgehog backend is the server with whom Edgehog frontend interacts. It's a Phoenixโ server that uses Ashโ application framework.
For building and running Edgehog backend locally, you'll need Elixir, Erlang and Postgres installed. To manage installed versions we recommend using a version manager such as asdfโ . The versions we're using are specified in the .tool-versions file.
To install them, navigate to the root of the project and run:
asdf install
It may take some time until everything is finished.
To build the Edgehog backend you first need to install dependencies by running:
mix deps.get
Then compile the source files with:
mix compile
Ideally the backend needs astarte to work. Check out Astarte repositoryโ to learn how to run it on your environment, or follow the Astarte in 5 minutes tutorialโ if you need all the functionality to be fully working. For most changes, it is usually sufficient to run the backend locally as described below.
First run a Postgres instance:
docker run --name edgehog-db -d -e "POSTGRES_HOST_AUTH_METHOD=trust" -p 5432:5432 --rm postgres
Then, the database must be created and setup. This is done by running migrations. Navigate to the backend folder (./backend) and run:
mix ecto.setup
The previous command creates the database with tables and populates it with seeds data. If you just want an empty database with no data, run mix ecto.create, then mix ecto.migrate.
Finally, run the Phoenix server:
mix phx.server
This starts a local backend instance on localhost:4000โ . Now you have Edgehog backend server up and running. Nice!
You can also start the server inside an interactive shell with
iex -S mix phx.server
Note: To create, migrate and seed the database, and install dependencies, there's a convenient mix task:
mix setup.
Format code:
mix format
Check code formatting:
mix format --check-formatted
Run static code analysis with Credo to identify issues related to code consistency, readability, and potential refactoring opportunities:
mix credo
Run Dialyzer to analyze the code for potential issues such as type mismatches:
MIX_ENV=test mix dialyzer
Before running tests, you first need to start a Postgres instance. You can read how to run it in Run the backendโ step.
Launch project tests:
mix test
This task starts the current application, loads up test/test_helper.exs and then, requires all files matching the test/**/*_test.exs pattern in parallel.
You can also use the justโ tasks defined in the top level of the repo if you need an astarte instance and a working device, but don't want to go through the setup described in the guide. See Edgehog Just in Timeโ for more information.
Content type
Image
Digest
sha256:3e1712ad1โฆ
Size
60.7 MB
Last updated
3 days ago
docker pull edgehogdevicemanager/edgehog-backend:0.14-snapshot