This is a work in progress
- Docker and Docker-compose (
sudo apt install docker docker-compose
)
- Python 3.6 (
sudo apt install python3.6
) - Celery (
sudo apt install python-celery-common
) - Requirements (inside socialNetwork directory with the virtual environment activated,
pip install -r requirements.txt
)
- Node (>= v8.17.0)
- npm (>= v6.13.4)
- Truffle (
npm install -g truffle
) - Install requirements (inside blockchain directory
npm install
)
First, we need a postgres database. We can easy create one with this docker command.
# This creates the container, not the database
docker run --name socialNetwork_db -d -p 5432:5432 -e POSTGRES_PASSWORD="socialNetwork" postgres:9.6.17-alpine
Then we need to create the database inside the container.
docker exec -it socialNetwork_db createdb socialNetwork -U postgres
In addition, if we want to enter the terminal inside our postgres, we can do it with this command:
docker exec -it socialNetwork_db psql -U postgres
You need to create a python virtual environment. If you don't know how, follow this steps.
- Install virtualenv and virtualenvwrapper following this gist.
- Create the environment with this command.
# This will create a virtual environment called "socialNetwork"
mkvirtualenv --python=/usr/bin/python3.6 socialNetwork
In order to activate the environment you just need to execute workon socialNetwork
, and to deactivate it, just type
deactivate
.
In order to set up our redis, we just need to run this docker command:
docker run --name socialNetwork_redis -p 6379:6379 redis:6.0-alpine
At the moment, we have not dockerized celery, so we can start our celery running this command in a terminal (don't kill this terminal).
cd socialNetwork
celery worker -A socialNetwork --loglevel=info
We can easily set up our local blockchain with this docker command:
docker run --name ganache-cli -d -p 8545:8545 trufflesuite/ganache-cli:latest
Before running this app, you need to install all requirements and do the set up.
If so, just follow this steps:
- Be sure ganache-cli docker is running.
- Go into the blockchain directory and deploy the contracts with
truffle deploy
. - Be sure the database is up.
- Go to the socialNetwork directory and stay there.
- Activate your virtual environment.
- Be sure redis and celery are running.
- Do the migrations if needed (
python manage.py makemigrations
andpython manage.py migrate
) - Flush the database
python manage.py flush
(this cleans the database, so there will be no conflicts with the Smart Contracts) - Finally, run the server with
python manage.py runserver
and go to http://127.0.0.1:8000.
MIT License. See more here.