Skip to content

scieloorg/spf

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SciELO Publishing Framework

Development

Installation under a Python virtual environment

System dependencies

# Be sure that you have the necessary operational system dependencies
gettext
python3

Create a virtual environment and install the application dependencies

# Create a virtual environment
virtualenv -p python3 .venv

# Access the virtual environment
source .venv/bin/activate

# Access the folder app
cd app

# Install dependencies
pip install -r requirements.txt

# Install packages
pip install .

Set the environment variables

# Create a dotenv file (and add to it the necessary environment variables - see List of environment variables)
touch .env.dev

# Export its contents to the system enviroment
export $(cat .env.dev | xargs)

Create a PostgreSQL database named "spf"

# Through a Docker container with a PostgreSQL database
docker exec --user postgres -it scl_postgres_1 psql -c 'create database spf;'

# Or through psql
psql --user postgres;
create database spf;

Run the Message Broker RabbitMQ

# See https://www.rabbitmq.com/download.html to obtain more information
docker run -d -p 5672:5672 rabbitmq

Prepare and run the application

# Make migrations related to the database
python manage.py makemigrations

# Migrate database (this operation will create all the necessary tables)
python manage.py migrate

Add default groups to the application database

# Add default groups to the application database
python manage.py loaddata group

Add example users to the application database (only in development environments)

# Add example users to the application database
python manage.py loaddata user

Override superuser credentials python manage.py createsuperuser

Run the application

# Start Celery
celery -A spf worker -l INFO

# Start the application
python manage.py runserver

How to translate the interface content to other languages

# Access the core project directory
cd core

# Create the strings to be translated to Portuguese
python ../manage.py make_messages_no_fuzzy -l pt

# Create the strings to be translated to Spanish
python ../manage.py make_messages_no_fuzzy -l es

# Translate the strings

# Compile the translated strings
python ../manage.py compilemessages

Production

Installation under Docker

# Be sure you are in the project root directory. Executing `ls .` will list the following files/directories
app
docker-compose.yml
LICENSE
nginx
README.md

Start a nginx container and copy nginx.conf to /etc/nginx/conf.d

Start a postgres container and keep note of user credentials

Create a dotenv file (and add to it the necessary environment variables - see List of environment variables)

touch .env.prod

Build image and start the services

docker-compose -f docker-compose.yml up -d --build

Migrate data

# Under host shell, run
docker-compose -f docker-compose.yml exec web python manage.py migrate --noinput

# Under docker shell, run
python manage.py migrate

Collect staticfiles

# Under host shell, run
docker-compose -f docker-compose.yml exec web python manage.py collectstatic --no-input --clear

# Under docker shell, run
python manage.py collectstatic

Generate translations

# Under host shell, run
python ../manage.py compilemessages

# Under docker shell, run
docker-compose -f docker-compose.yml exec web python manage.py compilemessages

Load default groups

# Under host shell, run
docker-compose -f docker-compose.yml exec web python manage.py loaddata group

# Under docker shell, run
python manage.py loaddata group

Load example users (recommended only for development environment)

# Under host shell, run
docker-compose -f docker-compose.yml exec web python manage.py loaddata user

# Under docker shell, run
python manage.py loaddata user

Make sure PostgreSQL and MongoDB databases are in the same network as the spf application


List of environment variables

  • BASES_PATH: Isis Bases root directory
  • BASES_PDF_PATH: Isis Base "PDF"
  • BASES_TRANSLATION_PATH: Isis Base "Translation"
  • BASES_WORK_PATH: Isis Base "Work"
  • BASES_XML_PATH: Isis Base "XML"
  • CISIS_PATH: CISIS root directory
  • HTDOCS_IMG_REVISTAS_PATH: HTDOCS Image directory
  • CELERY_BROKER_URL: RabbitMQ address (pyamqp://user:pass@host:port)
  • DATABASE_CONNECT_URL: OPAC/Kernel database (MongoDB) string connection (mongodb://user:pass@host:port/opac)
  • DJANGO_ALLOWED_HOSTS: localhost;127.0.0.1;[::1]
  • DJANGO_DEBUG: Django flag to see DEBUG messages (1)
  • DJANGO_SECRET_KEY: Django secret key
  • MINIO_ACCESS_KEY: MinIO username
  • MINIO_HOST: MinIO host address (host:port)
  • MINIO_SCIELO_COLLECTION: MinIO collection name
  • MINIO_SECRET_KEY: MinIO password
  • MINIO_SECURE: MinIO SSL flag (true or false)
  • MINIO_SPF_DIR: MinIO storage main directory
  • MINIO_TIMEOUT: MinIO connection timeout
  • PID_DATABASE_DSN: PID manager (PostgreSQL) string connection (postgresql+psycopg2://postgres:password@host:port/database)
  • POSTGRES_DB: SciELO Publishing Framework database name
  • POSTGRES_HOST: SciELO Publishing Framework database hostname
  • POSTGRES_PASSWORD: SciELO Publishing Framework database user password
  • POSTGRES_PORT: SciELO Publishing Framework database host port
  • POSTGRES_USER: SciELO Publishing Framework database user