installation.md 3.84 KB
Newer Older
Sebastian Castro's avatar
Sebastian Castro committed
1 2 3
Installation and Production Instructions
========================================

Alan Poulain's avatar
Alan Poulain committed
4
Feel free to add some more information if you solve installation issues!
5

Sebastian Castro's avatar
Sebastian Castro committed
6 7 8 9 10
Installation with Docker
------------

With the Docker installation, you have all the required softwares installed in two containers (`gogocarto` and `mongo`).

11
* Add your local user to docker group : `/usr/sbin/usermod -aG docker MY_USER`
Sarah Trichet-Allaire's avatar
Sarah Trichet-Allaire committed
12

Sebastian Castro's avatar
Sebastian Castro committed
13
* Run `make docker-build` to build the container images.
Sebastian Castro's avatar
Sebastian Castro committed
14 15 16 17 18 19

* Run `make up` to launch the containers.

* Enter the `gogocarto` container with this command: `make shell` or `docker exec -it gogocarto bash` (you can execute this one anywhere)

* Run `make init` from within the `gogocarto` container. This will launch all the required commands to finish the installation.
Sebastien Rosset's avatar
Sebastien Rosset committed
20

21
* Go to `http://localhost:3008/project/initialize` to initialize the project.
Sebastien Rosset's avatar
Sebastien Rosset committed
22

Sebastian Castro's avatar
Sebastian Castro committed
23
### Local docker-compose
Sebastian Castro's avatar
Sebastian Castro committed
24

25
If you have a specific environment, need for custom env vars, want to avoid exposing ports, etc, you can create a copy of `docker-compose.yml` named `docker-compose.local.yml` (it will be gitignored).
Sebastian Castro's avatar
Sebastian Castro committed
26 27 28


Manual Install
Sebastian Castro's avatar
Sebastian Castro committed
29 30
------------

Sebastian Castro's avatar
Sebastian Castro committed
31 32
Main requirements are :

33
1. PHP 7.4
34
2. [Composer](https://getcomposer.org/download/)
Sebastian Castro's avatar
Sebastian Castro committed
35
3. [Nodejs](https://nodejs.org/en/download/)
36
4. [MongoDB](http://php.net/manual/fr/mongodb.installation.php)
Sebastian Castro's avatar
Sebastian Castro committed
37
5. Web Server (Apache, Nginx)
Sebastian Castro's avatar
Sebastian Castro committed
38

39
Please refer to the dockerfile to know all dependencies : [DockerFile](../docker/Dockerfile)
Sebastian Castro's avatar
Sebastian Castro committed
40

41 42
You can also check [the Debian Buster Installation Guide](./installation_debian.md)

43
### Cloning Repository
Alan Poulain's avatar
Alan Poulain committed
44 45

```shell
Sebastian Castro's avatar
Sebastian Castro committed
46
git clone https://gitlab.adullact.net/pixelhumain/GoGoCarto.git
Sebastian Castro's avatar
Sebastian Castro committed
47 48
```

49
### Initialize the Project
Alan Poulain's avatar
Alan Poulain committed
50 51 52

Create an `.env.local` file containing:

Sebastian Castro's avatar
Sebastian Castro committed
53
```
Alan Poulain's avatar
Alan Poulain committed
54
MONGODB_URL=mongodb://localhost:27017
Sebastian Castro's avatar
Sebastian Castro committed
55 56
```

57
Execute the command:
Alan Poulain's avatar
Alan Poulain committed
58 59

```shell
60
make init
Sebastian Castro's avatar
Sebastian Castro committed
61 62
```

63
Now initialize your project with the following route:
Alan Poulain's avatar
Alan Poulain committed
64

65
`http://localhost/GoGoCarto/web/project/initialize`
Sebastian Castro's avatar
Sebastian Castro committed
66

Sebastian Castro's avatar
Sebastian Castro committed
67
Multi Instance Mode (Software As A Service)
Sebastian Castro's avatar
Sebastian Castro committed
68 69
--------------------------

Sebastian Castro's avatar
Sebastian Castro committed
70 71
Instead of having a single GoGoCarto instance, you can transform your site in a "farm" by turning env variable USE_AS_SAAS to true. Every instance will use a subdomain, i.e if your base url is carto-farm.org, a new instance will be located at mymap.carto-farm.org with it's own database "mymap"
Note : If your base url is already a subdomain, i.e. carto.farm.org, your root database name should equals your root url subdomain name : `DATABASE_NAME=carto`. 
Sebastian Castro's avatar
Sebastian Castro committed
72 73 74

For Development
--------------
Alan Poulain's avatar
Alan Poulain committed
75

76
Start watching for file changes (automatic recompilation):
Sebastian Castro's avatar
Sebastian Castro committed
77

Alan Poulain's avatar
Alan Poulain committed
78
```shell
Sebastian Castro's avatar
Sebastian Castro committed
79 80 81 82 83 84 85 86 87 88 89 90 91 92
make watch
```

For Production
--------------

### Cron Tabs

Here are the following cron tab you need to configure 

```shell
# for a Normal instance
@daily php GOGOCARTO_DIR/bin/console --env=prod app:elements:checkvote
@daily php GOGOCARTO_DIR/bin/console --env=prod app:elements:checkExternalSourceToUpdate
93 94 95 96
@daily php GOGOCARTO_DIR/bin/console --env=prod app:notify-moderation

@hourly php GOGOCARTO_DIR/bin/console --env=prod app:users:sendNewsletter
*/5 * * * * php GOGOCARTO_DIR/bin/console --env=prod app:webhooks:post
Sebastian Castro's avatar
Sebastian Castro committed
97 98 99 100
```

```shell
# for a SAAS instance
101 102 103 104 105 106 107
* * * * * php GOGOCARTO_DIR/bin/console --env=prod app:project:update
# If you have more than 1400 project, you should run it twice a minute :
* * * * * sleep 30 && php GOGOCARTO_DIR/bin/console --env=prod app:project:update
# Task ran for every projects that need it at once
@hourly php GOGOCARTO_DIR/bin/console --env=prod app:users:sendNewsletter
*/5 * * * * php GOGOCARTO_DIR/bin/console --env=prod app:webhooks:post

Sebastian Castro's avatar
Sebastian Castro committed
108
@daily php GOGOCARTO_DIR/bin/console --env=prod app:projects:check-for-deleting
109
# Next one is for custom domain, it works only with NGINX
110
0 * * * * cd GOGOCARTO_DIR &&bash bin/execute_custom_domain.sh
Alan Poulain's avatar
Alan Poulain committed
111 112
```

Sebastian Castro's avatar
Sebastian Castro committed
113
### Updating GoGoCarto
Sebastian Castro's avatar
Sebastian Castro committed
114

115
Each time you want to update GoGoCarto, run:
Alan Poulain's avatar
Alan Poulain committed
116 117

```shell
118
# With gogocarto user
119
make gogo-update
Sebastian Castro's avatar
Sebastian Castro committed
120
```
121

Sebastian Castro's avatar
Sebastian Castro committed
122
You can have a look to [the CHANGELOG](../CHANGELOG.md) to know what are the new features and breaking changes.