progiv / song2voice

Song To Voice. Backend. Splits song to voice and vocal parts using deezer/spleeter

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Clone the repo first:

git@gitlab.com:hse-how-to-make-a-startup/projects/vocal-extractor-song-2-voice/song-to-voice-backend.git`
cd song-to-voice-backend

Setup the environment(Do it once)

virtualenv -p python3 env && source env/bin/activate

Ensure that it is running correct python from virtual environment env:

which python && python --version

The output should look similar to this:

/home/auc/shad/mvp/song-to-voice-backend/env/bin/python
Python 3.7.4

Install requirements (like Django):

pip install -r requirements.txt

Run the server

Now we are ready to run the server:

DJANGO_DATABASE=test python manage.py runserver

Running locally in docker container for debug

Note: it is an alternative way of doing steps from above.

  1. (Once) Install docker using official guide
  2. Build the image with name song2voice: docker image build -t song2voice .
  3. Run the container interactively: docker run -e DEBUG=True --rm -it -p 80:80 song2voice
  4. The server is now accessible at localhost:80

Deploy to Remote server

Prerequisites: it is expected that you already have setup keypair connection to your remote server on <ROMITE IP> with private key stored at <PATH TO PRIVATRE SSH KEY>. <PATH TO ENV FILE> should contain secrets like SECRET_KEY, DJANGO_DATABASE=main DB_PASWORD and DB_HOST

  1. (Once)Setup docker environment on the remote machine. docker-machine create --driver generic --generic-ip-address=<REMOTE IP> --generic-ssh-user=<REMOTE USERNAME> --generic-ssh-key <PATH TO PRIVATRE SSH KEY> s2v-ya
  2. Configure docker to run commands on remote host eval $(docker-machine env s2v-ya)
  3. Build container as before. Notice: that it will be built on remote host using local source code.
  4. Kill running instance and delete its data docker kill back && docker container rm back
  5. Run new container in detached mode docker run --env-file <PATH TO ENV FILE> -dp 80:80 --name back song2voice
  6. Unset environment variables that were set up in step 2 eval $(docker-machine env -u)

List of environment variables in use settings.py

The values for secrets ones are stored in CI/CD settings -> Variables.

  • SECRET_KEY - django secret key

  • DEBUG use True to see descriptive error messages

  • DJANGO_DATABASE one of main(postgres), test(sqlite)

  • DB_HOST database host

  • DB_PORT by default is 5432 (postgres default port)

  • DB_NAME

  • DB_USER database username

  • DB_PASSWORD database password

  • AWS_S3_ENDPOINT storage.yandexcloud.net

  • AWS_ACCESS_KEY_ID

  • AWS_SECRET_ACCESS_KEY

  • AWS_STORAGE_BUCKET_NAME=musicbreaker

About

Song To Voice. Backend. Splits song to voice and vocal parts using deezer/spleeter


Languages

Language:Python 98.6%Language:Dockerfile 1.4%