Skip to content

Docker Compose specification and demo infrastructure settings #24

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
data_dumps/

24 changes: 24 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
FROM alpine:3.10
MAINTAINER Vyacheslav Tykhonov
RUN apk update && apk add --no-cache freetype && apk add python3 && apk add python3-dev && apk add py3-pip
RUN apk --update add libxml2-dev libxslt-dev libffi-dev gcc musl-dev libgcc openssl-dev curl
RUN apk add jpeg-dev zlib-dev freetype-dev lcms2-dev openjpeg-dev tiff-dev tk-dev tcl-dev
RUN apk add --update nodejs npm
RUN apk add bash gcc gfortran python python-dev py-pip build-base wget freetype-dev libpng-dev openblas-dev
RUN pip3 install --upgrade pip
RUN pip3 install cython
RUN pip3 install matplotlib
COPY . /semantic-bot
RUN pip3 install pybind11==2.2.4
WORKDIR /semantic-bot
RUN pip3 install -r requirements.txt
RUN apk add npm
RUN npm install -g yarn
ENV WORKDIR=/semantic-bot
RUN npm i
ENV DJANGO_SETTINGS_MODULE=chatbot_app.settings
ENV PYTHONPATH=$PYTHONPATH:$WORKDIR
ENV DATADIR=$WORKDIR/data_dumps
ENTRYPOINT ["bash"]
EXPOSE 8000
EXPOSE 8001
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,15 @@ SECRET_KEY = "<SECRET_KEY>"

If you get errors, proceed to the manual installation.

## Docker
Build image: `docker build -t semantic-bot .`

Run container: `docker-compose up`

Open application in your browser: http://0.0.0.0:8080

Warning: Docker container is running in the demonstration mode with configuration files in `demo` folder.

## Manual installation

install python dependencies with pip
Expand Down
171 changes: 171 additions & 0 deletions demo/settings.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,171 @@
"""

Django settings for chatbot_app project.

Generated by 'django-admin startproject' using Django 1.11.9.

For more information on this file, see
https://docs.djangoproject.com/en/1.11/topics/settings/

For the full list of settings and their values, see
https://docs.djangoproject.com/en/1.11/ref/settings/
"""

import os

# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
#BASE_DIR = "/semantic-bot/"

# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/1.11/howto/deployment/checklist/

# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = False
DEBUG = True

ALLOWED_HOSTS = ["*"]
SECRET_KEY = 'change-me'
#ALLOWED_HOSTS = ["0.0.0.0","127.0.0.1","localhost"]

# To be defined in your local_settings
DATA_API_KEY = None
MAPPING_SERIALIZER = 'YARRRML'

# If True, all URIs (classes and properties) are used only if available (returns http code 200)
CHECK_URI_AVAILABILITY = False

# Set the minimal score for an URI to be used by the chatbot (see _custom_scoring function in utils/lov_ods_api)
MINIMAL_CHATBOT_SCORE = 700

# Set the number of records to retrieve
RECORD_NUMBER = 10

# Application definition

INSTALLED_APPS = [
# 'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'chat',
'webpack_loader'
]

MIDDLEWARE = [
'django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
# 'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware'
]

ROOT_URLCONF = 'chatbot_app.urls'

TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [os.path.join(BASE_DIR, "chat/templates")],
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
'django.template.context_processors.debug',
'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
],
},
},
]

WSGI_APPLICATION = 'chatbot_app.wsgi.application'


# Database
# https://docs.djangoproject.com/en/1.11/ref/settings/#databases

DATABASES = {}


# Password validation
# https://docs.djangoproject.com/en/1.11/ref/settings/#auth-password-validators

AUTH_PASSWORD_VALIDATORS = [
{
'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
},
]

LOGGING = {
'version': 1,
'disable_existing_loggers': False,
'formatters': {
'simple': {
'format': '[%(asctime)s] [%(levelname)s] [%(module)s] %(message)s'
}
},
'handlers': {
'chatbot_results': {
'level': 'INFO',
'class': 'logging.FileHandler',
'filename': 'logs/chatbot_results.log',
'formatter': 'simple'
}
},
'loggers': {
'results_logger': {
'handlers': ['chatbot_results'],
'level': 'INFO',
'propagate': False,
}
},
}

# Internationalization
# https://docs.djangoproject.com/en/1.11/topics/i18n/

LANGUAGE_CODE = 'en-us'

TIME_ZONE = 'UTC'

USE_I18N = True

USE_L10N = True

USE_TZ = True

try:
from .local_settings import *
except ImportError:
pass

STATICFILES_DIRS = (
os.path.join(BASE_DIR, 'assets'),
)
#STATICFILES_DIRS = [os.path.join(BASE_DIR, 'static_files')]

#STATIC_ROOT = os.path.join(BASE_DIR, 'assets')
#STATIC_ROOT = '/semantic-bot/assets'
STATIC_URL = '/static/'
#STATIC_URL = 'http://dataverse.org.ua:8080/static/'
print(STATICFILES_DIRS)

WEBPACK_LOADER = {
'DEFAULT': {
'BUNDLE_DIR_NAME': 'bundles/',
'STATS_FILE': os.path.join(BASE_DIR, 'webpack-stats.json'),
}
}
8 changes: 8 additions & 0 deletions demo/start-server.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/bash

cd /semantic-bot
yarn run watch &
#/usr/bin/python3 manage.py migrate
#/usr/bin/python3 manage.py collectstatic
/usr/bin/python3 manage.py runserver 0.0.0.0:80
#yarn run watch &
17 changes: 17 additions & 0 deletions demo/webpack.watch.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
var baseConfig = require('./webpack.config.js');
var merge = require('webpack-merge');
var webpack = require('webpack');

module.exports = merge(baseConfig, {
entry: [
'webpack-dev-server/client?',
'webpack/hot/only-dev-server'
],
output: {
publicPath: '/static/bundles/',
},
plugins: [
new webpack.HotModuleReplacementPlugin(),
new webpack.NoEmitOnErrorsPlugin(),
],
});
20 changes: 20 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
version: '3.7'
services:
ontology:
build: ./
container_name: semantic-bot
privileged: true
environment:
- "WORKDIR=/semantic-bot"
- "PYTHONPATH=/semantic-bot"
- "LANG=en"
ports:
- "8080:80"
- "8081:8081"
volumes:
- ./data_dumps:/semantic-bot/data_dumps
- ./chat:/semantic-bot/chat
- ./demo/settings.py:/semantic-bot/chatbot_app/settings.py
- ./demo/start-server.sh:/semantic-bot/start-server.sh
- ./demo/webpack.watch.config.js:/semantic-bot/webpack.watch.config.js
command: '/semantic-bot/start-server.sh'
7 changes: 7 additions & 0 deletions start-server.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/bash

cd /semantic-bot
yarn run watch &
/usr/bin/python3 manage.py migrate
/usr/bin/python3 manage.py collectstatic
/usr/bin/python3 manage.py runserver 0:8000