Skip to content

Commit

Permalink
docs: new install guide
Browse files Browse the repository at this point in the history
 * Fixes ui packages.

Signed-off-by: Ioannis Tsanaktsidis <[email protected]>
  • Loading branch information
ioannistsanaktsidis committed Apr 12, 2019
1 parent 7f45eaa commit 5b9cbd7
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 192 deletions.
230 changes: 41 additions & 189 deletions INSTALL.rst
Original file line number Diff line number Diff line change
Expand Up @@ -32,49 +32,26 @@ on your machine.
Prerequisites
-------------

CERN Analysis Preservation is based on Invenio v3.0 alpha, which
requires some additional software packages:
CERN Analysis Preservation is based on Invenio v3.0.

- `Elasticsearch <https://www.elastic.co/products/elasticsearch>`_
- `PostgreSQL <http://www.postgresql.org/>`_
- `RabbitMQ <http://www.rabbitmq.com/>`_
- `Redis <http://redis.io/>`_

For example, on Debian GNU/Linux, you can install them as follows:
To run the services (ElasticSearch, RabbitMQ, PostgreSQL, Redis) simply do:

.. code-block:: shell
sudo apt-get install elasticsearch postgresql rabbitmq-server redis-server
docker-compose up
Now, add the following lines in your "elasticsearch.yml" (for
Debian GNU/Linux the full path is
``/etc/elasticsearch/elasticsearch.yml``):
In your ~/.bash_profile or ~/.bashrc add:

.. code-block:: shell
export DEBUG_MODE=True
export ENABLE_BACKEND_PROXY=true
# CAP CONFIGURATION
cluster.name: cap
discovery.zen.ping.multicast.enabled: false
http.port: 9200
http.publish_port: 9200
In order to use PostgreSQL you need to start the database server. This
is very operation system specific, so you should check how it works for
yours. When the server is running, switch to the default PostgreSQL user
and create a user who is allowed to create databases:
Finally install some required 3rd party libraries for python-ldap:

.. code-block:: shell
createuser -d $Username
Finally, do a system-wide install (see below for how to do a local
install enclosed inside your virtual environment instead) for the Sass
preprocessor by following
`Sass web guide <http://sass-lang.com/install>`_ and running:

.. code-block:: shell
sudo npm install -g [email protected] [email protected] uglify-js requirejs
sudo apt-get install libsasl2-dev python-dev libldap2-dev libsasl2-dev
Installation
------------
Expand Down Expand Up @@ -110,109 +87,59 @@ instance from inside the repository folder:
cd cap
mkvirtualenv cap
Install the CAP package from inside your ``cap`` repository folder and
run npm to install the necessary JavaScript assets the Invenio modules
depend on:
Install the CAP package from inside your ``cap`` repository folder:

.. code-block:: shell
pip install -r requirements.txt
cap npm
cdvirtualenv var/cap-instance/static
npm install bower
npm install
pip install -r requirements.txt
pip install -e .[all]
pip install -r requirements-local-forks.txt
Build the assets from your repository folder:
Install the required packages for UI:

.. code-block:: shell
cd -
cap collect -v
cap assets build
python ./scripts/schemas.py
Start Elasticsearch in the background:

.. code-block:: shell
elasticsearch &
**Note:** Instead of the following steps you may want to run
``./scripts/init.sh``.

Create a database to hold persistent data:

.. code-block:: shell
cap db init
cap db create
cd ui/
npm install
Create test user accounts and roles with which you can log in later:
or

.. code-block:: shell
cap users create [email protected] -a --password infoinfo
cap users create [email protected] -a --password alicealice
cap users create [email protected] -a --password atlasatlas
cap users create [email protected] -a --password cmscms
cap users create [email protected] -a --password lhcblhcb
cd ui/
yarn install
cap roles create [email protected]
cap roles create [email protected]
cap roles create [email protected]
cap roles create [email protected]
cap roles create [email protected]
cap roles add [email protected] [email protected]
cap roles add [email protected] [email protected]
cap roles add [email protected] [email protected]
cap roles add [email protected] [email protected]
cap roles add [email protected] [email protected]
``info`` is a superuser, ``alice`` is an ALICE user, ``atlas`` is an
ATLAS user, ``cms`` is a CMS user and ``lhcb`` is a LHCB user.

Create some basic collections for ElasticSearch:

.. code-block:: shell
cap collections create CERNAnalysisPreservation
cap collections create CMS -p CERNAnalysisPreservation
cap collections create CMSQuestionnaire -p CMS -q '_type:cmsquestionnaire'
cap collections create CMSAnalysis -p CMS -q '_type:cmsanalysis'
cap collections create LHCb -p CERNAnalysisPreservation
cap collections create LHCbAnalysis -p LHCb -q '_type:lhcbanalysis'
cap collections create ATLAS -p CERNAnalysisPreservation
cap collections create ATLASWorkflows -p ATLAS -q '_type:atlasworkflows'
cap collections create ATLASAnalysis -p ATLAS -q '_type:atlasanalysis'
cap collections create ALICE -p CERNAnalysisPreservation
Create the index in ElasticSearch using the mappings:

.. code-block:: shell
cap index init
Create a location for files:

.. code-block:: shell
cap files location local var/data --default
Finally run the setup and initialization script
``./scripts/clean-and-init.sh``.

Now you are ready to run the server.

Populating the Database with Example Records
Running the server
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

If you want to populate the database with example records simply run:
To run the backend:

.. code-block:: shell
cap run --reload
To run the the frontend:

.. code-block:: shell
cd ui/
npm start
or

.. code-block:: shell
cd ui/
yarn start
# For creating demo records with schema validation
cap fixtures records
You are ready to see the website in `action <http://localhost:3000>`_:

# For creating demo records without validation ( --force )
cap fixtures records -f

Database Migrations
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Expand All @@ -235,41 +162,6 @@ If you made some changes in one of the CAP models, Alembic can generate migratio
# To create a new revision in cap branch
cap alembic revision "Add some field" -b cap -p <parent-revision>
Prerequisites for Running the Server
------------------------------------

To run an https server you will have to create a certificate. This needs
to be done only once from inside your repository folder:

.. code-block:: shell
openssl genrsa 4096 > ssl.key
openssl req -key ssl.key -new -x509 -days 365 -sha256 -batch > ssl.crt
The certificate will be valid for 365 days.

Running the Server
------------------

Start a redis server in the background:

.. code-block:: shell
redis-server &
Start the web application locally in debug mode:

.. code-block:: shell
gunicorn -b 127.0.0.1:5000 --certfile=ssl.crt --keyfile=ssl.key cap.wsgi:application --workers 9 --log-level debug
Now you can log in locally in your browser by going to
``https://localhost:5000/login`` and entering one of the user
credentials created above, e.g. user ``[email protected]`` with
password ``infoinfo``.

General Recommendations
-----------------------
Specify Python Version
~~~~~~~~~~~~~~~~~~~~~~
Expand All @@ -281,33 +173,6 @@ creation as follows (e.g. to use python 2.7):
mkvirtualenv -p /usr/bin/python2.7 cap
Local Installation of npms and gems
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

You do not need to install sass and all npm dependencies globally on
your system. You can install them inside your virtual environment so
they will only be accessible from within it. Simply add:

.. code-block:: shell
export GEM_HOME="$VIRTUAL_ENV/gems"
export GEM_PATH=""
export PATH="$GEM_HOME/bin:$PATH"
export npm_config_prefix=$VIRTUAL_ENV
to the ``postactivate`` of your ``.virtualenv`` folder and run

.. code-block:: shell
cdvirtualenv
gem install sass
npm -g install [email protected] [email protected] uglify-js requirejs
after creating your virtual environment.

Troubleshooting
---------------

Missing Requirements
~~~~~~~~~~~~~~~~~~~~

Expand All @@ -321,17 +186,6 @@ following requirements, e.g. on Debian GNU/Linux:
The version of Python 2 given by ``python --version`` or
``python2 --version`` should be greater than 2.7.10.

Non-matching Requirements
~~~~~~~~~~~~~~~~~~~~~~~~~

If you encounter a problem with requirements that do not match it may
be because the python eggs are not included in your virtualenv and you
will have to update them running:

.. code-block:: shell
pip install -r requirements.txt
Database Indexing Problems
~~~~~~~~~~~~~~~~~~~~~~~~~~

Expand All @@ -349,8 +203,6 @@ and if that does not work try:
curl -XDELETE 'http://localhost:9200/_all'
cap db init
Docker Installation
===================

Expand Down
6 changes: 3 additions & 3 deletions ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
"dependencies": {
"grommet": "^1.0.0",
"grommet-addons": "^0.6.0",
"lodash": "4.17.5",
"lodash": "4.17.11",
"mini-css-extract-plugin": "0.4.4",
"node-sass": "4.8.3",
"object-assign": "4.1.0",
Expand All @@ -42,7 +42,7 @@
"pretty-bytes": "^4.0.2",
"query-string": "^5.1.0",
"react": "16.4.0",
"react-dom": "16.4.0",
"react-dom": "16.4.2",
"react-dropzone": "^4.2.9",
"react-json-editor-ajrm": "2.5.9",
"react-json-view": "^1.16.1",
Expand Down Expand Up @@ -264,4 +264,4 @@
},
"globals": {}
}
}
}

0 comments on commit 5b9cbd7

Please sign in to comment.