This repository is deployed at orfeus-eu.org/stationbook.
-
Create env file with config using
cp src/stationbook/.env.sample src/stationbook/.env
and adjust as needed:SECRET_KEY='abcdefghijklmnopqrstuvwxyz0123456789!@#$%^&*(-_=+)' DEBUG=False ALLOWED_HOSTS=.localhost,127.0.0.1,0.0.0.0 DATABASE_URL=sqlite:////data/stationbook/db/db.sqlite3 EMAIL_BACKEND=django.core.mail.backends.console.EmailBackend CACHE_BACKEND=django.core.cache.backends.locmem.LocMemCache CACHE_LOCATION='sb_cache' CACHE_TIME_SHORT=1800 CACHE_TIME_MEDIUM=3600 CACHE_TIME_LONG=43200 SB_URL_BASE='stationbook/' CSRF_COOKIE_HTTPONLY = True CSRF_COOKIE_SECURE = True SESSION_COOKIE_HTTPONLY = True SESSION_COOKIE_SECURE = True HCAPTCHA_SITEKEY='' HCAPTCHA_SECRET=''
-
Create the virtual environment and install dependencies:
cd src/stationbook python3.11 -m venv env && source env/bin/activate && pip install --upgrade pip && pip install -r requirements.txt
-
Prepare the database migration and apply it (check
DATABASE_URL
insrc/stationbook/.env
):python manage.py makemigrations python manage.py migrate
-
Create the super user:
python manage.py createsuperuser
-
Load the fixtures into the database:
python manage.py loaddata book.json
-
Run the test server:
python manage.py runserver 0.0.0.0:8080
# Build the image
docker build . -t stationbook:latest
# Run the container (replace PATH_TO_MEDIA and PATH_TO_DB accordingly)
docker run -d --restart always \
--user $(id -u):$(id -g) \
-p 8010:80 \
-v PATH_TO_MEDIA:/data/stationbook/media \
-v PATH_TO_DB:/data/stationbook/db \
--name stationbook \
stationbook:latest
Below code can be used to synchronize with the EIDA nodes. EIDA nodes can be configured manually using admin panel or loaded from the fixtures.
python3 fdsn_sync.py
To automate the synchronization process, /stationbook/src/stationbook/fdsn_sync.py
can be executed via crontab:
# min hour day month weekday command
0 * * * * cd /data/stationbook && python fdsn_sync.py