---
# System prepended metadata

title: installation du projet
tags: [Mode d'emploi]

---

---
tags: Mode d'emploi
---

# installation du projet

[TOC]

Dépendances
- Docker
- `pg_restore` (clients postgres)

## backend

1. cloner le dépôt

```bash
git clone git@github.com:betagouv/preuve-covoiturage.git
cd preuve-covoiturage/api
git checkout master
```

2. Créer le fichier `.env`

```
NODE_ENV=local
APP_MAINTENANCE=false

APP_SENTRY_DSN=

# Service URLs
APP_API_URL=http://localhost:8080
APP_APP_URL=http://localhost:4200

APP_JWT_SECRET=jwt_secret

# Database connections
APP_POSTGRES_URL=postgresql://postgres:postgres@postgres:5432/local

APP_REDIS_URL=redis://redis:6379

APP_MAILJET_FROM_EMAIL=rpc@example.com
APP_MAILJET_FROM_NAME=[audit] Preuve de covoiturage
APP_MAILJET_PRIVATE_KEY=
APP_MAILJET_PUBLIC_KEY=
APP_MAILJET_TEMPLATE=654884
APP_MAILJET_TEMPLATE_INVITATION=1043040
APP_MAILJET_TEMPLATE_FORGOTTEN_PASSWORD=1042951
APP_MAILJET_TEMPLATE_EMAIL=1043046
APP_MAILJET_TEMPLATE_EXPORT=1146606

# Redirect all outgoing emails to your debug mailbox
APP_MAILJET_DEBUG_EMAIL=me@example.com
APP_MAILJET_DEBUG_NAME=Jonathan Fallon

# Enable debug mode (default=false)
# renvoie TOUS les emails vers APP_MAILJET_DEBUG_EMAIL
APP_MAILJET_DEBUG_MODE=true

# permet de logguer les envois de preuves sur l'API
# dans la table acquisition.errors
# APP_DEBUG_REQUEST=true

# Utiliser un provider S3 (aws, scaleway, etc...)
AWS_ACCESS_KEY_ID=
AWS_SECRET_ACCESS_KEY=
AWS_BUCKET_NAME=
AWS_ENDPOINT=
AWS_REGION=
```

3. build des images Docker

```bash
docker-compose build --parallel --force-rm --no-cache
```

4. build de l'API

```bash
docker-compose run api yarn
docker-compose run api yarn build:all
docker-compose run api chmod u+x node_modules/@ilos/framework/dist/cli.js
docker-compose run api ln -svf ../@ilos/framework/dist/cli.js node_modules/.bin/ilos
```

5. Restauration de la base

```bash
docker-compose run -d postgres
tar xzvf 20201020114525_pdc_audit_7489.tar.gz
pg_restore -cv -Ox -d local 20201020114525_pdc_audit_7489.pgsql
```

6. Lancer l'API

```bash
docker-compose up api
```

7. Tester la connection

```bash
curl -i http://localhost:8080/uptime
```

```bash
HTTP/1.1 200 OK
X-DNS-Prefetch-Control: off
X-Frame-Options: SAMEORIGIN
Strict-Transport-Security: max-age=15552000; includeSubDomains
X-Download-Options: noopen
X-Content-Type-Options: nosniff
X-XSS-Protection: 1; mode=block
Access-Control-Allow-Origin: http://localhost:4200
Vary: Origin
Access-Control-Allow-Credentials: true
X-RateLimit-Limit: 100
X-RateLimit-Remaining: 98
Date: Tue, 20 Oct 2020 08:20:25 GMT
X-RateLimit-Reset: 1603182078
X-Response-SHA256: 93a23971a914e5eacbf0a8d25154cda309c3c1c72fbb9914d47c60f3cb681588
Content-Type: application/json; charset=utf-8
Content-Length: 17
ETag: W/"11-IkjuL6CqqtmReFMfkkvwC0sKj04"
Connection: keep-alive
Keep-Alive: timeout=5

{"hello":"world"}
```

## frontend (dashboard)

```bash
cd dashboard
yarn
yarn start
```

```bash
curl -I http://localhost:4200
```
