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
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
Now we are ready to run the server:
DJANGO_DATABASE=test python manage.py runserver
Note: it is an alternative way of doing steps from above.
- (Once) Install docker using official guide
- Build the image with name song2voice:
docker image build -t song2voice .
- Run the container interactively:
docker run -e DEBUG=True --rm -it -p 80:80 song2voice
- The server is now accessible at localhost:80
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
- (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
- Configure docker to run commands on remote host
eval $(docker-machine env s2v-ya)
- Build container as before. Notice: that it will be built on remote host using local source code.
- Kill running instance and delete its data
docker kill back && docker container rm back
- Run new container in detached mode
docker run --env-file <PATH TO ENV FILE> -dp 80:80 --name back song2voice
- 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
useTrue
to see descriptive error messages -
DJANGO_DATABASE
one ofmain
(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