README.md 6.08 KB
Newer Older
Mauricio Giacomini Girardello's avatar
Mauricio Giacomini Girardello committed
1
# Portal MEC
2

3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
## License

Copyright (C) 2015 Centro de Computacao Cientifica e Software Livre
Departamento de Informatica - Universidade Federal do Parana

This file is part of portalmec.

portalmec is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

portalmec is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU Affero General Public License for more details.

You should have received a copy of the GNU Affero General Public License
along with portalmec.  If not, see <http://www.gnu.org/licenses/>.


Mauricio Giacomini Girardello's avatar
Mauricio Giacomini Girardello committed
24 25
## Requirements
 * rvm
Marllon's avatar
Marllon committed
26
    * Using rvm you will install ruby "2.3.1"
Marllon's avatar
Marllon committed
27
 * ruby "2.3.1"
Marllon's avatar
Marllon committed
28
 * Dspace server "5.x"
Marllon's avatar
Marllon committed
29 30
 * Postgres (>= 9.6, <=10)
    * If you will install Dspace, it is recommended to use Postgres "9.6"
31
 * Elasticsearch "6.2.4"
32
 * Redis
Marllon's avatar
Marllon committed
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49
 * nvm
    * Using nvm you will install Node.js "8.10.0"

## NVM and Node.js

For install NVM and Node.js, use this follwing commands:
```
$ wget -qO- https://raw.githubusercontent.com/creationix/nvm/v0.33.11/install.sh | bash
```

```
$ source ~/.bashrc
```

```
$ nvm install 8.10.0
``` 
50

Marllon's avatar
Marllon committed
51 52
## Postgres

Marllon's avatar
Marllon committed
53
After the first install, you can run this commands:
Marllon's avatar
Marllon committed
54 55

* ``` sudo passwd postgres ```
Marllon's avatar
Marllon committed
56 57 58 59
* ``` su postgres```
* ``` psql -c "ALTER USER postgres WITH PASSWORD '$PASSWORD'" -d template1 ```
* ``` createuser -h localhost -U postgres -d $USER_DB ```
* ``` psql -c "ALTER USER $USER_DB WITH PASSWORD '$PASSWORD'" -d template1 ```
Marllon's avatar
Marllon committed
60 61 62

Note: You can ask for the database dump for someone in the project.

Marllon's avatar
Marllon committed
63
You need to modify the file "/etc/postgresql/10/main/pg_hba.conf", the modification is
Marllon's avatar
Marllon committed
64

Marllon's avatar
Marllon committed
65
    * comment the 1st and 2nd lines with "peer" and copy them replacing "peer" with "md5".
Marllon's avatar
Marllon committed
66 67 68 69 70 71 72 73
    
After this, run this command:

* ``` systemctl stop postgresql ```
* ``` systemctl start postgresql ```

## Rvm

Marllon's avatar
Marllon committed
74
After finish the installer, you will need to add in your ~/.bashrc this commands:
Marllon's avatar
Marllon committed
75 76 77 78

* ``` export PATH="$PATH:$HOME/.rvm/bin" ```
* ``` source /home/Your_user/.rvm/scripts/rvm ```

Marllon's avatar
Marllon committed
79
After this, run the command ```source ~/.bashrc```.
Marllon's avatar
Marllon committed
80

Marllon's avatar
Marllon committed
81
``` Note ``` : If does not work, you can try modify the commands above, for this:
Marllon's avatar
Marllon committed
82 83 84 85 86

* ```export PATH="$PATH:/usr/share/rvm/bin" ```
* ```source /usr/share/rvm/scripts/rvm``` 


Mauricio Giacomini Girardello's avatar
Mauricio Giacomini Girardello committed
87
## Setup
Marllon's avatar
Marllon committed
88 89
First of all, you need to configure the dspace, elasticsearch and redis servers. Create an user for postgres database.
After this setup, open the configuration files inside the project repository and update the following files:
90

91 92 93
    * config/database.yml: change your postgres credentials for development and test environment.
    * config/dspace.yml: change your dspace host and credentials for development and test environment.
    * config/sidekiq.yml: change your redis hosts and ports.
Marllon's avatar
Marllon committed
94
    * config/initializers/elasticsearch.rb: inside elsif Rails.env.test? change url 'elasticsearch:9200' to 'localhost:9200'.
95 96
    * config/initializers/gitlab.rb: change your gitlab host for bug reports and set env var with private token. ( $ export GITLAB_PORTALMEC_PRIVATE_TOKEN=131237128937128937 )

Marllon's avatar
Marllon committed
97

Marllon's avatar
Marllon committed
98

Marllon's avatar
Marllon committed
99
## Install
Marllon's avatar
Marllon committed
100
After installed the requeriments, the first you will need to do is run:
Marllon's avatar
Marllon committed
101 102 103

*   ``` bundle install ```

Marllon's avatar
Marllon committed
104
This command will install all required gems for the project. 
Marllon's avatar
Marllon committed
105

Marllon's avatar
Marllon committed
106 107 108
```Note ```: Sometimes some gems throw errors. That is because there is a chance that you do not have all the required dependecies for the installation of the gem that failed to install. Please install the dependencies and try again.

After all gems were installed succesfuly. Please create the database using the following commands:
Marllon's avatar
Marllon committed
109
*  ``` rake db:create ```
Marllon's avatar
Marllon committed
110
* If you have the dump of the database, use it before db:migrate.
Marllon's avatar
Marllon committed
111
    * To use the dump, run this commands:  ```psql -U $DATABASE_USER -d $DATABASE_NAME < $DATABASE_PATH/dump_name.sql ```  
Marllon's avatar
Marllon committed
112
*  ``` rake db:migrate ```
Marllon's avatar
Marllon committed
113

Marllon's avatar
Marllon committed
114
``` Note ``` : You need to load the dump in the database_dev.
Marllon's avatar
Marllon committed
115 116 117 118


This procedure will create and configure all table in the project database  

Marllon's avatar
Marllon committed
119 120
For the search mechanism to works, it is required to copy ``` your_directory_path/portalmec/calculate_score.painless ``` to ``` /etc/elasticsearch/scripts ```. After this is done, 
execute the CMD in the portalmec directory ``` rake searchkick:reindex:all ```.
Marllon's avatar
Marllon committed
121 122


Marllon's avatar
Marllon committed
123 124 125
<!--### Development environment-->
<!-- Se algum dia o docker do projeto for arrumado, essa parte deve bastar como explicação -->
<!--
126
    #### Using docker for development env
Marllon's avatar
Marllon committed
127 128
    You can use docker for your development environment. For that, run: 
        ./bin/docker-setup 
129
    Now, redis, elasticsearch and postgres are running as services and linked to PortalMEC application. Database migrations were execute and the configs (database.yml, sidekiq.yml was replaced by config/docker/...).
130

131
If all development and test vars are set, run:
Marllon's avatar
Marllon committed
132 133 134



Marllon's avatar
Marllon committed
135
*    ```rake db:create``` 
Marllon's avatar
Marllon committed
136 137


Marllon's avatar
Marllon committed
138
This command will install the rubygems, create/reset your database schema, seed some default data and import all dspace data.-->
139

Marllon's avatar
Marllon committed
140
Once finished, your application is read to be used. To acess it, run CMD:
141 142
``` bundle exec rails s ```

Marllon's avatar
Marllon committed
143 144
<!--
Se a rotina de testes descrita pelo rake test for arrumada, o comando a baixo funcionara
145
### Running tests suite
Marllon's avatar
Marllon committed
146 147
For tests, TestUnit is used, and to run it
``` bundle exec rake test ```-->
Marllon's avatar
Marllon committed
148 149 150 151 152 153 154


For tests, run this commands:

* ``` export DSPACE_LOGIN=your_login ```
* ``` export DSPACE_PASS=your_password ```
* ``` source ~/.bashrc ```
Marllon's avatar
Marllon committed
155 156

* ``` bundle exec rake spec:acceptance ```
157 158 159 160 161 162 163 164

### Production environment
As you set development and test environment vars, now production vars will be needed to be set.
For that, open the file config/env_vars.sh and set them. After, run:
``` ./config/env_vars.sh ```

    * Redis vars need to be set on config/sidekiq.yml
    * In config/initializers/devise.rb, change the emails addresses. (Ex.: config.mailer_sender = 'suporte@c3sl.ufpr.br')
165

Marllon's avatar
Marllon committed
166
Now that your application is ready, you can run it using sames commands used in the install section.
167

168
After the setup, link your webserver to the app. Some OS services are in root of the project and can be used.