mirror of
https://gitlab.ub.uni-bielefeld.de/sfb1288inf/nopaque.git
synced 2025-01-13 03:30:35 +00:00
Compare commits
5 Commits
f79c6d48b2
...
81c6f32a35
Author | SHA1 | Date | |
---|---|---|---|
|
81c6f32a35 | ||
|
94548ac30c | ||
|
158190de1a | ||
|
13e4d461c7 | ||
|
e51dcafa6f |
22
.env.tpl
22
.env.tpl
@ -1,32 +1,20 @@
|
|||||||
##############################################################################
|
##############################################################################
|
||||||
# Variables for use in Docker Compose YAML files #
|
# Environment variables used by Docker Compose config files. #
|
||||||
##############################################################################
|
##############################################################################
|
||||||
# HINT: Use this bash command `id -u`
|
# HINT: Use this bash command `id -u`
|
||||||
# NOTE: 0 (= root user) is not allowed
|
# NOTE: 0 (= root user) is not allowed
|
||||||
HOST_UID=
|
HOST_UID=
|
||||||
|
|
||||||
# HINT: Use this bash command `id -g`
|
# HINT: Use this bash command `id -g`
|
||||||
|
# NOTE: 0 (= root group) is not allowed
|
||||||
HOST_GID=
|
HOST_GID=
|
||||||
|
|
||||||
# HINT: Use this bash command `getent group docker | cut -d: -f3`
|
# HINT: Use this bash command `getent group docker | cut -d: -f3`
|
||||||
HOST_DOCKER_GID=
|
HOST_DOCKER_GID=
|
||||||
|
|
||||||
# DEFAULT: nopaque
|
# DEFAULT: nopaque
|
||||||
# DOCKER_DEFAULT_NETWORK_NAME=
|
NOPAQUE_DOCKER_NETWORK_NAME=nopaque
|
||||||
|
|
||||||
# DEFAULT: ./volumes/db/data
|
|
||||||
# NOTE: Use `.` as <project-basedir>
|
|
||||||
# DOCKER_DB_SERVICE_DATA_VOLUME_SOURCE_PATH=
|
|
||||||
|
|
||||||
# DEFAULT: ./volumes/mq/data
|
|
||||||
# NOTE: Use `.` as <project-basedir>
|
|
||||||
# DOCKER_MQ_SERVICE_DATA_VOLUME_SOURCE_PATH=
|
|
||||||
|
|
||||||
# NOTE: This must be a network share and it must be available on all
|
# NOTE: This must be a network share and it must be available on all
|
||||||
# Docker Swarm nodes, mounted to the same path with the same
|
# Docker Swarm nodes, mounted to the same path.
|
||||||
# user and group ownership.
|
HOST_NOPAQUE_DATA_PATH=/mnt/nopaque
|
||||||
DOCKER_NOPAQUE_SERVICE_DATA_VOLUME_SOURCE_PATH=
|
|
||||||
|
|
||||||
# DEFAULT: ./volumes/nopaque/logs
|
|
||||||
# NOTE: Use `.` as <project-basedir>
|
|
||||||
# DOCKER_NOPAQUE_SERVICE_LOGS_VOLUME_SOURCE_PATH=.
|
|
||||||
|
18
.vscode/settings.json
vendored
18
.vscode/settings.json
vendored
@ -1,19 +1,7 @@
|
|||||||
{
|
{
|
||||||
"editor.rulers": [79],
|
"editor.rulers": [79],
|
||||||
|
"editor.tabSize": 2,
|
||||||
"files.insertFinalNewline": true,
|
"files.insertFinalNewline": true,
|
||||||
"[css]": {
|
"files.trimFinalNewlines": true,
|
||||||
"editor.tabSize": 2
|
"files.trimTrailingWhitespace": true
|
||||||
},
|
|
||||||
"[html]": {
|
|
||||||
"editor.tabSize": 2
|
|
||||||
},
|
|
||||||
"[javascript]": {
|
|
||||||
"editor.tabSize": 2
|
|
||||||
},
|
|
||||||
"[jinja-html]": {
|
|
||||||
"editor.tabSize": 2
|
|
||||||
},
|
|
||||||
"[scss]": {
|
|
||||||
"editor.tabSize": 2
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -2,7 +2,9 @@ from flask import current_app
|
|||||||
from flask_migrate import upgrade
|
from flask_migrate import upgrade
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from typing import List
|
from typing import List
|
||||||
|
from app import db
|
||||||
from app.models import (
|
from app.models import (
|
||||||
|
Corpus,
|
||||||
CorpusFollowerRole,
|
CorpusFollowerRole,
|
||||||
Role,
|
Role,
|
||||||
SpaCyNLPPipelineModel,
|
SpaCyNLPPipelineModel,
|
||||||
@ -15,7 +17,7 @@ from . import bp
|
|||||||
@bp.cli.command('deploy')
|
@bp.cli.command('deploy')
|
||||||
def deploy():
|
def deploy():
|
||||||
''' Run deployment tasks. '''
|
''' Run deployment tasks. '''
|
||||||
# Make default directories
|
|
||||||
print('Make default directories')
|
print('Make default directories')
|
||||||
base_dir = current_app.config['NOPAQUE_DATA_DIR']
|
base_dir = current_app.config['NOPAQUE_DATA_DIR']
|
||||||
default_dirs: List[Path] = [
|
default_dirs: List[Path] = [
|
||||||
@ -28,11 +30,9 @@ def deploy():
|
|||||||
if not default_dir.is_dir():
|
if not default_dir.is_dir():
|
||||||
raise NotADirectoryError(f'{default_dir} is not a directory')
|
raise NotADirectoryError(f'{default_dir} is not a directory')
|
||||||
|
|
||||||
# migrate database to latest revision
|
|
||||||
print('Migrate database to latest revision')
|
print('Migrate database to latest revision')
|
||||||
upgrade()
|
upgrade()
|
||||||
|
|
||||||
# Insert/Update default database values
|
|
||||||
print('Insert/Update default Roles')
|
print('Insert/Update default Roles')
|
||||||
Role.insert_defaults()
|
Role.insert_defaults()
|
||||||
print('Insert/Update default Users')
|
print('Insert/Update default Users')
|
||||||
@ -44,4 +44,9 @@ def deploy():
|
|||||||
print('Insert/Update default TesseractOCRPipelineModels')
|
print('Insert/Update default TesseractOCRPipelineModels')
|
||||||
TesseractOCRPipelineModel.insert_defaults()
|
TesseractOCRPipelineModel.insert_defaults()
|
||||||
|
|
||||||
|
print('Stop running analysis sessions')
|
||||||
|
for corpus in Corpus.query.filter(Corpus.num_analysis_sessions > 0).all():
|
||||||
|
corpus.num_analysis_sessions = 0
|
||||||
|
db.session.commit()
|
||||||
|
|
||||||
# TODO: Implement checks for if the nopaque network exists
|
# TODO: Implement checks for if the nopaque network exists
|
||||||
|
65
config.py
65
config.py
@ -20,6 +20,7 @@ class Config:
|
|||||||
APIFAIRY_UI_PATH = '/api'
|
APIFAIRY_UI_PATH = '/api'
|
||||||
|
|
||||||
''' # Flask # '''
|
''' # Flask # '''
|
||||||
|
APPLICATION_ROOT = os.environ.get('APPLICATION_ROOT', '/')
|
||||||
PREFERRED_URL_SCHEME = os.environ.get('PREFERRED_URL_SCHEME', 'http')
|
PREFERRED_URL_SCHEME = os.environ.get('PREFERRED_URL_SCHEME', 'http')
|
||||||
SECRET_KEY = os.environ.get('SECRET_KEY', 'hard to guess string')
|
SECRET_KEY = os.environ.get('SECRET_KEY', 'hard to guess string')
|
||||||
SERVER_NAME = os.environ.get('SERVER_NAME', 'localhost:5000')
|
SERVER_NAME = os.environ.get('SERVER_NAME', 'localhost:5000')
|
||||||
@ -34,7 +35,7 @@ class Config:
|
|||||||
|
|
||||||
''' # Flask-Hashids '''
|
''' # Flask-Hashids '''
|
||||||
HASHIDS_MIN_LENGTH = int(os.environ.get('HASHIDS_MIN_LENGTH', '16'))
|
HASHIDS_MIN_LENGTH = int(os.environ.get('HASHIDS_MIN_LENGTH', '16'))
|
||||||
HASHIDS_SALT=os.environ.get('HASHIDS_SALT', 'hard to guess string')
|
HASHIDS_SALT = os.environ.get('HASHIDS_SALT', 'hard to guess string')
|
||||||
|
|
||||||
''' # Flask-Login # '''
|
''' # Flask-Login # '''
|
||||||
REMEMBER_COOKIE_SECURE = \
|
REMEMBER_COOKIE_SECURE = \
|
||||||
@ -85,17 +86,15 @@ class Config:
|
|||||||
'[%(asctime)s] %(levelname)s in '
|
'[%(asctime)s] %(levelname)s in '
|
||||||
'%(pathname)s (function: %(funcName)s, line: %(lineno)d): %(message)s'
|
'%(pathname)s (function: %(funcName)s, line: %(lineno)d): %(message)s'
|
||||||
)
|
)
|
||||||
NOPAQUE_LOG_LEVEL = os.environ.get('NOPAQUE_LOG_LEVEL', 'INFO')
|
|
||||||
NOPAQUE_LOG_FILE_ENABLED = \
|
NOPAQUE_LOG_FILE_ENABLED = \
|
||||||
os.environ.get('NOPAQUE_LOG_FILE_ENABLED', 'true').lower() == 'true'
|
os.environ.get('NOPAQUE_LOG_FILE_ENABLED', 'false').lower() == 'true'
|
||||||
NOPAQUE_LOG_FILE_DIR = \
|
NOPAQUE_LOG_FILE_DIR = Path(os.environ.get('NOPAQUE_LOG_FILE_DIR', '/var/log/nopaque'))
|
||||||
os.environ.get('NOPAQUE_LOGS_PATH', os.path.join(basedir, 'logs'))
|
|
||||||
NOPAQUE_LOG_FILE_LEVEL = \
|
NOPAQUE_LOG_FILE_LEVEL = \
|
||||||
os.environ.get('NOPAQUE_LOG_FILE_LEVEL', NOPAQUE_LOG_LEVEL)
|
os.environ.get('NOPAQUE_LOG_FILE_LEVEL', None)
|
||||||
NOPAQUE_LOG_STDERR_ENABLED = \
|
NOPAQUE_LOG_STDERR_ENABLED = \
|
||||||
os.environ.get('NOPAQUE_LOG_STDERR_ENABLED', 'false').lower() == 'true'
|
os.environ.get('NOPAQUE_LOG_STDERR_ENABLED', 'true').lower() == 'true'
|
||||||
NOPAQUE_LOG_STDERR_LEVEL = \
|
NOPAQUE_LOG_STDERR_LEVEL = \
|
||||||
os.environ.get('NOPAQUE_LOG_STDERR_LEVEL', NOPAQUE_LOG_LEVEL)
|
os.environ.get('NOPAQUE_LOG_STDERR_LEVEL', None)
|
||||||
|
|
||||||
NOPAQUE_PROXY_FIX_ENABLED = \
|
NOPAQUE_PROXY_FIX_ENABLED = \
|
||||||
os.environ.get('NOPAQUE_PROXY_FIX_ENABLED', 'false').lower() == 'true'
|
os.environ.get('NOPAQUE_PROXY_FIX_ENABLED', 'false').lower() == 'true'
|
||||||
@ -119,42 +118,35 @@ class Config:
|
|||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def init_app(app: Flask):
|
def init_app(app: Flask):
|
||||||
# Set up logging according to the corresponding (NOPAQUE_LOG_*)
|
|
||||||
# configurations
|
|
||||||
app.logger.setLevel(app.config['NOPAQUE_LOG_LEVEL'])
|
|
||||||
# Remove existing handlers
|
|
||||||
for handler in app.logger.handlers:
|
for handler in app.logger.handlers:
|
||||||
app.logger.removeHandler(handler)
|
app.logger.removeHandler(handler)
|
||||||
# Setup handlers
|
|
||||||
formatter = logging.Formatter(
|
log_formatter = logging.Formatter(
|
||||||
fmt=app.config['NOPAQUE_LOG_FORMAT'],
|
fmt=app.config['NOPAQUE_LOG_FORMAT'],
|
||||||
datefmt=app.config['NOPAQUE_LOG_DATE_FORMAT']
|
datefmt=app.config['NOPAQUE_LOG_DATE_FORMAT']
|
||||||
)
|
)
|
||||||
if app.config['NOPAQUE_IS_PRIMARY_INSTANCE']:
|
|
||||||
app.config['JOBS'].append(
|
|
||||||
{
|
|
||||||
"id": "daemon",
|
|
||||||
"func": "app.daemon:daemon",
|
|
||||||
"args": (app,),
|
|
||||||
"trigger": "interval",
|
|
||||||
"seconds": 3,
|
|
||||||
}
|
|
||||||
)
|
|
||||||
if app.config['NOPAQUE_LOG_STDERR_ENABLED']:
|
if app.config['NOPAQUE_LOG_STDERR_ENABLED']:
|
||||||
|
log_stderr_level: str | None = app.config['NOPAQUE_LOG_STDERR_LEVEL']
|
||||||
stream_handler = logging.StreamHandler()
|
stream_handler = logging.StreamHandler()
|
||||||
stream_handler.setFormatter(formatter)
|
stream_handler.setFormatter(log_formatter)
|
||||||
stream_handler.setLevel(app.config['NOPAQUE_LOG_STDERR_LEVEL'])
|
if log_stderr_level is not None:
|
||||||
|
stream_handler.setLevel(log_stderr_level)
|
||||||
app.logger.addHandler(stream_handler)
|
app.logger.addHandler(stream_handler)
|
||||||
|
|
||||||
if app.config['NOPAQUE_LOG_FILE_ENABLED']:
|
if app.config['NOPAQUE_LOG_FILE_ENABLED']:
|
||||||
if not os.path.exists(app.config['NOPAQUE_LOG_FILE_DIR']):
|
log_file_dir: Path = app.config['NOPAQUE_LOG_FILE_DIR']
|
||||||
os.mkdir(app.config['NOPAQUE_LOG_FILE_DIR'])
|
log_file_level: str | None = app.config['NOPAQUE_LOG_FILE_LEVEL']
|
||||||
|
if not log_file_dir.exists():
|
||||||
|
log_file_dir.mkdir()
|
||||||
rotating_file_handler = RotatingFileHandler(
|
rotating_file_handler = RotatingFileHandler(
|
||||||
os.path.join(app.config['NOPAQUE_LOG_FILE_DIR'], 'nopaque.log'), # noqa
|
log_file_dir / 'nopaque.log',
|
||||||
maxBytes=10_240,
|
maxBytes=10_240,
|
||||||
backupCount=10
|
backupCount=10
|
||||||
)
|
)
|
||||||
rotating_file_handler.setFormatter(formatter)
|
rotating_file_handler.setFormatter(log_formatter)
|
||||||
rotating_file_handler.setLevel(app.config['NOPAQUE_LOG_FILE_LEVEL']) # noqa
|
if log_file_level is not None:
|
||||||
|
rotating_file_handler.setLevel(log_file_level)
|
||||||
app.logger.addHandler(rotating_file_handler)
|
app.logger.addHandler(rotating_file_handler)
|
||||||
|
|
||||||
if app.config['NOPAQUE_PROXY_FIX_ENABLED']:
|
if app.config['NOPAQUE_PROXY_FIX_ENABLED']:
|
||||||
@ -168,3 +160,14 @@ class Config:
|
|||||||
x_prefix=app.config['NOPAQUE_PROXY_FIX_X_PREFIX'],
|
x_prefix=app.config['NOPAQUE_PROXY_FIX_X_PREFIX'],
|
||||||
x_proto=app.config['NOPAQUE_PROXY_FIX_X_PROTO']
|
x_proto=app.config['NOPAQUE_PROXY_FIX_X_PROTO']
|
||||||
)
|
)
|
||||||
|
|
||||||
|
if app.config['NOPAQUE_IS_PRIMARY_INSTANCE']:
|
||||||
|
app.config['JOBS'].append(
|
||||||
|
{
|
||||||
|
"id": "daemon",
|
||||||
|
"func": "app.daemon:daemon",
|
||||||
|
"args": (app,),
|
||||||
|
"trigger": "interval",
|
||||||
|
"seconds": 3,
|
||||||
|
}
|
||||||
|
)
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
##############################################################################
|
##############################################################################
|
||||||
# Environment variables to configure the db service in docker-compose.yml. #
|
# Environment variables used by the Docker db service. #
|
||||||
# #
|
# #
|
||||||
# More information about the environment variables can be found here: #
|
# More information about the environment variables can be found here: #
|
||||||
# https://hub.docker.com/_/postgres #
|
# https://hub.docker.com/_/postgres #
|
||||||
|
@ -1,62 +1,55 @@
|
|||||||
# The docker-compose.yml file is not meant to be modified itself.
|
# This file is not meant to be modified, use the following files instead:
|
||||||
# Instead use the following files for configurations:
|
# - `.env`: Environment variables available within Docker Compose config files.
|
||||||
# - .env: Environment variables for the docker-compose.yml file.
|
# - `db.env`: Environment variables for the database service.
|
||||||
# - db.env: Environment variables for the database service.
|
# - `nopaque.env`: Environment variables for the nopaque service.
|
||||||
# - nopaque.env: Environment variables for the nopaque service.
|
# - `docker-compose.override.yml`: Override the docker-compose.yml file.
|
||||||
# - docker-compose.override.yml: Override the docker-compose.yml file.
|
# - The `docker-compose` directory includes examples for this.
|
||||||
# - Don't change too much here, it's meant for configurations like exposing
|
|
||||||
# ports for development or adding labels for e.g. traefik.
|
|
||||||
|
|
||||||
networks:
|
networks:
|
||||||
default:
|
nopaque:
|
||||||
name: "${DOCKER_DEFAULT_NETWORK_NAME:-nopaque}"
|
attachable: true
|
||||||
|
driver: "overlay"
|
||||||
|
name: "${NOPAQUE_DOCKER_NETWORK_NAME}"
|
||||||
|
|
||||||
services:
|
services:
|
||||||
db:
|
db:
|
||||||
env_file: db.env
|
env_file: "db.env"
|
||||||
image: postgres:11
|
image: "postgres:11"
|
||||||
restart: unless-stopped
|
networks:
|
||||||
|
- "nopaque"
|
||||||
|
restart: "unless-stopped"
|
||||||
volumes:
|
volumes:
|
||||||
- type: bind
|
- "./volumes/db/data:/var/lib/postgresql/data"
|
||||||
source: "${DOCKER_DB_SERVICE_DATA_VOLUME_SOURCE_PATH:-./volumes/db/data}"
|
|
||||||
target: "/var/lib/postgresql/data"
|
|
||||||
|
|
||||||
mq:
|
mq:
|
||||||
image: redis:6
|
image: "redis:6"
|
||||||
restart: unless-stopped
|
networks:
|
||||||
|
- "nopaque"
|
||||||
|
restart: "unless-stopped"
|
||||||
volumes:
|
volumes:
|
||||||
- type: bind
|
- "./volumes/mq/data:/data"
|
||||||
source: "${DOCKER_MQ_SERVICE_DATA_VOLUME_SOURCE_PATH:-./volumes/mq/data}"
|
|
||||||
target: "/data"
|
|
||||||
|
|
||||||
nopaque:
|
nopaque:
|
||||||
build: .
|
build: .
|
||||||
depends_on:
|
depends_on:
|
||||||
- db
|
- "db"
|
||||||
- mq
|
- "mq"
|
||||||
env_file:
|
env_file:
|
||||||
- nopaque.env
|
- "nopaque.env"
|
||||||
environment:
|
environment:
|
||||||
# This section overrides the values set in the nopaque.env file. Do not
|
# DANGER: Don't change the following environment variables within a
|
||||||
# override the environment variables in a docker-compose.override.yml
|
# Docker Compose config file, use the `.env` file instead.
|
||||||
# file unless you really know what you are doing.
|
HOST_UID: "${HOST_UID}"
|
||||||
- NOPAQUE_UID=${HOST_UID}
|
HOST_GID: "${HOST_GID}"
|
||||||
- NOPAQUE_GID=${HOST_GID}
|
HOST_DOCKER_GID: "${HOST_DOCKER_GID}"
|
||||||
- DOCKER_GID=${HOST_DOCKER_GID}
|
NOPAQUE_DATA_PATH: "${HOST_NOPAQUE_DATA_PATH}"
|
||||||
- NOPAQUE_DATA_PATH=${DOCKER_NOPAQUE_SERVICE_DATA_VOLUME_SOURCE_PATH}
|
NOPAQUE_DOCKER_NETWORK_NAME: "${NOPAQUE_DOCKER_NETWORK_NAME}"
|
||||||
- NOPAQUE_DOCKER_NETWORK_NAME=${DOCKER_DEFAULT_NETWORK_NAME:-nopaque}
|
image: "nopaque:latest"
|
||||||
- NOPAQUE_LOGS_PATH=/home/nopaque/logs
|
networks:
|
||||||
image: nopaque:latest
|
- "nopaque"
|
||||||
restart: unless-stopped
|
restart: "unless-stopped"
|
||||||
volumes:
|
volumes:
|
||||||
- type: bind
|
- "/var/run/docker.sock:/var/run/docker.sock"
|
||||||
source: "/var/run/docker.sock"
|
# DANGER: Don't change the following mount within a Docker Compose
|
||||||
target: "/var/run/docker.sock"
|
# config file, use the `.env` file instead.
|
||||||
# TODO: Make this less quirky. The target path should be variable.
|
- "${HOST_NOPAQUE_DATA_PATH}:${HOST_NOPAQUE_DATA_PATH}"
|
||||||
# In order to achieve this, a cifs volume needs to be configured.
|
|
||||||
- type: bind
|
|
||||||
source: "${DOCKER_NOPAQUE_SERVICE_DATA_VOLUME_SOURCE_PATH}"
|
|
||||||
target: "${DOCKER_NOPAQUE_SERVICE_DATA_VOLUME_SOURCE_PATH}"
|
|
||||||
- type: bind
|
|
||||||
source: "${DOCKER_NOPAQUE_SERVICE_LOGS_VOLUME_SOURCE_PATH:-./volumes/nopaque/logs}"
|
|
||||||
target: "/home/nopaque/logs"
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
services:
|
services:
|
||||||
nopaque:
|
nopaque:
|
||||||
environment:
|
environment:
|
||||||
- FLASK_DEBUG=True
|
FLASK_DEBUG: "True"
|
||||||
ports:
|
ports:
|
||||||
- "5000:5000"
|
- "5000:5000"
|
||||||
volumes:
|
volumes:
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
services:
|
services:
|
||||||
nopaque:
|
nopaque:
|
||||||
environment:
|
environment:
|
||||||
- NOPAQUE_IS_PRIMARY_INSTANCE=False
|
NOPAQUE_IS_PRIMARY_INSTANCE: "False"
|
||||||
|
@ -6,29 +6,26 @@ networks:
|
|||||||
services:
|
services:
|
||||||
nopaque:
|
nopaque:
|
||||||
environment:
|
environment:
|
||||||
- NOPAQUE_PROXY_FIX_ENABLED=True
|
NOPAQUE_PROXY_FIX_ENABLED: "True"
|
||||||
- NOPAQUE_PROXY_FIX_X_FOR=1
|
NOPAQUE_PROXY_FIX_X_FOR: "1"
|
||||||
- NOPAQUE_PROXY_FIX_X_HOST=1
|
NOPAQUE_PROXY_FIX_X_HOST: "1"
|
||||||
- NOPAQUE_PROXY_FIX_X_PORT=1
|
NOPAQUE_PROXY_FIX_X_PORT: "1"
|
||||||
- NOPAQUE_PROXY_FIX_X_PREFIX=0
|
NOPAQUE_PROXY_FIX_X_PREFIX: "0"
|
||||||
- NOPAQUE_PROXY_FIX_X_PROTO=1
|
NOPAQUE_PROXY_FIX_X_PROTO: "1"
|
||||||
labels:
|
labels:
|
||||||
- "traefik.docker.network=traefik"
|
|
||||||
- "traefik.enable=true"
|
- "traefik.enable=true"
|
||||||
### <http> ###
|
# HTTP
|
||||||
- "traefik.http.routers.http-nopaque.entrypoints=http"
|
- "traefik.http.routers.http-nopaque.entrypoints=http"
|
||||||
- "traefik.http.routers.http-nopaque.middlewares=redirect-to-https@file"
|
- "traefik.http.routers.http-nopaque.middlewares=redirect-to-https@file"
|
||||||
# Replace <nopaque-domain> with your domain
|
# Replace <nopaque-domain> with your domain
|
||||||
- "traefik.http.routers.http-nopaque.rule=Host(`<nopaque-domain>`)"
|
- "traefik.http.routers.http-nopaque.rule=Host(`<nopaque-domain>`)"
|
||||||
### </http> ###
|
# HTTPS
|
||||||
### <https> ###
|
|
||||||
- "traefik.http.routers.https-nopaque.entrypoints=https"
|
- "traefik.http.routers.https-nopaque.entrypoints=https"
|
||||||
- "traefik.http.routers.https-nopaque.middlewares=hsts-header@file"
|
- "traefik.http.routers.https-nopaque.middlewares=hsts-header@file"
|
||||||
# Replace <nopaque-domain> with your domain
|
# Replace <nopaque-domain> with your domain
|
||||||
- "traefik.http.routers.https-nopaque.rule=Host(`<nopaque-domain>`)"
|
- "traefik.http.routers.https-nopaque.rule=Host(`<nopaque-domain>`)"
|
||||||
- "traefik.http.routers.https-nopaque.tls.certresolver=<CERTRESOLVER>"
|
- "traefik.http.routers.https-nopaque.tls.certresolver=<CERTRESOLVER>"
|
||||||
- "traefik.http.routers.https-nopaque.tls.options=intermediate@file"
|
- "traefik.http.routers.https-nopaque.tls.options=intermediate@file"
|
||||||
### </https> ###
|
|
||||||
networks:
|
networks:
|
||||||
- default
|
- "nopaque"
|
||||||
- traefik
|
- "traefik"
|
||||||
|
@ -7,25 +7,48 @@ CHECK_MARK="\xE2\x9C\x93"
|
|||||||
CROSS_MARK="\xE2\x9D\x8C"
|
CROSS_MARK="\xE2\x9D\x8C"
|
||||||
|
|
||||||
|
|
||||||
if [[ "${NOPAQUE_UID}" == "0" ]]; then
|
# Check if necessary environment variables are set
|
||||||
|
if [[ -z "${HOST_DOCKER_GID}" ]]; then
|
||||||
|
echo "Environment variable \"HOST_DOCKER_GID\" not set."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ -z "${HOST_UID}" ]]; then
|
||||||
|
echo "Environment variable \"HOST_UID\" not set."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ -z "${HOST_GID}" ]]; then
|
||||||
|
echo "Environment variable \"HOST_GID\" not set."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
# Check if the UID or GID are set to "0" (root). We want an unprivileged user.
|
||||||
|
if [[ "${HOST_UID}" == "0" ]]; then
|
||||||
echo -e "${RED_COLOR}${CROSS_MARK}${NO_COLOR}"
|
echo -e "${RED_COLOR}${CROSS_MARK}${NO_COLOR}"
|
||||||
echo "Running as root is not allowed"
|
echo "\"0\" is not allowed for HOST_UID"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ "${HOST_GID}" == "0" ]]; then
|
||||||
|
echo -e "${RED_COLOR}${CROSS_MARK}${NO_COLOR}"
|
||||||
|
echo "\"0\" is not allowed for HOST_GID"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
echo "Set container UID and GIDs to match the host system..."
|
echo "Set container UID and GIDs to match the host system..."
|
||||||
|
|
||||||
|
|
||||||
##############################################################################
|
##############################################################################
|
||||||
# docker GID #
|
# Update docker GID #
|
||||||
##############################################################################
|
##############################################################################
|
||||||
if [[ "${DOCKER_GID}" == "$(getent group docker | cut -d: -f3)" ]]; then
|
DOCKER_GID=$(getent group docker | cut -d: -f3)
|
||||||
|
if [[ "${DOCKER_GID}" == "${HOST_DOCKER_GID}" ]]; then
|
||||||
echo -n "- docker GID is already matching..."
|
echo -n "- docker GID is already matching..."
|
||||||
echo -e "${GREEN_COLOR}${CHECK_MARK}${NO_COLOR}"
|
echo -e "${GREEN_COLOR}${CHECK_MARK}${NO_COLOR}"
|
||||||
else
|
else
|
||||||
echo -n "- Updating docker GID ($(getent group docker | cut -d: -f3) -> ${DOCKER_GID})... "
|
echo -n "- Updating docker GID (${DOCKER_GID} -> ${HOST_DOCKER_GID})... "
|
||||||
groupmod --gid "${DOCKER_GID}" docker > /dev/null
|
groupmod --gid "${HOST_DOCKER_GID}" docker > /dev/null
|
||||||
if [[ "${?}" == "0" ]]; then
|
if [[ "${?}" == "0" ]]; then
|
||||||
echo -e "${GREEN_COLOR}${CHECK_MARK}${NO_COLOR}"
|
echo -e "${GREEN_COLOR}${CHECK_MARK}${NO_COLOR}"
|
||||||
else
|
else
|
||||||
@ -36,16 +59,16 @@ fi
|
|||||||
|
|
||||||
|
|
||||||
##############################################################################
|
##############################################################################
|
||||||
# nopaque GID #
|
# Update nopaque GID #
|
||||||
##############################################################################
|
##############################################################################
|
||||||
if [[ "${NOPAQUE_GID}" == "$(id -g nopaque)" ]]; then
|
NOPAQUE_GID=$(id -g nopaque)
|
||||||
|
if [[ "${NOPAQUE_GID}" == "${HOST_GID}" ]]; then
|
||||||
echo -n "- nopaque GID is already matching..."
|
echo -n "- nopaque GID is already matching..."
|
||||||
echo -e "${GREEN_COLOR}${CHECK_MARK}${NO_COLOR}"
|
echo -e "${GREEN_COLOR}${CHECK_MARK}${NO_COLOR}"
|
||||||
else
|
else
|
||||||
echo -n "- Updating nopaque GID ($(id -g nopaque) -> ${NOPAQUE_GID})... "
|
echo -n "- Updating nopaque GID (${NOPAQUE_GID} -> ${HOST_GID})... "
|
||||||
groupmod --gid "${NOPAQUE_GID}" nopaque > /dev/null
|
groupmod --gid "${HOST_GID}" nopaque > /dev/null
|
||||||
if [[ "${?}" == "0" ]]; then
|
if [[ "${?}" == "0" ]]; then
|
||||||
HAS_NOPAQUE_GID_CHANGED=true
|
|
||||||
echo -e "${GREEN_COLOR}${CHECK_MARK}${NO_COLOR}"
|
echo -e "${GREEN_COLOR}${CHECK_MARK}${NO_COLOR}"
|
||||||
else
|
else
|
||||||
echo -e "${RED_COLOR}${CROSS_MARK}${NO_COLOR}"
|
echo -e "${RED_COLOR}${CROSS_MARK}${NO_COLOR}"
|
||||||
@ -64,14 +87,15 @@ fi
|
|||||||
|
|
||||||
|
|
||||||
##############################################################################
|
##############################################################################
|
||||||
# nopaque UID #
|
# Update nopaque UID #
|
||||||
##############################################################################
|
##############################################################################
|
||||||
if [[ "${NOPAQUE_UID}" == "$(id -u nopaque)" ]]; then
|
NOPAQUE_UID=$(id -u nopaque)
|
||||||
|
if [[ "${NOPAQUE_UID}" == "${HOST_UID}" ]]; then
|
||||||
echo -n "- nopaque UID is already matching..."
|
echo -n "- nopaque UID is already matching..."
|
||||||
echo -e "${GREEN_COLOR}${CHECK_MARK}${NO_COLOR}"
|
echo -e "${GREEN_COLOR}${CHECK_MARK}${NO_COLOR}"
|
||||||
else
|
else
|
||||||
echo -n "- Updating nopaque UID ($(id -u nopaque) -> ${NOPAQUE_UID})... "
|
echo -n "- Updating nopaque UID (${NOPAQUE_UID} -> ${HOST_UID})... "
|
||||||
usermod --uid "${NOPAQUE_UID}" nopaque > /dev/null
|
usermod --uid "${HOST_UID}" nopaque > /dev/null
|
||||||
if [[ "${?}" == "0" ]]; then
|
if [[ "${?}" == "0" ]]; then
|
||||||
echo -e "${GREEN_COLOR}${CHECK_MARK}${NO_COLOR}"
|
echo -e "${GREEN_COLOR}${CHECK_MARK}${NO_COLOR}"
|
||||||
else
|
else
|
||||||
|
@ -1,9 +1,5 @@
|
|||||||
##############################################################################
|
##############################################################################
|
||||||
# Environment variables to configure the nopaque. #
|
# Environment variables used by nopaque. #
|
||||||
# - When running nopaque with Docker Compose, these variables are set in the #
|
|
||||||
# `docker-compose.yml` file. #
|
|
||||||
# - When running nopaque without Docker, these variables are loaded by #
|
|
||||||
# nopaque in the config.py file #
|
|
||||||
##############################################################################
|
##############################################################################
|
||||||
|
|
||||||
|
|
||||||
@ -11,6 +7,9 @@
|
|||||||
# Flask #
|
# Flask #
|
||||||
# https://flask.palletsprojects.com/en/1.1.x/config/ #
|
# https://flask.palletsprojects.com/en/1.1.x/config/ #
|
||||||
##############################################################################
|
##############################################################################
|
||||||
|
# DEFAULT: /
|
||||||
|
# APPLICATION_ROOT=
|
||||||
|
|
||||||
# CHOOSE ONE: http, https
|
# CHOOSE ONE: http, https
|
||||||
# DEFAULT: http
|
# DEFAULT: http
|
||||||
# PREFERRED_URL_SCHEME=
|
# PREFERRED_URL_SCHEME=
|
||||||
@ -114,10 +113,10 @@ NOPAQUE_ADMIN=
|
|||||||
# DEFAULT: /mnt/nopaque
|
# DEFAULT: /mnt/nopaque
|
||||||
# NOTES:
|
# NOTES:
|
||||||
# - This must be a network share and it must be available on all
|
# - This must be a network share and it must be available on all
|
||||||
# Docker Swarm nodes, mounted to the same path with the same
|
# Docker Swarm nodes, mounted to the same path.
|
||||||
# user and group ownership
|
|
||||||
# - When running with Docker Compose, this gets overwritten in the
|
# - When running with Docker Compose, this gets overwritten in the
|
||||||
# `docker-compose.yml` file
|
# `docker-compose.yml` file with the value of the `HOST_NOPAQUE_DATA_PATH`
|
||||||
|
# environment variable from the `.env` file.
|
||||||
# NOPAQUE_DATA_PATH=
|
# NOPAQUE_DATA_PATH=
|
||||||
|
|
||||||
# CHOOSE ONE: False, True
|
# CHOOSE ONE: False, True
|
||||||
@ -142,30 +141,22 @@ NOPAQUE_DOCKER_REGISTRY_PASSWORD=
|
|||||||
# DEFAULT: [%(asctime)s] %(levelname)s in %(pathname)s (function: %(funcName)s, line: %(lineno)d): %(message)s
|
# DEFAULT: [%(asctime)s] %(levelname)s in %(pathname)s (function: %(funcName)s, line: %(lineno)d): %(message)s
|
||||||
# NOPAQUE_LOG_FORMAT=
|
# NOPAQUE_LOG_FORMAT=
|
||||||
|
|
||||||
# DEFAULT: INFO
|
|
||||||
# CHOOSE ONE: CRITICAL, ERROR, WARNING, INFO, DEBUG
|
|
||||||
# NOPAQUE_LOG_LEVEL=
|
|
||||||
|
|
||||||
# CHOOSE ONE: False, True
|
# CHOOSE ONE: False, True
|
||||||
# DEFAULT: True
|
# DEFAULT: False
|
||||||
# NOPAQUE_LOG_FILE_ENABLED=
|
# NOPAQUE_LOG_FILE_ENABLED=
|
||||||
|
|
||||||
# DEFAULT: <nopaque-basedir>/logs
|
# DEFAULT: /var/log/nopaque
|
||||||
# NOTES:
|
# NOPAQUE_LOG_FILE_DIR=
|
||||||
# - Use `.` as <nopaque-basedir>
|
|
||||||
# - When running with Docker Compose, this gets overwritten in the
|
|
||||||
# `docker-compose.yml` file
|
|
||||||
# NOPAQUE_LOGS_PATH=
|
|
||||||
|
|
||||||
# DEFAULT: NOPAQUE_LOG_LEVEL
|
# DEFAULT: DEBUG if FLASK_DEBUG == True else WARNING
|
||||||
# CHOOSE ONE: CRITICAL, ERROR, WARNING, INFO, DEBUG
|
# CHOOSE ONE: CRITICAL, ERROR, WARNING, INFO, DEBUG
|
||||||
# NOPAQUE_LOG_FILE_LEVEL=
|
# NOPAQUE_LOG_FILE_LEVEL=
|
||||||
|
|
||||||
# CHOOSE ONE: False, True
|
# CHOOSE ONE: False, True
|
||||||
# DEFAULT: False
|
# DEFAULT: True
|
||||||
# NOPAQUE_LOG_STDERR_ENABLED=
|
# NOPAQUE_LOG_STDERR_ENABLED=
|
||||||
|
|
||||||
# DEFAULT: NOPAQUE_LOG_LEVEL
|
# DEFAULT: DEBUG if FLASK_DEBUG == True else WARNING
|
||||||
# CHOOSE ONE: CRITICAL, ERROR, WARNING, INFO, DEBUG
|
# CHOOSE ONE: CRITICAL, ERROR, WARNING, INFO, DEBUG
|
||||||
# NOPAQUE_LOG_STDERR_LEVEL=
|
# NOPAQUE_LOG_STDERR_LEVEL=
|
||||||
|
|
||||||
|
23
wsgi.py
23
wsgi.py
@ -8,20 +8,6 @@ from flask import Flask # noqa
|
|||||||
from typing import Any, Dict # noqa
|
from typing import Any, Dict # noqa
|
||||||
from app import create_app, db, scheduler, socketio # noqa
|
from app import create_app, db, scheduler, socketio # noqa
|
||||||
from app import models # noqa
|
from app import models # noqa
|
||||||
# from app.models import (
|
|
||||||
# Avatar,
|
|
||||||
# Corpus,
|
|
||||||
# CorpusFile,
|
|
||||||
# CorpusFollowerAssociation,
|
|
||||||
# CorpusFollowerRole,
|
|
||||||
# Job,
|
|
||||||
# JobInput,
|
|
||||||
# JobResult,
|
|
||||||
# Role,
|
|
||||||
# TesseractOCRPipelineModel,
|
|
||||||
# SpaCyNLPPipelineModel,
|
|
||||||
# User
|
|
||||||
# ) # noqa
|
|
||||||
|
|
||||||
|
|
||||||
app: Flask = create_app()
|
app: Flask = create_app()
|
||||||
@ -48,12 +34,9 @@ def make_shell_context() -> Dict[str, Any]:
|
|||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
with app.app_context():
|
if app.config['NOPAQUE_IS_PRIMARY_INSTANCE']:
|
||||||
if app.config['NOPAQUE_IS_PRIMARY_INSTANCE']:
|
with app.app_context():
|
||||||
for corpus in models.Corpus.query.filter(models.Corpus.num_analysis_sessions > 0).all():
|
scheduler.start()
|
||||||
corpus.num_analysis_sessions = 0
|
|
||||||
db.session.commit()
|
|
||||||
scheduler.start()
|
|
||||||
socketio.run(app, host='0.0.0.0')
|
socketio.run(app, host='0.0.0.0')
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user