File size: 2,493 Bytes
56b6519
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
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
107
108
109
# Installation

> AuditForge uses 4 containers: the backend, the frontend, the database and the AI model.

## Production

All 4 containers can be run at once using the docker-compose file in the root directory.

!> For production usage make sure to change the certificates in `backend/ssl` and `cwe_api/ssl` folders and optionally to set the JWT secret in `backend/src/lib/auth.js` (`jwtSecret` and `jwtRefreshSecret` in `backend/src/config/config.json`) if you don't want to use random ones.

Build and run Docker containers

```
docker-compose up -d --build
```

Display backend container logs

```
docker-compose logs -f auditforge-backend
```

Stop/Start containers

```
docker-compose stop
docker-compose start
```

Remove containers

```
docker-compose down
```

Update

```
docker-compose down
git pull
docker-compose up -d --build
```

Application is accessible through https://localhost:8443  
API is accessible through https://localhost:8443/api

## Development

For development purposes, specific docker-compose file can be used in each folder (backend/frontend).

> _Source code can be modified live and application will automatically reload on changes._

Build and run backend and database containers

```
docker-compose -f backend/docker-compose.dev.yml up -d --build
```

Display backend container logs

```
docker-compose -f backend/docker-compose.dev.yml logs -f auditforge-backend
```

Stop/Start container

```
docker-compose -f backend/docker-compose.dev.yml stop
docker-compose -f backend/docker-compose.dev.yml start
```

Remove containers

```
docker-compose -f backend/docker-compose.dev.yml down
```

Application is accessible through https://localhost:8081  
API is accessible through https://localhost:8081/api

## Tests

> For now only backend tests have been written (it's a continuous work in progress)

Test files are located in `backend/tests` using Jest testing framework

Script `run_tests.sh` at the root folder can be used to launch tests :

```
Usage:        ./run_tests.sh -q|-f [-h, --help]

Options:
  -h, --help  Display help
  -q          Run quick tests (No build)
  -f          Run full tests (Build with no cache)
```

!> **Don't use it in production as it will delete the production Database**

## Backup

It's possible, even recommended, to regularly backup the `backend/mongo-data` folder. It contains all the database.

To restore :

- Stop containers
- Replace the current `backend/mongo-data` folder with the backed up one
- Start containers