README.adoc 3.91 KB
Newer Older
Barbora Kompišová's avatar
readme  
Barbora Kompišová committed
1
2
3
4
= Portal Backend

Kontr portal backend 

Peter Stanko's avatar
Peter Stanko committed
5
6
image:https://gitlab.fi.muni.cz/grp-kontr2/portal/badges/master/pipeline.svg[link="https://gitlab.fi.muni.cz/grp-kontr2/portal/commits/master",title="pipeline status"]

7
8
9
10
11

== Documentation

More complex documentation you can find link:https://gitlab.fi.muni.cz/grp-kontr2/kontr-documentation[here]

Barbora Kompišová's avatar
readme  
Barbora Kompišová committed
12
13
== Getting Started

14
15
These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. 
See documentation for notes on how to deploy the project on a live system.
Barbora Kompišová's avatar
readme  
Barbora Kompišová committed
16
17

== Installation
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53

Here are simple instructions how to download and run the server. You need Python 3.6.

==== Checkout the portal project

Checkout the portal.

[source, shell]
----
$ git clone https://gitlab.fi.muni.cz/grp-kontr2/portal
----

==== Install dependencies
You need to install link:https://www.python-ldap.org/en/latest/installing.html[python-ldap], postgres development and python dev dependencies.

===== Alpine linux:

[source, shell]
----
$ apk add --update --no-cache g++ gcc libxslt-dev postgresql-dev postgresql-libs openldap-dev python3-dev
----

===== Debian:

[source, shell]
----
$ apt install ldap-utils ldapscripts libldap2-dev libsasl2-dev
----

==== Install Python dependencies
If you need to run the tests, you need to call `pipenv install` with `--dev` option.

[source, shell]
----
$ pipenv install --dev
----
Barbora Kompišová's avatar
readme  
Barbora Kompišová committed
54
55
56
57


== Running the tests

58
To run the test you need to run:
Barbora Kompišová's avatar
readme  
Barbora Kompišová committed
59
60
61

[source, bash]
----
62
$ pipenv run coverage run -m pytest
Barbora Kompišová's avatar
readme  
Barbora Kompišová committed
63
64
65
----


66
67
68
69
70
== Development Deployment


=== Deploy postgres

71
For manual deployment you need to have deployed database - for example `postgres`.
72
73
74
75
76
77
78

**Docker instance:**

[source, shell]
----
$ docker run -d --name pgdb -p 5432:5432 -e POSTGRES_USER=postgres -e POSTGRES_PASSWORD=postgres postgres:latest
----
Barbora Kompišová's avatar
readme  
Barbora Kompišová committed
79

80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
=== Deploy redis

You need redis as message broker for the celery.

[source, shell]
----
$ docker run --rm --name some-redis -p 6379:6379 -d redis redis-server  
----


=== Configure the Portal

You can use the `ENV` variables or configure it using the `portal.local.cfg` or `portal/config.py`.


Here are some important variables:

- `SQLALCHEMY_DATABASE_URI` - Database uri for SQLAlchemy (example: `postgresql://postgres:postgres@localhost:5432/postgres`)
- `JWT_SECRET_KEY` - Key to be used to encrypt the `access_code` for authentication
- `PORTAL_STORAGE_BASE_DIR` - Storage base dir - where to store all the files (examle: `/tmp/portal/storage`)
- `GITLAB_URL` - Url to Gitlab instance
- `GITLAB_CLIENT_ID` - Gitlab client id
- `GITLAB_CLIENT_SECRET` - Client secret
- `FRONTEND_URL` - Where to redirect after gitlab login was successfull
- `EMAIL_HOST` - Where is running the mail server
- `EMAIL_PORT` - Port on which the mail server is running
- `EMAIL_DEFAULT_FROM` - From who the emails are
107
- `PORTAL_DATA_WORKER_DOMAIN` - Domain where default worker will be running (default: `localhost`) This one is mostly for the template
108
- `LDAP_URL` - LDAP url, required only if you need LDAP support
109
110
111

For more take a look at the config files.

Peter Stanko's avatar
Peter Stanko committed
112
113
114
115
116
117
Logging specific:
```
LOG_LEVEL_GLOBAL = 'INFO'
LOG_LEVEL_FILE = LOG_LEVEL_GLOBAL
LOG_LEVEL_CONSOLE = LOG_LEVEL_GLOBAL
```
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146

==== Init the portal

Initialize the portal database and data

[source, shell]
----
$ flask db upgrde
$ flask data init 'dev'
$ flask users create admin --password '<your_password>'
----

==== Run the celery worker

Run the async worker

[source, shell]
----
$ celery -A app.celery worker
----

==== Run the flask server - API

Run the flask API server.

[source, shell]
----
$ flask run -p 8000
----
Barbora Kompišová's avatar
readme  
Barbora Kompišová committed
147
148
149
150


== Contributing

151
Please read `CONTRIBUTING.adoc` for details on our code of conduct,
Barbora Kompišová's avatar
readme  
Barbora Kompišová committed
152
153
154
155
and the process for submitting pull requests to us.

== Authors

156
* *Matej Dujava*
157
* *Barbora Kompišová* - https://gitlab.fi.muni.cz/xkompis[xkompis]
158
* *Kristýna Pekarková*
159
160
* *Peter Stanko* - https://gitlab.fi.muni.cz/xstanko2[xstanko2]

Barbora Kompišová's avatar
readme  
Barbora Kompišová committed
161
162
163
164
165
166
167


== Acknowledgments

* Hat tip to anyone who's code was used
* Inspiration
* etc