Commit e333c8c4 authored by Romain Loth's avatar Romain Loth

clarify the possible procedures for mysql (external or dockerized)

parent d2a42c8f
......@@ -36,11 +36,13 @@ docker-compose up
-------
#### Running in dev
Minimal config:
### Running in dev
#### Minimal config
```
sudo apt install python3
sudo pip3 install -r setup/requirements.txt
cd $INSTALL_DIR
source setup/regcomex_config.ini
```
......@@ -52,40 +54,67 @@ The form server is then accessible locally on `127.0.0.1:5000/regcomex`
-------
Or, to run the app with a real-world config:
- gunicorn webserver
- external mysql database
- external doors (simulated by docker)
#### Real-world config
1. external mysql database
2. external doors (or simulated by docker)
3. gunicorn webserver (linked to 1 & 2 via `$SQL_HOST` and `$DOORS_HOST`)
##### 1) Set up your mysql database
###### If you have your own local mysql
```
# install more prerequisites
sudo apt install docker jq
export SQL_HOST=localhost # or any other hostname/IP
```
Then just create the table following [the table specifications](https://github.com/moma/regcomex/blob/master/doc/table_specifications.md)
cd $INSTALL_DIR
source setup/regcomex_config.ini
###### If you want a dedicated mysql in docker
# external mysql setup
mkdir ../shared_mysql_data
- Follow the detailed steps in [mysql_prerequisites](https://github.com/moma/regcomex/blob/master/setup/dockers/mysql_prerequisites.md): it will explain how to create the docker and connect to it.
- Then create the table following [the table specifications](https://github.com/moma/regcomex/blob/master/doc/table_specifications.md)
- Now run it as follows:
```
# run the database docker
docker run --detach --name comex_db \
-v $INSTALL_DIR/data/shared_mysql_data:/var/lib/mysql \
--env="MYSQL_ROOT_PASSWORD=very-safe-pass" mysql
docker start comex_db
# get its IP into the env
export SQL_HOST=$(docker inspect comex_db | jq -r '.[0].NetworkSettings.IPAddress')
```
##### 2) Set up a doors connection
Again, the environment variable `DOORS_HOST` must simply be set to the doors server's hostname or IP, and `DOORS_PORT` to the doors server's exposed port.
###### If you have a doors server
```
export DOORS_HOST=yourdoorsserver
export DOORS_PORT=8989
```
###### If you have no doors server
For tests you can use a `minidoors` container
```
# build the docker image (once)
cd setup/dockers
docker build -t minidoors:latest minidoors/
# run the container (each time)
docker run -it -p 32789:8989 --name doors_test minidoors
# here also set up the doors connection
# pass the info to the env before running regcomex
export DOORS_HOST=localhost
export DOORS_PORT=8989
```
# run the app
gunicorn -b 127.0.0.1:9090 server_comex_registration:app
##### 3) Run the regomex app with gunicorn
```
gunicorn -b 0.0.0.0:9090 server_comex_registration:app
```
The form server is then accessible locally on `127.0.0.1:9090/regcomex`
The form server is then accessible locally on `0.0.0.0:9090/regcomex`
**Remarks:**
- the default ROUTE_PREFIX is /regcomex, but TODO can be changed in config file
- the mysql DB needs to be [built first](https://github.com/moma/regcomex/blob/master/setup/dockers/1-create_sql_container.md), but TODO automatize
**Remark:** the default ROUTE_PREFIX is /regcomex, but TODO can be changed in config file
-------
......@@ -105,28 +134,8 @@ server {
}
}
```
-------
### Setting up a doors connection
The environment variable `DOORS_HOST` must simply be set to the doors server's hostname or IP, and `DOORS_PORT` to the doors server's exposed port.
For tests you can use a `minidoors` container
```
# build the docker image (once)
cd setup/dockers
docker build -t minidoors:latest minidoors/
# run the container (each time)
docker run -it -p 32789:8989 --name doors_test minidoors
# pass the info to the env before running regcomex
export DOORS_HOST=localhost
export DOORS_PORT=8989
```
-------
### Connecting the data to *communityexplorer.org*
#### Connecting the data to *communityexplorer.org*
Currently the data is collected in `data/shared_mysql_data`
- the DB name is `comex_shared`
- the table is `comex_registrations`
......
## Parameters for *`data/registered.db`*
registered.db is a sqlite3 db, with 2 tables:
### Set up the tables
```
-- test_table: used in debug
-- #########################
create table test_table (
email varchar(255) unique,
initials varchar(7),
pic_file blob
) ;
# connect to your sql host or container
mysql -uroot -pvery-safe-pass -h $SQL_HOST -P 3306
-- real_table: used in prod
-- ########################
create table comex_registrations (
# --- after connection to mysql
CREATE DATABASE comex_shared ;
USE comex_shared ;
CREATE TABLE comex_registrations (
doors_uid char(36) not null unique,
-- ISO stamp like 2016-11-16T17:47:07.308Z
last_modified_date char(24) not null,
email varchar(255) not null unique primary key,
initials varchar(7) not null,
......
#### To make a docker with the mysql instead of using your local mysql server
## Sql config tips
If you have an sql running, just fill your sql hostname in `$SQL_HOST` and skip to [Set up the tables](https://github.com/moma/regcomex/blob/master/doc/table_specifications.md).
#### Prerequisites
We'll use docker and jq here
```
# install prerequisites
sudo apt install docker jq
```
#### To build and run a `comex_db` container with the mysql
*source:* hub.docker.com/r/mysql/mysql-server/
```
mkdir ../shared_mysql_data
# create the **comex_db** container
mkdir $INSTALL_DIR/data/shared_mysql_data
docker create mysql
docker run --detach --name comex_db \
docker run --detach \
--name comex_db \
--env="MYSQL_ROOT_PASSWORD=very-safe-pass"\
mysql
# get the ip
# get the ip into SQL_HOST
export SQL_HOST=$(docker inspect comex_db | jq -r '.[0].NetworkSettings.IPAddress')
```
#### To use any other mysql server
```
export SQL_HOST=localhost # or any other hostname/IP
```
### Set up the tables
```
# connect to your sql host or container
mysql -uroot -pvery-safe-pass -h $SQL_HOST -P 3306
# --- after connection to mysql
CREATE DATABASE comex_shared ;
USE comex_shared ;
CREATE TABLE comex_registrations (
doors_uid char(36) not null unique,
last_modified_date char(24) not null,
email varchar(255) not null unique primary key,
initials varchar(7) not null,
country varchar(60) not null,
first_name varchar(30) not null,
middle_name varchar(30),
last_name varchar(50) not null,
jobtitle varchar(30) not null,
keywords varchar(350) not null,
institution varchar(120) not null,
institution_type varchar(50) not null,
team_lab varchar(50),
institution_city varchar(50),
interests_text varchar(1200),
community_hashtags varchar(350),
gender char(1),
pic_file mediumblob
) ;
```
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment