Skip to content
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
21 changes: 21 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"version": "0.2.0",
"configurations": [
{
"name": "Python: Remote Attach",
"type": "debugpy",
"request": "attach",
"connect": {
"host": "localhost",
"port": 5678
},
"pathMappings": [
{
"localRoot": "${workspaceFolder}",
"remoteRoot": "/var/www/cts"
}
],
"justMyCode": true
}
]
}
17 changes: 17 additions & 0 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"version": "2.0.0",
"tasks": [
{
"label": "Docker Compose Up",
"type": "shell",
"command": "docker-compose up --build",
"problemMatcher": []
},
{
"label": "Docker Compose Down",
"type": "shell",
"command": "docker-compose down",
"problemMatcher": []
}
]
}
27 changes: 27 additions & 0 deletions coptic/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
**/__pycache__
**/.venv
**/.classpath
**/.dockerignore
**/.env
**/.git
**/.gitignore
**/.project
**/.settings
**/.toolstarget
**/.vs
**/.vscode
**/*.*proj.user
**/*.dbmdl
**/*.jfm
**/bin
**/charts
**/docker-compose*
**/compose*
**/Dockerfile*
**/node_modules
**/npm-debug.log
**/obj
**/secrets.dev.yaml
**/values.dev.yaml
LICENSE
README.md
42 changes: 42 additions & 0 deletions coptic/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# Base image
FROM ubuntu:20.04

# Environment settings
ENV DEBIAN_FRONTEND=noninteractive

# Install key packages
RUN apt-get update && apt-get install -y \
apache2 \
apache2-dev \
chromium-browser \
git \
libapache2-mod-wsgi-py3 \
default-libmysqlclient-dev \
build-essential \
pkg-config \
python3-pip \
redis-server \
redis-tools \
unzip \
xvfb \
&& apt-get clean

# Install Python dependencies
COPY coptic/requirements.txt /var/www/cts/coptic/requirements.txt
RUN pip3 install -r /var/www/cts/coptic/requirements.txt
RUN pip3 install debugpy

# Copy application files
WORKDIR /var/www/cts/coptic
COPY ./coptic /var/www/cts/coptic
RUN mkdir -p /var/www/cts/coptic/scripts
COPY ./scripts/ /var/www/cts/coptic/scripts

# Apache configuration
COPY ./ansible/roles/scriptorium/files/scriptorium.conf /etc/apache2/sites-available/000-default.conf

EXPOSE 80
# Environment variables for Django
ENV DJANGO_SETTINGS_MODULE="coptic.settings.docker"
# Command to start Apache
CMD ["python3", "-m", "debugpy", "--listen", "0.0.0.0:5678", "manage.py", "runserver", "0.0.0.0:8000"]
9 changes: 9 additions & 0 deletions coptic/README_Docker.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Developing with visual studio code

```
export SECRET_KEY="what you want"
export GITHUB_TOKEN="what you need"
docker compose build
docker compose up
code .
```
78 changes: 78 additions & 0 deletions coptic/coptic/settings/docker.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
import os
from pathlib import Path
SECRET_KEY="what you want" # this is local development only

# Build paths inside the project like this: BASE_DIR / 'subdir'.
BASE_DIR = Path(__file__).resolve().parent.parent.parent

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


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

ALLOWED_HOSTS = ['*']

# Application definition
INSTALLED_APPS = (
'grappelli',
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'texts',
#'annis',
#'ingest',
'api',
'mod_wsgi.server'
)

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 = 'coptic.urls'

TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [os.path.join(BASE_DIR, '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 = 'coptic.wsgi.application'

# Database
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql',
'NAME': os.environ.get('MYSQL_DB', 'coptic'),
'USER': os.environ.get('MYSQL_USER', 'coptic'),
'PASSWORD': os.environ.get('MYSQL_PASSWORD', ''),
'HOST': os.environ.get('MYSQL_HOST', 'db'),
'PORT': os.environ.get('MYSQL_PORT', '3306'),
}
}

# Static files (CSS, JavaScript, Images)
STATIC_URL = '/static/'
STATIC_ROOT = "/var/www/cts/coptic/static/"

16 changes: 8 additions & 8 deletions coptic/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
requests
django
django-grappelli
beautifulsoup4
selenium==2.45.0
xvfbwrapper==0.2.4
mod-wsgi==4.4.11
celery==3.1.18
django==2.2.13
mysqlclient
django-grappelli==2.13.1
beautifulsoup4==4.8.0
selenium==3.141.0
xvfbwrapper==0.2.9
mod-wsgi
celery
github3.py==1.3.0
tqdm
9 changes: 0 additions & 9 deletions coptic/requirements_django_2.txt

This file was deleted.

29 changes: 29 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
services:
web:
build:
context: .
dockerfile: coptic/Dockerfile
environment:
- DJANGO_SETTINGS_MODULE=coptic.settings.docker
- MYSQL_HOST=db
- MYSQL_USER=coptic
- MYSQL_PASSWORD=your_mysql_password
- MYSQL_DB=coptic
command: ["python3", "-m", "debugpy", "--listen", "0.0.0.0:5678", "manage.py", "runserver", "0.0.0.0:8000"]
volumes:
- .:/var/www/cts
ports:
- "8000:8000"
- "5678:5678"
depends_on:
- db
db:
image: mariadb:10.2
restart: always
environment:
MYSQL_ROOT_PASSWORD: root_password
MYSQL_DATABASE: coptic
MYSQL_USER: coptic
MYSQL_PASSWORD: your_mysql_password
ports:
- "3306:3306"