database configuration
This commit is contained in:
parent
4dad188a07
commit
8c1730389c
@ -3,6 +3,7 @@ FROM python:latest
|
|||||||
LABEL Maintainer="Wolfgang Hottgenroth wolfgang.hottgenroth@icloud.com"
|
LABEL Maintainer="Wolfgang Hottgenroth wolfgang.hottgenroth@icloud.com"
|
||||||
|
|
||||||
ARG APP_DIR="/opt/app"
|
ARG APP_DIR="/opt/app"
|
||||||
|
ARG CONF_DIR="${APP_DIR}/config"
|
||||||
|
|
||||||
RUN \
|
RUN \
|
||||||
apt update && \
|
apt update && \
|
||||||
@ -15,19 +16,21 @@ RUN \
|
|||||||
|
|
||||||
RUN \
|
RUN \
|
||||||
mkdir -p ${APP_DIR} && \
|
mkdir -p ${APP_DIR} && \
|
||||||
|
mkdir -p ${CONF_DIR} && \
|
||||||
useradd -d ${APP_DIR} -u 1000 user
|
useradd -d ${APP_DIR} -u 1000 user
|
||||||
|
|
||||||
COPY *.py ${APP_DIR}/
|
COPY *.py ${APP_DIR}/
|
||||||
COPY swagger.yaml ${APP_DIR}/
|
COPY swagger.yaml ${APP_DIR}/
|
||||||
COPY server.ini ${APP_DIR}/
|
COPY server.ini ${CONF_DIR}/
|
||||||
|
|
||||||
USER 1000:1000
|
USER 1000:1000
|
||||||
WORKDIR ${APP_DIR}
|
WORKDIR ${APP_DIR}
|
||||||
|
VOLUME ${CONF_DIR}
|
||||||
|
|
||||||
EXPOSE 5000
|
EXPOSE 5000
|
||||||
EXPOSE 9191
|
EXPOSE 9191
|
||||||
|
|
||||||
CMD [ "uwsgi", "server.ini" ]
|
CMD [ "uwsgi", "./config/server.ini" ]
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -2,15 +2,15 @@ import mariadb
|
|||||||
|
|
||||||
pool = None
|
pool = None
|
||||||
|
|
||||||
def createConnectionPool():
|
def createConnectionPool(config):
|
||||||
global pool
|
global pool
|
||||||
|
|
||||||
pool = mariadb.ConnectionPool(
|
pool = mariadb.ConnectionPool(
|
||||||
user = 'heroes',
|
user = config['user'],
|
||||||
password = 'test123',
|
password = config['password'],
|
||||||
host = '172.16.10.18',
|
host = config['host'],
|
||||||
database = 'heroes',
|
database = config['database'],
|
||||||
pool_name = 'wep-app',
|
pool_name = 'heroes-wep-app',
|
||||||
pool_size = 5
|
pool_size = 5
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -5,3 +5,9 @@ processes = 4
|
|||||||
threads = 2
|
threads = 2
|
||||||
stats = :9191
|
stats = :9191
|
||||||
|
|
||||||
|
[database]
|
||||||
|
host = 172.16.10.18
|
||||||
|
user = heroes
|
||||||
|
password = test123
|
||||||
|
database = heroes
|
||||||
|
|
||||||
|
@ -1,9 +1,15 @@
|
|||||||
import connexion
|
import connexion
|
||||||
from flask_cors import CORS
|
from flask_cors import CORS
|
||||||
from dbpool import createConnectionPool
|
from dbpool import createConnectionPool
|
||||||
|
import configparser
|
||||||
|
|
||||||
|
|
||||||
|
# load configuration
|
||||||
|
config = configparser.ConfigParser()
|
||||||
|
config.read('./config/server.ini')
|
||||||
|
|
||||||
# prepare database connections
|
# prepare database connections
|
||||||
createConnectionPool()
|
createConnectionPool(config['database'])
|
||||||
|
|
||||||
# instantiate the webservice
|
# instantiate the webservice
|
||||||
app = connexion.App(__name__)
|
app = connexion.App(__name__)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user