[DEV] update config methodologie
This commit is contained in:
parent
b8e80bbf1f
commit
ceccd15519
9
back/config_sample.env
Normal file
9
back/config_sample.env
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
# sample value with default config:
|
||||||
|
|
||||||
|
#DB_HOSTNAME="localhost"
|
||||||
|
#DB_PORT=15032
|
||||||
|
#DB_NAME="karideo"
|
||||||
|
#DB_USER="root"
|
||||||
|
#DB_PASSWORD="postgress_password"
|
||||||
|
|
||||||
|
|
@ -4,15 +4,16 @@ services:
|
|||||||
REST_video_service:
|
REST_video_service:
|
||||||
build: src
|
build: src
|
||||||
restart: always
|
restart: always
|
||||||
environment:
|
|
||||||
SANIC_DB_ADDRESS: postgres
|
|
||||||
SANIC_DB_NAME: karideo
|
|
||||||
SANIC_DB_USER: postgres
|
|
||||||
SANIC_DB_PASSWORD: postgres
|
|
||||||
image: yui.heero/video_rest_api
|
image: yui.heero/video_rest_api
|
||||||
container_name: video_rest_api
|
container_name: video_rest_api
|
||||||
ports:
|
ports:
|
||||||
- "15080:80"
|
- "15080:80"
|
||||||
volumes:
|
volumes:
|
||||||
- ./data/data_karideo:/application/data
|
- ./data/data_karideo:/application/data
|
||||||
|
- ./default_images:/default_images:ro
|
||||||
|
env_file:
|
||||||
|
- ./config.env
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -21,6 +21,13 @@ cd rest_video
|
|||||||
Run the application
|
Run the application
|
||||||
===================
|
===================
|
||||||
|
|
||||||
|
Create configuration:
|
||||||
|
```
|
||||||
|
cp config_sample.env config.env
|
||||||
|
# set your server IP in the hostname
|
||||||
|
vim config.env
|
||||||
|
```
|
||||||
|
|
||||||
Start the application:
|
Start the application:
|
||||||
```
|
```
|
||||||
docker-compose up -d
|
docker-compose up -d
|
||||||
|
@ -13,11 +13,15 @@ import os
|
|||||||
|
|
||||||
def get_rest_config():
|
def get_rest_config():
|
||||||
variable = {
|
variable = {
|
||||||
"tmp_data": "tmp",
|
#"tmp_data": "tmp",
|
||||||
"data": "data",
|
#"data": "data",
|
||||||
"data_media": "data/media",
|
#"data_media": "data/media",
|
||||||
"host": os.getenv('REST_HOSTNAME', "0.0.0.0"),
|
#"host": os.getenv('REST_HOSTNAME', "0.0.0.0"),
|
||||||
"port": int(os.getenv('REST_PORT', 80)),
|
#"port": int(os.getenv('REST_PORT', 80)),
|
||||||
|
"db_host": os.getenv('DB_HOSTNAME', "localhost"),
|
||||||
|
"db_port": int(os.getenv('DB_PORT', 15032)),
|
||||||
|
"db_name": os.getenv('DB_NAME', "karideo"),
|
||||||
|
"db_user": os.getenv('DB_USER', "root"),
|
||||||
|
"db_password": os.getenv('DB_PASSWORD', "postgress_password"),
|
||||||
}
|
}
|
||||||
return variable
|
return variable
|
||||||
|
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
from realog import debug
|
from realog import debug
|
||||||
|
|
||||||
import psycopg2
|
import psycopg2
|
||||||
|
import config
|
||||||
|
|
||||||
connection = None
|
connection = None
|
||||||
connection_count = 0
|
connection_count = 0
|
||||||
@ -9,7 +10,8 @@ def connect_bdd():
|
|||||||
global connection_count
|
global connection_count
|
||||||
if connection == None:
|
if connection == None:
|
||||||
debug.info("connect BDD: ")
|
debug.info("connect BDD: ")
|
||||||
connection = psycopg2.connect(dbname="karideo", user="root", password="postgress_password", host="localhost", port="15032")
|
conf = config.get_rest_config()
|
||||||
|
connection = psycopg2.connect(dbname=conf["db_name"], user=conf["db_user"], password=conf["db_password"], host=conf["db_host"], port=conf["db_port"])
|
||||||
connection_count += 1
|
connection_count += 1
|
||||||
return connection
|
return connection
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user