Commit 72aa6227 authored by Konstantin Schulz's avatar Konstantin Schulz
Browse files

removed port forwarding for the database (docker) container

parent 143e218e
Pipeline #11421 failed with stages
in 3 minutes and 7 seconds
[![pipeline status](https://scm.cms.hu-berlin.de/callidus/machina-callida/badges/master/pipeline.svg)](https://scm.cms.hu-berlin.de/callidus/machina-callida/-/commits/master)
[![coverage report](https://scm.cms.hu-berlin.de/callidus/machina-callida/badges/master/coverage.svg)](https://scm.cms.hu-berlin.de/callidus/machina-callida/-/commits/master)
# Machina Callida
Installation
...
Docker:
When using the application for the first time, please wait until the mc_frontend container has finished compiling the application. After that, you may access the application at http://localhost:8100.
...
\ No newline at end of file
......@@ -41,8 +41,6 @@ services:
stdin_open: true
db:
image: postgres
ports:
- "5432:5432"
restart: always
volumes:
- db-data:/var/lib/postgresql/data
......
stages:
- test
coverage:
stage: test
script:
- docker-compose build
- docker-compose run --rm mcserver bash -c "source ../venv/bin/activate && coverage run --rcfile=.coveragerc tests.py && coverage combine && coverage report -m"
coverage: '/^TOTAL.+?(\d+\%)$/'
tags:
- python
- pip
- flask
......@@ -11,7 +11,7 @@ RUN python -m venv venv
RUN apt-get update
RUN apt-get install -y openssh-server nano
COPY mcserver/requirements.txt requirements.txt
COPY requirements.txt requirements.txt
RUN venv/bin/pip install --no-cache-dir --default-timeout=120 -r requirements.txt
#prepare ssh
......
version: '3.7'
services:
csm:
build:
context: .
dockerfile: Dockerfile
command: /home/mc/venv/bin/gunicorn -c csm/gunicorn_config.py run_csm:app
depends_on:
- db
environment:
- FLASK_APP=run_csm.py
- IS_THIS_A_DOCKER_CONTAINER=Yes
- PYTHONPATH=/home/mc
ports:
- "8122:22"
- "6555:6555"
restart: always
stdin_open: true
db:
image: postgres
ports:
- "5432:5432"
restart: always
volumes:
- db-data:/var/lib/postgresql/data
mcserver:
build:
context: .
dockerfile: Dockerfile
command: /home/mc/venv/bin/gunicorn -c mcserver/gunicorn_config.py app:app
depends_on:
- db
environment:
- FLASK_APP=app.py
- IS_THIS_A_DOCKER_CONTAINER=Yes
- PYTHONPATH=/home/mc
networks:
- mc_backend
ports:
- "8022:22"
- "5000:5000"
restart: always
stdin_open: true
networks:
mc_backend:
external:
name: mc_backend_default
volumes:
db-data:
......@@ -23,7 +23,7 @@ def create_app(cfg: Type[Config] = Config) -> Flask:
"""
# use local postgres database for migrations
if len(sys.argv) > 2 and sys.argv[2] == Config.FLASK_MIGRATE:
cfg.SQLALCHEMY_DATABASE_URI = Config.DATABASE_LOCAL_URL
cfg.SQLALCHEMY_DATABASE_URI = Config.DATABASE_URL_LOCAL
app = init_app_common(cfg=cfg)
from mcserver.app.services import bp as services_bp
app.register_blueprint(services_bp)
......
......@@ -57,11 +57,10 @@ class Config(object):
CUSTOM_CORPUS_VIVA_FILE_PATH = os.path.join(ASSETS_DIRECTORY, "viva_lektionstexte1-32.txt")
CUSTOM_CORPUS_VIVA_URN = "urn:custom:latinLit:viva.lat"
CUSTOM_CORPUS_PROIEL_URN_TEMPLATE = "urn:custom:latinLit:proiel.{0}.lat"
DATABASE_LOCAL_URL = "postgresql://postgres@0.0.0.0:5432/postgres"
DATABASE_TABLE_ALEMBIC = "alembic_version"
DATABASE_URL = os.environ.get("DATABASE_URL",
("postgresql://postgres@db:5432/" if IS_DOCKER else
"postgresql://0.0.0.0:5432/postgres"))
DATABASE_URL_LOCAL = "postgresql://postgres@0.0.0.0:5432/postgres"
DATABASE_URL_FALLBACK = "postgresql://postgres@db:5432/" if IS_DOCKER else DATABASE_URL_LOCAL
DATABASE_URL = os.environ.get("DATABASE_URL", DATABASE_URL_FALLBACK)
DEBUG = False
FLASK_MIGRATE = "migrate"
GRAPHANNIS_DEPENDENCY_LINK = "dep"
......@@ -134,9 +133,7 @@ class Config(object):
class ProductionConfig(Config):
"""Configuration for the production environment"""
DEBUG = False
SQLALCHEMY_DATABASE_URI = os.environ.get("DATABASE_URL_PROD",
"postgresql://postgres@db:5432/" if
Config.IS_DOCKER else "postgresql://0.0.0.0:5432/postgres")
SQLALCHEMY_DATABASE_URI = os.environ.get("DATABASE_URL_PROD", Config.DATABASE_URL_FALLBACK)
class StagingConfig(Config):
......@@ -149,8 +146,7 @@ class DevelopmentConfig(Config):
"""Configuration for the development environment"""
DEVELOPMENT = True
DEBUG = True
SQLALCHEMY_DATABASE_URI = os.environ.get(
"DATABASE_URL", "postgresql://postgres@db:5432/" if Config.IS_DOCKER else Config.DATABASE_LOCAL_URL)
SQLALCHEMY_DATABASE_URI = os.environ.get("DATABASE_URL", Config.DATABASE_URL_FALLBACK)
class TestingConfig(Config):
......
alembic==1.1.0
aniso8601==7.0.0
astroid==2.2.5
async-timeout==3.0.1
attrs==19.1.0
beautifulsoup4==4.8.0
bleach==3.1.0
blinker==1.4
boto3==1.12.27
botocore==1.15.27
cachetools==4.0.0
certifi==2019.6.16
cffi==1.12.3
chardet==3.0.4
Click==7.0
cmarkgfm==0.4.2
conllu==1.4
coverage==4.5.4
cycler==0.10.0
decorator==4.4.0
dnspython==1.16.0
docutils==0.15.2
eventlet==0.25.1
Flask==1.1.1
Flask-Cors==3.0.8
Flask-Migrate==2.5.2
Flask-RESTful==0.3.7
Flask-SQLAlchemy==2.4.0
future==0.17.1
gensim==3.8.1
google-api-core==1.16.0
google-auth==1.11.3
google-cloud-core==1.3.0
google-cloud-storage==1.26.0
google-resumable-media==0.5.0
googleapis-common-protos==1.51.0
graphannis==0.23.1
greenlet==0.4.15
gunicorn==20.0.4
html5lib==1.0.1
httplib2==0.13.1
idna==2.8
idna-ssl==1.1.0
isodate==0.6.0
isort==4.3.21
itsdangerous==1.1.0
Jinja2==2.10.1
jmespath==0.9.5
kiwisolver==1.1.0
lazy-object-proxy==1.4.2
lxml==4.4.1
Mako==1.1.0
MarkupSafe==1.1.1
matplotlib==3.2.1
mccabe==0.6.1
monotonic==1.5
multidict==4.5.2
MyCapytain==2.0.10
networkx==2.4
nose==1.3.7
numpy==1.18.2
Pillow==6.1.0
pkginfo==1.5.0.1
protobuf==3.11.3
psutil==5.6.3
psycopg2-binary==2.8.3
pyasn1==0.4.8
pyasn1-modules==0.2.8
pycparser==2.19
Pygments==2.4.2
pylint==2.3.1
pyparsing==2.4.2
PyPDF2==1.26.0
python-dateutil==2.8.0
python-docx==0.8.10
python-dotenv==0.10.3
python-editor==1.0.4
python-rapidjson==0.8.0
pytz==2019.2
rapidjson==1.0.0
rdflib==4.2.2
rdflib-jsonld==0.4.0
readme-renderer==24.0
reportlab==3.5.23
requests==2.22.0
requests-toolbelt==0.9.1
rsa==4.0
s3transfer==0.3.3
scipy==1.4.1
six==1.12.0
smart-open==1.10.0
soupsieve==1.9.3
SQLAlchemy==1.3.8
tqdm==4.35.0
twine==1.13.0
typed-ast==1.4.0
urllib3==1.25.3
webencodings==0.5.1
Werkzeug==0.15.6
wrapt==1.11.2
xhtml2pdf==0.2.3
yarl==1.3.0
\ No newline at end of file
alembic==1.4.2
aniso8601==8.0.0
beautifulsoup4==4.9.0
blinker==1.4
boto==2.49.0
boto3==1.12.49
botocore==1.15.49
cachetools==4.1.0
certifi==2020.4.5.1
cffi==1.14.0
chardet==3.0.4
click==7.1.2
conllu==2.3.2
cycler==0.10.0
decorator==4.4.2
docutils==0.15.2
Flask==1.1.2
Flask-Cors==3.0.8
Flask-Migrate==2.5.3
Flask-RESTful==0.3.8
Flask-SQLAlchemy==2.4.1
frozendict==1.2
future==0.18.2
gensim==3.8.2
graphannis==0.27.0
html5lib==1.0.1
idna==2.9
isodate==0.6.0
itsdangerous==1.1.0
Jinja2==2.11.2
jmespath==0.9.5
kiwisolver==1.2.0
LinkHeader==0.4.3
lxml==4.5.0
Mako==1.1.2
MarkupSafe==1.1.1
matplotlib==3.2.1
MyCapytain==3.0.2
networkx==2.4
numpy==1.18.3
Pillow==7.1.2
pycparser==2.20
PyLD==2.0.2
pyparsing==2.4.7
PyPDF2==1.26.0
python-dateutil==2.8.1
python-docx==0.8.10
python-dotenv==0.13.0
python-editor==1.0.4
python-rapidjson==0.9.1
pytz==2020.1
rdflib==5.0.0
rdflib-jsonld==0.5.0
reportlab==3.5.42
requests==2.23.0
s3transfer==0.3.3
scipy==1.4.1
six==1.14.0
smart-open==2.0.0
soupsieve==2.0
SQLAlchemy==1.3.16
typing==3.7.4.1
urllib3==1.25.9
webencodings==0.5.1
Werkzeug==1.0.1
xhtml2pdf==0.2.4
......@@ -492,7 +492,7 @@ class McTestCase(unittest.TestCase):
cfg: Type[Config] = TestingConfig
old_uri: str = cfg.SQLALCHEMY_DATABASE_URI
create_app(cfg)
self.assertEqual(cfg.SQLALCHEMY_DATABASE_URI, Config.DATABASE_LOCAL_URL)
self.assertEqual(cfg.SQLALCHEMY_DATABASE_URI, Config.DATABASE_URL_LOCAL)
cfg.SQLALCHEMY_DATABASE_URI = old_uri
self.app_context.push()
......
stages:
- test
coverage:
stage: test
script:
- docker-compose build
- docker-compose run --rm --entrypoint="npm run test-ci" mc_frontend
coverage: '/Statements.*?(\d+(?:\.\d+)?)%/'
tags:
- node
- npm
- angular
version: '3.7'
services:
mc_frontend:
build:
context: .
dockerfile: Dockerfile
entrypoint: ng build --prod app
environment:
- CHROME_BIN=google-chrome
stdin_open: true
tty: true
# do not use mounted volume in combination with the node_modules directory being ignored in .dockerignore
# volumes:
# - .:/home/mc/mc_frontend
volumes:
- $PWD/www:/home/mc/mc_frontend/www
nginx:
command: nginx -g "daemon off;"
image: nginx:alpine
ports:
- "8100:80"
restart: always
volumes:
- $PWD/www:/usr/share/nginx/html
- ./nginx.conf:/etc/nginx/nginx.conf
depends_on:
- mc_frontend
networks:
default:
external: true
name: mc_backend_default
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