set-up.md 3.27 KB
Newer Older
1
# Set-up
2
3
4

## Git

5
_If you don't have `git` install on your computer, look online and install it :tongue: ._
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21

Then, you can simply clone the project repository:

```bash
git clone git@gitlab.utc.fr:rex-dri/rex-dri.git && cd rex-dri
```

## Docker and docker-compose

This projects takes advantage of `docker` and `docker-compose` to ease the setup process, continuous integration, deployments, etc.

!> If you don't have those tools on your computer, you first need to install them. You can do so by following those guides:

- [`docker`](https://docs.docker.com/install/)
- [`docker-compose`](https://docs.docker.com/compose/install/)

22
_To run `Docker` your user needs to belong to the `docker` user-group (creating during the install process) or to `sudo` all `docker`-related commands. The last solution is a bit annoying when developing, so you can add your user to the `docker` group: `sudo usermod -aG docker your-user`. You can find "who" is your user with the command `whoami`. **The change will take effect after you restart your computer (or close your session and reopen it)**._
23
24
25
26
27
28
29

Once this is done, don't forget that you need to have docker running before using `docker-compose`. For example, on `Fedora 29` you need to run the following command:

```bash
sudo service docker start
```

30
Finally you can start-up all `docker` related _stuff_ using the command:
31
32

```bash
33
make dev
34
35
36
37
38
39
```

You can look at the `Makefile` to have more information on that last command and the other ones that are available.

To start all the `docker` images you will then only need to use the `make up` command.

40
**Important: the `make up` command actually lunches `docker-compose` in an _attached_ mode, so that you can easily access the logs of the docker containers. If you quit it (e.g. with `CTRL+C`), this will stop all the docker containers. So usually, you should lunch it in one shell, don't touch that shell and use another one for all other `make` command related to the containers that were lunched.**
41
42
43
44
45

## Initialization

To initialize the database associated with the project, you need to connect to the `backend` image:

46
_(As explained in the **important** section, this has to be done in another shell than the one you used for the `make up` command.)_
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75

```bash
make shell_backend
```

Then:

- Migrate the `Django` models:

```bash
./manage.py migrate
```

- Create the initial revisions:

```bash
./manage.py createinitialrevisions
```

_NB: this last command should be run every time you migrate (modify/add) some models._

When this is done you can exit the `docker` image shell (`CTRL + D`).

## Checking setup

### Backend

Run the commands bellow to check that the backend is setup correctly:

76
_(Simple check of the setup)_.
77
78
79
80
81

```bash
make check_backend
```

82
_(Run `Python` tests)_
83
84
85
86
87
88
89
90
91

```bash
make test_backend
```

### Frontend

Run the commands bellow to check that the frontend is setup correctly:

92
_(Build the `React` app)_
93
94
95
96
97

```bash
make build_frontend
```

98
_NB: At the time of the writing of the documentation there is no test for the frontend..._
99
100
101
102
103

## You are done

Once the `Docker` images are up (command `make up`), the app is available on [http://localhost:8000](http://localhost:8000).

104
**Don't miss the other pages of the documentation, in particular [the one about loading 'init' data in the app](GettingStarted/init_data.md).**