Step-by-step guide to setup Avia Commerce locally for development and contribution.
Setup using docker
- Docker version 18.06.1 or higher is required.
Setting Up the development environment
- Dockerfile for development environment is
- Add values of all the environment variables in
- Environment variables are those which have
ENVwritten before them. Dummy values are already assigned to them.
Docker Compose File
- The docker compose file is
- Docker Compose file has
dbservice for postgres database container.
hostnameequal to postgres service in
apps/snitch_core/config/dev.exsfile which is
dbin our case.
config :snitch_core, Snitch.Repo, adapter: Ecto.Adapters.Postgres, username: "postgres", password: "postgres", database: "snitch_dev", hostname: "db", pool_size: 10
Docker commands to run the containers
Below command will
- download all the required images
- run containers using them
build aviacommerce webapp image and run it in a container
> docker-compose -f config/docker/dev/docker-compose-dev.yml up --build
After all the containers are up and running and the logs show localhost:4000 as available,
Avia Commerce runs on Elixir 1.7+
Installing Hex Package Manager
- To check the version
At present Avia Commerce has been fully tested and exploited only on Postgres so make sure to have postgres 9.5 or higher.
- To check run
psqland see the version in the prompt.
- Installing NodeJs
- The phoenix application in Avia Commerce uses brunch.io for asset management. Brunch uses npm to install dependencies and npm requires node.js
- Though phoenix suggests version node 5.0.0 or higher but to avoid any unwanted issues we would suggest v 9.11.0 or higher.
- wkhtmltopdf is a command line tool to render HTML into PDF. Used in generating pdf invoices. Download here.
You can find all the repositories related to Avia Commerce here.
We need to clone the
avia repository on our local.
Clone this repo and its submodule at the same, use the —recurse-submodules option:
git clone --recurse-submodules https://github.com/aviacommerce/avia.git
If you’ve already cloned this repo without its submodule, then run this command from the repo root:
git submodule update --init --remote
IMPORTANT: Whenever you update your repo, update the submodule as well: git pull; git submodule update --init --remote
Setting up the Development Environment
Setting up the system environment variables
Create a copy of the
> cp env/example.env env/local.env
The env file has keys, secrets and paths required by application to run. After putting all the details for different keys, source it.
> source env/local.env
Image Upload Setup
The default configuration to store uploaded images on development environment is local storage.
Setting up for image upload on S3 \TODO
To setup the database we have to modify
The default setup for
config :snitch_core, Snitch.Repo, adapter: Ecto.Adapters.Postgres, username: "postgres", password: "postgres", database: "snitch_dev", hostname: "localhost", pool_size: 10
username and the
password field with your local credentials for
postgres. You can also change the
database field to a name of your choice.
From the root of the project run
> mix deps.get
This will install all the dependencies for the project.
Setting Application Database
If you have already configured the database you can go ahead with steps mentioned below, otherwise follow Configuring Postgres.
Move in to the snitch core directory
> cd apps/snitch_core
From the root of
> mix ecto.create
Migrate the Database
> mix ecto.migrate
> mix run priv/repo/seed/seeds.exs
Create sample data
> mix ecto.load.demo
Setting Elasticsearch Indexing
- keep elasticsearch running on port 9200 (if another port, then config that in local.env)
- Activate atleast one product in the admin panel, so that it is ready to be indexed. Variants need to be activated from options tab.
> mix cmd --app snitch_core mix elasticsearch.build products --cluster Snitch.Tools.ElasticsearchCluster
Setting up Assets
The admin application in Avia Commerce is phoenix application with html.
To setup the assets:
> cd apps/admin_app/assets > npm install
Running the server
From the project root
> iex -S mix phx.server
This will run two servers one for the
admin application and the
Browser Admin Interface
To run the
user interface you will have to go through the frontend installation.
in case you get
elm-make command not found error on OS X from the project root:
yarn global add email@example.com && elm-package install -y
and then type this:
cd apps/admin_app/assets && yarn install && cd elm && elm-package install --yes
this will install old version of elm compatibile with the project
To run all the tests from your project root run the command
> mix test
You can also run the tests of individual applications from the root of those applications. e.g. to run tests of core
> cd apps/snitch_core > mix test