vas3k.club/docs/setup.md

2.9 KiB

Advanced Setup

Local development

Once you decided to code something in the project you'll need to setup your environment. Here's how you can make it.

Setup pipenv

  1. Get pipenv: pip3 install --user pipenv
  2. Install packages and activate virtual environment: pipenv install --dev
  3. Check that it was installed correctly: pipenv shell

Setup postgres

locally

Easies way is to run postgres is to run in docker, just run it with follow command:

$ docker-compose -f docker-compose.yml up -d postgres

When you need to connect to postgres use next params:

POSTGRES_DB=vas3k_club
POSTGRES_USER=postgres
POSTGRES_PASSWORD=postgres
POSTGRES_HOST=localhost
In case you really want setup local postgres then go under cut...
Brief instruction:

1. Install postgresql (for macos https://postgresapp.com/ is easies start)
2. After you install and run postgress create a project database:
      ```sh
      # create db
      $ psql postgres
      postgres=# createdb vas3k_club

      # create user (user: vas3k, password: vas3k)
      postgres=# createuser --interactive --pwpromp

      # grant priviliges
      postgres=# GRANT ALL PRIVILEGES ON DATABASE vas3k_club TO vas3k;
      postgres=# \connect vas3k_club
      postgres=# GRANT ALL PRIVILEGES ON ALL TABLES IN SCHEMA public TO vas3k;
      postgres=# GRANT ALL PRIVILEGES ON ALL SEQUENCES IN SCHEMA public to vas3k;
      postgres=# GRANT ALL PRIVILEGES ON ALL FUNCTIONS IN SCHEMA public to vas3k;
      postgres=# \q

      # check connection
      $ psql -d vas3k_club -U vas3k
      ```

Setup frontend

$ cd frontend
$ npm run watch # will implicitly run `npm ci`

Run dev server

After you have setup postgres, venv and build frontend (look this steps above) complete preparations with follow commands:

# run redis
$ docker-compose -f docker-compose.yml up redis

# run queue
$ pipenv run python manage.py qcluster

# run db migration
$ pipenv run python manage.py migrate

# run dev server
$ pipenv run python manage.py runserver 0.0.0.0:8000

Telegram bot

To run telegram bot you have to:

  1. Copy env.exmaple file: cp ./club/.env.example ./club/.env
  2. Fill all the requirement fields in ./club/env, such as TELEGRAM_TOKEN etc.
    • TELEGRAM_TOKEN you can get from @BotFather
    • To get TELEGRAM_CLUB_CHANNEL_URL, TELEGRAM_ADMIN_CHAT_ID etc Just Simply Forward a message from your group/channel to @JsonDumpBot or @getidsbot
  3. Rebuild application: docker-compose up --build

Docker-compose

Check out our docker-compose.yml to understand the infrastructure.