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-alpineThen we need to create the database inside the container.
docker exec -it socialNetwork_db createdb socialNetwork -U postgresIn 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 postgresYou 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 socialNetworkIn 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-alpineAt 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=infoWe can easily set up our local blockchain with this docker command:
docker run --name ganache-cli -d -p 8545:8545 trufflesuite/ganache-cli:latestBefore 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 makemigrationsandpython 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 runserverand go to http://127.0.0.1:8000.
MIT License. See more here.