Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
clinicaltrials
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
david Chavalarias
clinicaltrials
Commits
d2a42c8f
Commit
d2a42c8f
authored
Nov 28, 2016
by
Romain Loth
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
better config for minidoors
parent
2205e6c0
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
68 additions
and
26 deletions
+68
-26
README.md
README.md
+25
-4
server_comex_registration.py
server_comex_registration.py
+16
-3
docker-compose.yml
setup/dockers/docker-compose.yml
+7
-6
Dockerfile
setup/dockers/minidoors/Dockerfile
+6
-1
regcomex.ini
setup/regcomex.ini
+0
-8
regcomex_config.ini
setup/regcomex_config.ini
+8
-0
comex_reg_form_controllers.js
static/js/comex_reg_form_controllers.js
+3
-2
base_form.html
templates/base_form.html
+3
-2
No files found.
README.md
View file @
d2a42c8f
...
...
@@ -41,7 +41,7 @@ Minimal config:
```
sudo apt install python3
sudo pip3 install -r setup/requirements.txt
source setup/regcomex.ini
source setup/regcomex
_config
.ini
```
Then to run the regcomex app in the simplest way just do:
...
...
@@ -52,13 +52,19 @@ The form server is then accessible locally on `127.0.0.1:5000/regcomex`
-------
Or, to run the app with a real webserver (gunicorn) and a new mysql database:
Or, to run the app with a real-world config:
-
gunicorn webserver
-
external mysql database
-
external doors (simulated by docker)
```
# install more prerequisites
sudo apt install docker jq
cd $INSTALL_DIR
source setup/regcomex_config.ini
# external mysql setup
mkdir ../shared_mysql_data
# run the database docker
...
...
@@ -69,6 +75,8 @@ docker run --detach --name comex_db \
# get its IP into the env
export SQL_HOST=$(docker inspect comex_db | jq -r '.[0].NetworkSettings.IPAddress')
# here also set up the doors connection
# run the app
gunicorn -b 127.0.0.1:9090 server_comex_registration:app
```
...
...
@@ -99,9 +107,22 @@ server {
```
-------
### Setting up the doors connection
### 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
The environment variable
`DOORS_HOST`
must simply be set to the doors server's hostname or IP.
# pass the info to the env before running regcomex
export DOORS_HOST=localhost
export DOORS_PORT=8989
```
-------
...
...
server_comex_registration.py
View file @
d2a42c8f
...
...
@@ -29,6 +29,12 @@ MY_HOST = environ.get('HOST', '0.0.0.0')
MY_DEBUG_FLAG
=
environ
.
get
(
'DEBUG_FLAG'
)
==
'true'
MY_SQL_HOST
=
environ
.
get
(
'SQL_HOST'
,
'172.17.0.2'
)
MY_DOORS_HOST
=
environ
.
get
(
'DOORS_HOST'
,
'0.0.0.0'
)
MY_DOORS_PORT
=
environ
.
get
(
'DOORS_PORT'
,
'8989'
)
if
MY_DEBUG_FLAG
:
print
(
"DEBUG: DOORS environ.get... =>"
,
environ
.
get
(
'DOORS_HOST'
),
environ
.
get
(
'DOORS_PORT'
))
print
(
"DEBUG: DOORS final connect params =>"
,
MY_DOORS_HOST
+
':'
+
MY_DOORS_PORT
)
print
(
"DEBUG: MYSQL final connect params =>"
,
MY_SQL_HOST
+
':3306'
)
# TODO add doors port if != 8989
# ============= app creation =============
...
...
@@ -36,7 +42,6 @@ app = Flask(__name__)
app
.
config
[
'DEBUG'
]
=
MY_DEBUG_FLAG
########### PARAMS ###########
# all columns as they are declared in form & DB as tuple:
...
...
@@ -69,11 +74,19 @@ COLS = [ ("doors_uid", True, 36),
# prefix must match what nginx conf expects
ROUTE_PREFIX
=
"/regcomex"
# ROUTE_PREFIX = "/"
#
# @app.route("/regcomex", methods=['GET','POST'])
# def one_big_form2():
# one_big_form()
@
app
.
route
(
ROUTE_PREFIX
+
"
"
,
methods
=
[
'GET'
,
'POST'
])
@
app
.
route
(
"/regcomex/
"
,
methods
=
[
'GET'
,
'POST'
])
def
one_big_form
():
if
request
.
method
==
'GET'
:
return
render_template
(
"base_form.html"
,
doors_host
=
MY_DOORS_HOST
)
return
render_template
(
"base_form.html"
,
doors_connect
=
MY_DOORS_HOST
+
':'
+
MY_DOORS_PORT
)
elif
request
.
method
==
'POST'
:
# ex: request.form = ImmutableMultiDict([('initials', 'R.L.'), ('email', 'romain.loth@iscpif.fr'), ('last_name', 'Loth'), ('country', 'France'), ('first_name', 'Romain'), ('my-captchaHash', '-773776109'), ('my-captcha', 'TSZVIN')])
# print("GOT ANSWERS <<========<<", request.form)
...
...
setup/dockers/docker-compose.yml
View file @
d2a42c8f
...
...
@@ -14,13 +14,11 @@
doors_test
:
image
:
minidoors
ports
:
-
"
8989:327
89"
-
"
32789:89
89"
# POSSIBLE volume for h2 DB itself
flask_ispcif_regcomex
:
image
:
flask_iscpif_regcomex
ports
:
-
"
9090:32790"
depends_on
:
-
mysql_regcomex
-
doors_test
...
...
@@ -28,9 +26,12 @@
-
mysql_regcomex:comex_db_backend
-
doors_test:doors_backend
environment
:
-
HOST=0.0.0.0
# script will bind server to this address
-
HOST=0.0.0.0
# script will bind server to this address
-
DEBUG_FLAG=false
-
SQL_HOST=comex_db_backend
# script will read/write sql to this host
-
DOORS_HOST=doors_backend
# script will log/register users to this host
-
SQL_HOST=comex_db_backend
# script will read/write sql to this host
#- DOORS_HOST=doors_backend # script will log/register users to this host
#- DOORS_PORT=8989 # original port on doors_backend
-
DOORS_HOST=localhost
-
DOORS_PORT=32789
# forwarded port we're accessing in tests
#TODO add php legacy communityexplorer site
setup/dockers/minidoors/Dockerfile
View file @
d2a42c8f
...
...
@@ -5,6 +5,7 @@
# Pull base image
FROM
java:8
# cf. doors/application/build.sbt for correct version
ENV
SCALA_VERSION 2.11.8
ENV
SBT_VERSION 0.13.12
ENV
DOORS_COMMIT ef7c5e0
...
...
@@ -32,7 +33,11 @@ RUN git clone https://github.com/ISCPIF/doors.git
WORKDIR
/root/doors
RUN
git checkout
$DOORS_COMMIT
WORKDIR
/root/doors/application
RUN
sbt
"project lab"
# build and compile it once so it downloads dependencies
RUN
sbt
"project lab"
compile
test
package
# sset docker run command to run doors servers
CMD
sbt "project lab" run
# ports
...
...
setup/regcomex.ini
deleted
100644 → 0
View file @
2205e6c0
# REGCOMEX INI MINIMAL CONFIG
# ===========================
HOST
=
localhost
SQL_HOST
=
localhost
DOORS_HOST
=
hello_todo
DEBUG_FLAG
=
false
setup/regcomex_config.ini
0 → 100644
View file @
d2a42c8f
# REGCOMEX SH MINIMAL CONFIG
# ==========================
export
HOST
=
localhost
export
SQL_HOST
=
localhost
export
DOORS_HOST
=
localhost
export
DOORS_PORT
=
32789
export
DEBUG_FLAG
=
false
static/js/comex_reg_form_controllers.js
View file @
d2a42c8f
...
...
@@ -47,7 +47,8 @@ var regTimestamp = document.getElementById('last_modified_date')
var
uidInput
=
document
.
getElementById
(
'doors_uid'
)
var
email
=
document
.
getElementById
(
'email'
)
var
doorsHost
=
document
.
getElementById
(
'doors_host'
).
value
// str of the form: doors_hostname:doors_port
var
doorsConnectParam
=
document
.
getElementById
(
'doors_connect'
).
value
// captchaHash should be appended by itself if normal submit,
// but we may need to do it ourselves (TODO test)
...
...
@@ -213,7 +214,7 @@ function callDoors(data, callback, apiAction) {
$
.
ajax
({
contentType
:
"application/json"
,
dataType
:
'json'
,
url
:
"http://"
+
doors
Host
+
":8989
/api/"
+
apiAction
,
url
:
"http://"
+
doors
ConnectParam
+
"
/api/"
+
apiAction
,
data
:
JSON
.
stringify
({
"login"
:
mailStr
,
"password"
:
passStr
,
...
...
templates/base_form.html
View file @
d2a42c8f
...
...
@@ -350,8 +350,9 @@
</ul>
</nav>
<!-- hidden input for doors hostname -->
<input
id=
"doors_host"
name=
"doors_host"
type=
"text"
hidden
>
{{doors_host|safe}}
</input>
<!-- hidden input for doors "hostname:port" -->
<input
id=
"doors_connect"
name=
"doors_connect"
type=
"text"
hidden
value=
"{{doors_connect|safe}}"
>
</input>
<!-- hidden input for modification date -->
<input
id=
"last_modified_date"
name=
"last_modified_date"
type=
"text"
hidden
>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment