Steps to run django server in a virtualenv, without needing a k8s cluster. For now only isolated mode is supported: without assert registration or task computation.
Start postgres instance
make db
Activate a virtualenv, then run the commands:
make install # install python dependencies
make quickstart # wait for db, run migrations, create a user, start the server
make fixtures # generate assets fixtures
Alternatively, you can run it inside a container by using dev target (adapt to mount volumes you need).
docker build -f docker/substra-backend/Dockerfile --target dev -t substra-backend .
docker run -it --name substra-backend --rm -p 8000:8000 \
-v ${PWD}/backend/substrapp:/usr/src/app/substrapp \
-e DJANGO_SETTINGS_MODULE=backend.settings.localdev \
-e ISOLATED=1 \
-e BACKEND_DB_HOST=$(docker inspect -f '{{range.NetworkSettings.Networks}}{{.IPAddress}}{{end}}' postgres) \
substra-backend sh dev-startup.sh
docker exec substra-backend python manage.py generate_fixtures
Warning: it will erase the database content (user, fixtures, etc).
cat dump-file.sql | docker exec -it postgres psql postgresql://backend:backend@localhost:5432/backend_default
You can use edb bundle (version >= 11). This comes with pgAdmin 4.
brew install postgres # install the psql client
Create a backend_default
database. To use another name, set the BACKEND_DB_NAME
env var accordingly.
psql postgresql://backend:backend@localhost:5432/backend_default -c "CREATE DATABASE backend_default;"