Skip to content

Commit

Permalink
Merge pull request #34 from Breee/master
Browse files Browse the repository at this point in the history
remove mappings, geofences
  • Loading branch information
muckelba committed Jan 19, 2020
2 parents faa5746 + 2acbb9e commit 1ff7ba4
Showing 1 changed file with 18 additions and 58 deletions.
76 changes: 18 additions & 58 deletions installation/6.docker.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,17 +30,16 @@ touch docker-compose.yml && \
mkdir docker-entrypoint-initdb && \
wget -O docker-entrypoint-initdb/rocketmap.sql https://raw.githubusercontent.com/Map-A-Droid/MAD/master/scripts/SQL/rocketmap.sql && \
cd mad/configs/ && \
touch mappings.json && \
wget -O config.ini https://raw.githubusercontent.com/Map-A-Droid/MAD/master/configs/config.ini.example && \
mkdir geofences && cd ../../
cd ../../
```

This will:
1. Create a directory `MAD-docker`.
2. Create a file `docker-compose.yml`.
3. Create a directory `MAD-docker/mad`. (here we store MAD related stuff)
4. Create a directory `MAD-docker/mad/configs`. (here we store config files for MAD).
Here you store your `config.ini`, `mappings.json` and a directory `geofences` (which contains your geofences).
Here you store your `config.ini`.
Examples for these files can be found @github https://github.com/Map-A-Droid/MAD/tree/master/configs
5. Create a directory `MAD-docker/docker-entrypoint-initdb`
6. Download the Rocketmap Database Schema: https://raw.githubusercontent.com/Map-A-Droid/MAD/master/SQL/rocketmap.sql and store it
Expand All @@ -55,47 +54,8 @@ Your directory should now look like this:
|-- mad/
|-- configs/
|-- config.ini
|-- mappings.json
|-- geofences/
```

If you start from scratch, add the following content to `mad/configs/mappings.json`:
```
{
"areas": {
"entries": {},
"index": 0
},
"auth": {
"entries": {},
"index": 0
},
"devices": {
"entries": {},
"index": 0
},
"devicesettings": {
"entries": {},
"index": 0
},
"migrated": true,
"monivlist": {
"entries": {},
"index": 0
},
"walker": {
"entries": {},
"index": 0
},
"walkerarea": {
"entries": {},
"index": 0
}
}
```
If you have an existing `mappings.json`, because you used MAD before, then just copy it over.


### 1.2 Writing the docker-compose file.
We use `docker-compose` to deploy and manage our services.

Expand All @@ -110,25 +70,23 @@ services:
volumes:
- /etc/timezone:/etc/timezone:ro
- /etc/localtime:/etc/localtime:ro
- ./mad/configs/geofences:/usr/src/app/configs/geofences
- ./mad/configs/config.ini:/usr/src/app/configs/config.ini
- ./mad/configs/mappings.json:/usr/src/app/configs/mappings.json
- ./volumes/mad/files:/usr/src/app/files
- ./volumes/mad/logs:/usr/src/app/logs
depends_on:
- rocket-db
- rocketdb
networks:
- default
ports:
- "8080:8080"
- "8000:8000"
- "5000:5000"

rocket-db:
rocketdb:
container_name: pokemon_rocketdb
image: mariadb:10.3
restart: always
command: ['mysqld', '--character-set-server=utf8mb4', '--collation-server=utf8mb4_unicode_ci']
command: ['mysqld', '--character-set-server=utf8mb4', '--collation-server=utf8mb4_unicode_ci', '--innodb_file_per_table=1', '--event-scheduler=ON', '--sql-mode=NO_ENGINE_SUBSTITUTION']
environment:
MYSQL_ROOT_PASSWORD: StrongPassword
MYSQL_DATABASE: rocketdb
Expand All @@ -151,7 +109,7 @@ In the docker-image, the whole MAD repository is located in `/usr/src/app`.

**Volumes:**
- The volumes define what is mounted into the docker-container.
- On one hand we mount the **configuration files (config.ini, mappings.json)** and the **geofences** we need.
- On one hand we mount the **configuration file (config.ini)**.
- On the other hand we "mount out" the **files/directories produced by MAD**,
such as the directory `logs` and also the `files` directory, which contains all calculated routes, position files and stats. As usual,
volumes are needed for everything **you do not want to loose** after you take the docker-container down.
Expand All @@ -164,15 +122,15 @@ So e.g. `https://your-domain.com:8080` will point to port `8080` of the containe
In this case in RGC you would put `https://your-domain.com:8080` as target, in pogodroid `http://your-domain.com:8000`
and madmin would be reachable under `https://your-domain.com:5000`.

#### 1.2.2 The `rocket-db` service.
The `rocket-db` service is docker-container based on [mariadb:10.3](https://hub.docker.com/_/mariadb).
#### 1.2.2 The `rocketdb` service.
The `rocketdb` service is docker-container based on [mariadb:10.3](https://hub.docker.com/_/mariadb).
It will start a mariadb database server and automatically create the defined used `MYSQL_USER` with password `MYSQL_PASSWORD`.

**Your job here is to set secure passwords for `MYSQL_ROOT_PASSWORD` and `MYSQL_PASSWORD`.**

**The database is reachable in the default network as `rocket-db`, so in your config.ini it looks like this:**
**The database is reachable in the default network as `rocketdb`, so in your config.ini it looks like this:**
```
dbip: rocket-db # IP adress or hostname of the mysql server
dbip: rocketdb # IP adress or hostname of the mysql server
dbusername: rocketdb # USERname for database
dbpassword: AnotherStrongPassword # Password for that username
dbname: rocketdb # Name of the database
Expand All @@ -186,13 +144,13 @@ All *.sql scripts in this directory are executed, once the container starts.
Let's deploy the database, shall we?
Just execute:
```
docker-compose up -d rocket-db
docker-compose up -d rocketdb
```

This will start the `rocket-db` service and execute `rocketmap.sql` in `docker-entrypoint-initdb`.
This will start the `rocketdb` service and execute `rocketmap.sql` in `docker-entrypoint-initdb`.
Take a look at the logs:
```
docker-compose logs -f rocket-db
docker-compose logs -f rocketdb
```
and verify that the database was initialized without problems.

Expand All @@ -208,20 +166,22 @@ Look at the logs with:
docker-compose logs -f mad
```

go to `https://your-domain.com:5000` and check if the MADmin is running.

## 2 Some useful commands to maintain MAD + DB
#### Dump DB:
```
docker-compose exec -T rocket-db /usr/bin/mysqldump -uroot -pStrongPassword rocketdb > $(date +"%Y-%m-%d")_rocketmap_backup.sql
docker-compose exec -T rocketdb /usr/bin/mysqldump -uroot -pStrongPassword rocketdb > $(date +"%Y-%m-%d")_rocketmap_backup.sql
```

#### Restore DB:
```
cat <backup>.sql | docker-compose exec -T rocket-db /usr/bin/mysql -uroot -pStrongPassword rocketdb
cat <backup>.sql | docker-compose exec -T rocketdb /usr/bin/mysql -uroot -pStrongPassword rocketdb
```

#### mysql cli:
```
docker-compose exec rocket-db /usr/bin/mysql -uroot -pStrongPassword rocketdb
docker-compose exec rocketdb /usr/bin/mysql -uroot -pStrongPassword rocketdb
```


Expand Down

0 comments on commit 1ff7ba4

Please sign in to comment.