Skip to content
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

Deployment with Docker Compose #901

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
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
28 changes: 28 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
FROM debian:bullseye

RUN apt update
RUN apt install -y apache2 git subversion curl cron \
libconfig-ini-perl libdbd-mysql-perl libdbi-perl libxml-parser-perl \
php7.4 php7.4-mysql php7.4-curl php7.4-intl libapache2-mod-php7.4 php7.4-mbstring php7.4-xml

WORKDIR /var/www/html
RUN rm -rf /var/www/html/* && git clone https://github.com/OpenCorpora/opencorpora.git .
RUN curl -sS https://getcomposer.org/installer | php
RUN php composer.phar self-update --1
RUN php composer.phar install

WORKDIR /var/www
RUN mkdir -p smarty_dir/cache && mkdir -p smarty_dir/configs && mkdir -p smarty_dir/templates_c
RUN chown -R www-data:www-data smarty_dir

WORKDIR /var/www/html
RUN sed -E 's/^(host\s+=\s+)127\.0\.0\.1/\1opencorpora_db/' config.default.ini | \
sed -E 's/^(template_dir\s+=\s+)\/var\/www\/templates\//\1\/var\/www\/html\/templates\//' > config.ini
RUN sed -E 's/^(\s+\"host\"\s*:\s*\")127\.0\.0\.1/\1opencorpora_db/' config.default.json | \
sed -E 's/^(\s+\"template_dir\"\s*:\s+\")\/var\/www\/templates\//\1\/var\/www\/html\/templates\//' > config.json
RUN mkdir logs && chown -R www-data:www-data logs

RUN ln -s /var/www/html /corpus

CMD ["apachectl", "-D", "FOREGROUND"]

47 changes: 47 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,50 @@ opencorpora
===========

A web-based engine for creating and annotating textual corpora


How-to run with Docker Compose
==============================

- Modify MySql root password in `docker-compose.yml`

- Execure following commands in the first terminal:
```
docker-compose up --build
```

- Execute following commands in the second terminal:

```
docker-compose exec opencorpora_db /bin/bash

# Inside container:

# Create database in MySql and grant access
mysql -u root -p

# Inside MySql shell:
CREATE DATABASE corpora DEFAULT CHARSET utf8;
CREATE USER corpora@localhost IDENTIFIED BY 'password';
GRANT DELETE, INSERT, LOCK TABLES, SELECT, UPDATE, ALTER, CREATE ON corpora.* TO corpora;
exit;

exit
```

```
docker-compose exec opencorpora_front /bin/bash

# Inside contianer:

# Add password for MySql user 'corpora' into both config.ini and config.json

# Fill the database
zcat database-dev.sql.gz | mysql -Dcorpora -uroot -p

# Add cron tasks
crontab scripts/conf/crontab.list

exit
```

24 changes: 24 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
version: "3.9"
services:

opencorpora_front:
build: .
container_name: opencorpora_front
restart: always
ports:
- 80:80

opencorpora_db:
image: mysql:latest
container_name: opencorpora_db
restart: always
cap_add:
- SYS_NICE # CAP_SYS_NICE
environment:
MYSQL_ROOT_PASSWORD: 'test_pass' # TODO: Change this
volumes:
- ocsqldata:/var/lib/mysql

volumes:
ocsqldata:

30 changes: 15 additions & 15 deletions scripts/conf/crontab.list
Original file line number Diff line number Diff line change
@@ -1,33 +1,33 @@
# m h dom mon dow command
# less than once a day
0 6 1 * * php /corpus/scripts/check_dog_achievement.php >> /home/madfriend/error.log 2&>1
0 6 1 * * php /corpus/scripts/check_dog_achievement.php >> /corpus/logs/madfriend_error.log 2&>1
30 3 * * 1 /corpus/export/database/backup.sh 2>>/corpus/logs/db-backup.stderr.log

# once a day
# date to logs
0 0 * * * date +\%F >>/home/grand/error.log
0 0 * * * date +\%F >>/corpus/logs/grand_error.log
0 0 * * * date +\%F >>/corpus/logs/consistency.stderr.log
0 0 * * * date +\%F >>/corpus/logs/db-backup.stderr.log

# other
30 2 * * * nice /corpus/scripts/cronrunner.pl "/corpus/scripts/run_validators.sh" 2>>/home/grand/error.log
#0 3 * * * nice /corpus/scripts/tokenizer/collect_data.pl /corpus/config.ini --dry-run >/dev/null 2>/home/grand/tokenizer.log
0 4 * * * /corpus/scripts/backup.sh 2>>/home/grand/error.log
30 4 * * * nice /corpus/scripts/cronrunner.pl "/corpus/scripts/export_and_stats.sh" 2>>/home/grand/error.log
30 6 * * * nice /corpus/scripts/cronrunner.pl "/corpus/export/pools/export_pools.sh" 2>>/home/grand/error.log
30 2 * * * nice /corpus/scripts/cronrunner.pl "/corpus/scripts/run_validators.sh" 2>>/corpus/logs/grand_error.log
#0 3 * * * nice /corpus/scripts/tokenizer/collect_data.pl /corpus/config.ini --dry-run >/dev/null 2>/corpus/logs/grand_tokenizer.log
0 4 * * * /corpus/scripts/backup.sh 2>>/corpus/logs/grand_error.log
30 4 * * * nice /corpus/scripts/cronrunner.pl "/corpus/scripts/export_and_stats.sh" 2>>/corpus/logs/grand_error.log
30 6 * * * nice /corpus/scripts/cronrunner.pl "/corpus/export/pools/export_pools.sh" 2>>/corpus/logs/grand_error.log
0 7 * * * /corpus/scripts/invalidate_auth_tokens.pl /corpus/config.ini
5 7 * * * nice /corpus/scripts/cronrunner.pl "/corpus/scripts/ma_pools/populate_pools.pl /corpus/config.ini" 2>>/home/grand/error.log
20 7 * * * php /corpus/scripts/ma_pools/autopublish.php 2>>/home/grand/error.log
5 7 * * * nice /corpus/scripts/cronrunner.pl "/corpus/scripts/ma_pools/populate_pools.pl /corpus/config.ini" 2>>/corpus/logs/grand_error.log
20 7 * * * php /corpus/scripts/ma_pools/autopublish.php 2>>/corpus/logs/grand_error.log
45 7 * * * nice /corpus/scripts/cronrunner.pl "/corpus/scripts/train_tokenizer.sh" >/dev/null 2>/dev/null

# several times a day
2,22,42 * * * * /corpus/scripts/cronrunner.pl "/corpus/scripts/update_user_rating.py /corpus/config.json" 2>>/home/grand/error.log
20 * * * * /corpus/scripts/cronrunner.pl "/corpus/scripts/ma_pools/unpublish_pools.py /corpus/config.json" 2>>/home/grand/error.log
15 * * * * /corpus/scripts/cronrunner.pl "/corpus/scripts/tokenizer/check_sentence_split.pl /corpus/config.ini" 2>>/home/grand/error.log
0,30 0-3,7-23 * * * nice /corpus/scripts/cronrunner.pl "/corpus/scripts/stats/update_annot_stats.pl /corpus/config.ini" 2>>/home/grand/error.log
* * * * * nice /corpus/scripts/cronrunner.pl "/corpus/scripts/dict_check.pl /corpus/config.ini" 2>>/home/grand/error.log
2,22,42 * * * * /corpus/scripts/cronrunner.pl "/corpus/scripts/update_user_rating.py /corpus/config.json" 2>>/corpus/logs/grand_error.log
20 * * * * /corpus/scripts/cronrunner.pl "/corpus/scripts/ma_pools/unpublish_pools.py /corpus/config.json" 2>>/corpus/logs/grand_error.log
15 * * * * /corpus/scripts/cronrunner.pl "/corpus/scripts/tokenizer/check_sentence_split.pl /corpus/config.ini" 2>>/corpus/logs/grand_error.log
0,30 0-3,7-23 * * * nice /corpus/scripts/cronrunner.pl "/corpus/scripts/stats/update_annot_stats.pl /corpus/config.ini" 2>>/corpus/logs/grand_error.log
* * * * * nice /corpus/scripts/cronrunner.pl "/corpus/scripts/dict_check.pl /corpus/config.ini" 2>>/corpus/logs/grand_error.log
* * * * * /corpus/scripts/cronrunner.pl "/corpus/scripts/consistency/form2lemma.pl /corpus/config.ini" 2>>/corpus/logs/consistency.stderr.log
* * * * * /corpus/scripts/cronrunner.pl "/corpus/scripts/consistency/form2tf.pl /corpus/config.ini" 2>>/corpus/logs/consistency.stderr.log
* * * * * /corpus/scripts/cronrunner.pl "/corpus/scripts/consistency/dict_update_forms.pl /corpus/config.ini" 2>>/corpus/logs/consistency.stderr.log
* * * * * /corpus/scripts/cronrunner.pl "/corpus/scripts/ma_pools/merge_pools_data.py /corpus/config.json" 2>>/home/grand/error.log
* * * * * /corpus/scripts/cronrunner.pl "/corpus/scripts/ma_pools/merge_pools_data.py /corpus/config.json" 2>>/corpus/logs/grand_error.log
# empty line must be here