README.md 6.08 KB
Newer Older
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/>.


24 25
## Requirements
 * rvm
mwcm17's avatar
mwcm17 committed
26
    * Using rvm you will install ruby "2.3.1"
mwcm17's avatar
mwcm17 committed
27
 * ruby "2.3.1"
mwcm17's avatar
mwcm17 committed
28
 * Dspace server "5.x"
mwcm17's avatar
mwcm17 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
mwcm17's avatar
mwcm17 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

mwcm17's avatar
mwcm17 committed
51 52
## Postgres

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

* ``` sudo passwd postgres ```
mwcm17's avatar
mwcm17 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 ```
mwcm17's avatar
mwcm17 committed
60 61 62

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

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

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

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

## Rvm

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

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

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

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

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


87
## Setup
mwcm17's avatar
mwcm17 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.
mwcm17's avatar
mwcm17 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 )

mwcm17's avatar
mwcm17 committed
97

mwcm17's avatar
mwcm17 committed
98

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

*   ``` bundle install ```

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

mwcm17's avatar
mwcm17 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:
mwcm17's avatar
mwcm17 committed
109
*  ``` rake db:create ```
mwcm17's avatar
mwcm17 committed
110
* If you have the dump of the database, use it before db:migrate.
mwcm17's avatar
mwcm17 committed
111
    * To use the dump, run this commands:  ```psql -U $DATABASE_USER -d $DATABASE_NAME < $DATABASE_PATH/dump_name.sql ```  
mwcm17's avatar
mwcm17 committed
112
*  ``` rake db:migrate ```
mwcm17's avatar
mwcm17 committed
113

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


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

mwcm17's avatar
mwcm17 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 ```.
mwcm17's avatar
mwcm17 committed
121 122


mwcm17's avatar
mwcm17 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
mwcm17's avatar
mwcm17 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:
mwcm17's avatar
mwcm17 committed
132 133 134



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


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

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

mwcm17's avatar
mwcm17 committed
143 144
<!--
Se a rotina de testes descrita pelo rake test for arrumada, o comando a baixo funcionara
145
### Running tests suite
mwcm17's avatar
mwcm17 committed
146 147
For tests, TestUnit is used, and to run it
``` bundle exec rake test ```-->
mwcm17's avatar
mwcm17 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 ```
mwcm17's avatar
mwcm17 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

mwcm17's avatar
mwcm17 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.