docker done

This commit is contained in:
Wolfgang Steuer
2019-11-20 14:58:46 +01:00
parent 0c0f02b32b
commit 2278a7a229
15 changed files with 545 additions and 5 deletions
+4
View File
@@ -0,0 +1,4 @@
vendor/
docker/mariadb-data
docker/redis-data
docker/manticore-data
+43
View File
@@ -0,0 +1,43 @@
FROM ubuntu:18.04
ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get -q update && \
apt-get -q upgrade && \
apt-get install -qy screen time sudo unzip software-properties-common nano git make automake build-essential pkg-config libevent-dev libncurses5-dev fonts-powerline powerline mariadb-client libmysqlclient-dev unrar p7zip-full mediainfo lame ffmpeg && \
add-apt-repository ppa:ondrej/php && \
apt-get -q update && \
apt-get install -qy apache2 libapache2-mod-php7.3 php-pear php7.3 php7.3-cli php7.3-dev php7.3-common php7.3-curl php7.3-json php7.3-gd php7.3-mysql php7.3-mbstring php7.3-xml php7.3-intl php7.3-fpm php7.3-bcmath php7.3-zip php-imagick
RUN git clone https://github.com/tmux/tmux.git && \
cd tmux && \
git fetch --all --tags --prune && \
git checkout 2.9 && \
sh autogen.sh && \
./configure && make && \
make install && \
cd .. && \
rm -rf tmux
ENV HASH a5c698ffe4b8e849a443b120cd5ba38043260d5c4023dbf93e1558871f1f07f58274fc6f4c93bcfd858c6bd0775cd8d1
RUN cd ~ && curl -sS https://getcomposer.org/installer -o composer-setup.php && php -r "if (hash_file('SHA384', 'composer-setup.php') === '$HASH') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;" && \
php composer-setup.php --install-dir=/usr/local/bin --filename=composer && composer global require hirak/prestissimo
COPY docker/php.ini /etc/php/7.3/apache2/conf.d/99-nn-tmux.ini
COPY docker/php.ini /etc/php/7.3/cli/conf.d/99-nn-tmux.ini
COPY docker/NNTmux.conf /etc/apache2/sites-available/NNTmux.conf
RUN ln -sf /dev/stdout /var/log/apache2/access.log
RUN ln -sf /dev/stdout /var/log/apache2/other_vhosts_access.log
RUN ln -sf /dev/stderr /var/log/apache2/error.log
RUN a2dissite 000-default && a2ensite NNTmux && a2enmod rewrite && service apache2 restart
RUN chown -R www-data:www-data /var/www
RUN useradd -ms /bin/bash notroot && usermod -aG www-data notroot && usermod -aG notroot www-data
USER www-data
RUN mkdir /var/www/NNTmux/ && chmod 775 /var/www/NNTmux/
WORKDIR /var/www/NNTmux
COPY composer.json composer.lock /var/www/NNTmux/
RUN composer install --prefer-dist --no-scripts --no-dev --no-autoloader
COPY . ./
RUN composer dump-autoload
USER root
COPY docker/install.sh /tmp/install.sh
EXPOSE 80
+29
View File
@@ -68,6 +68,35 @@ Use [mysqltuner.pl](http://mysqltuner.pl "MySQL tuner - Use it!") for recommenda
https://github.com/NNTmux/newznab-tmux/wiki/Installing-Composer
## Docker
Copy .env.example -> .env, configure .env, mandatory fields:
- DB_*
- SPHINX_HOST=manticore
- SPHINX_PORT=9306
- NNTP_*
- ADMIN_*
- APP_TZ
- APP_KEY=base64:wbvPP9pBOwifnwu84BeKAVzmwM4TLvcVFowLcPAi6nA= # or generate one!!!
- REDIS_HOST=redis
- REDIS_PASSWORD=null
- REDIS_PORT=6379
´´´bash
docker-compose run --rm nn-tmux sh /tmp/install.sh
# answer the questions, since this will fetch predb entries this takes an hour or two, just press ctrl + c if you dont like it ;)
docker-compose run --rm --service-ports -T nn-tmux apachectl -D FOREGROUND
```
Open http://localhost:8089
sign in as admin (username, password from .env) and configure side settings and tmux settings
´´´bash
ctrl + c
docker-compose up nn-tmux
# check the logs, if everything is working fine ctrl + c
# start and run in background
docker-compose up nn-tmux -d
```
### Support
Support is given on irc.synirc.net #tmux channel.
+3 -3
View File
@@ -89,8 +89,8 @@ return [
'sphinx' => [
'driver' => 'mysql',
'host' => '127.0.0.1',
'port' => 9306,
'host' => env('SPHINX_HOST', '127.0.0.1'),
'port' => env('SPHINX_PORT', 9306),
'database' => '',
'unix_socket' => '',
'charset' => 'utf8',
@@ -144,4 +144,4 @@ return [
],
],
];
];
+2 -2
View File
@@ -1,8 +1,8 @@
<?php
return [
'host' => '127.0.0.1',
'port' => 9306,
'host' => env('SPHINX_HOST', '127.0.0.1'),
'port' => env('SPHINX_PORT', 9306),
'indexes' => [
'releases' => 'releases_rt',
'predb' => 'predb_rt',
+46
View File
@@ -0,0 +1,46 @@
version: '3.4'
services:
redis:
image: redis:5
volumes:
- ./docker/redis-data;/data
- ./docker/redis.conf:/usr/local/etc/redis/redis.conf
manticore:
image: manticoresearch/manticore:3
volumes:
- ./docker/manticore-data;/var/lib/manticore/data
- ./docker/sphinx.conf:/etc/sphinxsearch/sphinx.conf
mariadb:
image: mariadb:10
restart: unless-stopped
volumes:
- ./docker/my.cnf:/etc/mysql/conf.d/newsnab-tmux.cnf
- ./docker/mariadb-data:/var/lib/mysql
- .:/var/www/NNTmux/
ports:
- 53306:3306
environment:
MYSQL_ROOT_PASSWORD: ilmdvV8H
MYSQL_DATABASE: nntmux
MYSQL_USER: nntmux
MYSQL_PASSWORD: Nntmux!
TZ: ${APP_TZ}
nn-tmux:
build:
context: .
restart: unless-stopped
command: bash -c "apachectl -D FOREGROUND & sudo -E -u notroot screen -d -m php artisan tmux-ui:start"
#command: apachectl -D FOREGROUND
volumes:
- /var/www/NNTmux/vendor/
- .:/var/www/NNTmux/
env_file: .env
ports:
- 8089:80
environment:
MYSQL_ROOT_PASSWORD: ilmdvV8H
TZ: ${APP_TZ}
depends_on:
- mariadb
- redis
- manticore
+14
View File
@@ -0,0 +1,14 @@
<VirtualHost *:80>
ServerAdmin webmaster@localhost
ServerName localhost
DocumentRoot "/var/www/NNTmux/public"
LogLevel warn
ServerSignature Off
ErrorLog /var/log/apache2/error.log
<Directory "/var/www/NNTmux/public">
Options FollowSymLinks
AllowOverride All
Require all granted
</Directory>
Alias /covers /var/www/NNTmux/resources/covers
</VirtualHost>
+11
View File
@@ -0,0 +1,11 @@
#!/bin/bash
mysql --host=$DB_HOST --user=root --password=$MYSQL_ROOT_PASSWORD -e "INSTALL SONAME 'ha_sphinx';"
mysql --host=$DB_HOST --user=root --password=$MYSQL_ROOT_PASSWORD -e "GRANT ALL PRIVILEGES ON *.* TO $DB_USERNAME@'%' WITH GRANT OPTION;"
sudo -E -u www-data php artisan nntmux:install
sudo -E -u www-data php /var/www/NNTmux/misc/sphinxsearch/create_se_tables.php $SPHINX_HOST 9312
sudo -E -u www-data php /var/www/NNTmux/misc/sphinxsearch/populate_rt_indexes.php releases_rt
sudo -E -u www-data php /var/www/NNTmux/misc/sphinxsearch/populate_rt_indexes.php predb_rt
read -p "Do you want to batch import predb now (this will take an hour or two)? (y/n)" yn
case $yn in
[Yy]* ) sudo -E -u notroot php /var/www/NNTmux/cli/data/predb_import_daily_batch.php 0 remote false
esac
+2
View File
@@ -0,0 +1,2 @@
*
!.gitignore
+2
View File
@@ -0,0 +1,2 @@
*
!.gitignore
+8
View File
@@ -0,0 +1,8 @@
[mysqld]
# max_allowed_packet = 16M default value
# group_concat_max_len = 8192 default value higher
max_connections = 200 # default 151
# innodb_file_format = BARRACUDA unused and default value
# innodb_large_prefix = 1 default value
# innodb_file_per_table = 1 default value
innodb_buffer_pool_size = 512M # default value 128M
+6
View File
@@ -0,0 +1,6 @@
log_errors = On
error_reporting = E_ALL
max_execution_time = 120
memory_limit = 1024M
date.timezone = Europe/Vienna
error_log = /var/log/apache2/error.log
+2
View File
@@ -0,0 +1,2 @@
*
!.gitignore
+2
View File
@@ -0,0 +1,2 @@
maxmemory 128mb
maxmemory-policy allkeys-lru
+371
View File
@@ -0,0 +1,371 @@
# !*: indicates nZEDb Notes
# !*: Do not change the "releases_rt" word.
index releases_rt
{
# !*: Do not change this.
type = rt
# dictionary type, 'crc' or 'keywords'
# crc is faster to index when no substring/wildcards searches are needed
# crc with substrings might be faster to search but is much slower to index
# (because all substrings are pre-extracted as individual keywords)
# keywords is much faster to index with substrings, and index is much (3-10x) smaller
# keywords supports wildcards, crc does not, and never will
# optional, default is 'keywords'
# dict = keywords
# !*: These allow wildcard searches, they take more ram/disk space.
# !*: If you want to turn it off, put min_infix_len, min_prefix_len and enable_star to 0.
#
# !*: min_prefix_len Allows wildcard searches from the start of the word. ie: to search fishing you can
# do fish* ; This mode takes less ram/disk space than min_infix_len. To set it on, put min_infix_len to 0
# and min_prefix_len to 1
#
# !*: min_infix_len Allows wildcard searches from any position in the word, ie: *ish* would match fishing
# This comes at the expense of more ram/disk space.
# NOTE: min_infix_len DOES NOT WORK FOR RT INDEXES ON SOME VERSIONS OF SPHINX, IT WILL DEFAULT TO min_prefix_len
# IF YOUR SPHINX VERSION DOES NOT SUPPORT IT.
#
# !*: DO NOT ENABLE BOTH min_prefix_len AND min_infix_len AT THE SAME TIME.
#
min_prefix_len = 0
min_infix_len = 2
# !*: Path to where the index files will be stored.
# !*: http://sphinxsearch.com/docs/current.html#conf-path
path = /var/lib/manticore/data/releases_rt
# RAM chunk size limit
# RT index will keep at most this much data in RAM, then flush to disk
# !*: http://sphinxsearch.com/docs/current.html#conf-rt-mem-limit
rt_mem_limit = 1024M
# Full-text field declarations.
# !*: Do not change these.
rt_field = name
rt_field = searchname
rt_field = fromname
rt_field = filename
rt_attr_uint = dummy
}
# !*: Do not change the "predb_rt" word.
index predb_rt
{
# !*: Do not change this.
type = rt
# dictionary type, 'crc' or 'keywords'
# crc is faster to index when no substring/wildcards searches are needed
# crc with substrings might be faster to search but is much slower to index
# (because all substrings are pre-extracted as individual keywords)
# keywords is much faster to index with substrings, and index is much (3-10x) smaller
# keywords supports wildcards, crc does not, and never will
# optional, default is 'keywords'
# dict = keywords
# !*: These allow wildcard searches, they take more ram/disk space.
# !*: If you want to turn it off, put min_infix_len, min_prefix_len and enable_star to 0.
#
# !*: min_prefix_len Allows wildcard searches from the start of the word. ie: to search fishing you can
# do fish* ; This mode takes less ram/disk space than min_infix_len. To set it on, put min_infix_len to 0
# and min_prefix_len to 1
#
# !*: min_infix_len Allows wildcard searches from any position in the word, ie: *ish* would match fishing
# This comes at the expense of more ram/disk space.
# NOTE: min_infix_len DOES NOT WORK FOR RT INDEXES ON SOME VERSIONS OF SPHINX, IT WILL DEFAULT TO min_prefix_len
# IF YOUR SPHINX VERSION DOES NOT SUPPORT IT.
#
# !*: DO NOT ENABLE BOTH min_prefix_len AND min_infix_len AT THE SAME TIME.
#
min_prefix_len = 0
min_infix_len = 2
# !*: Path to where the index files will be stored.
# !*: http://sphinxsearch.com/docs/current.html#conf-path
path = /var/lib/manticore/data/predb_rt
# RAM chunk size limit
# RT index will keep at most this much data in RAM, then flush to disk
# !*: http://sphinxsearch.com/docs/current.html#conf-rt-mem-limit
rt_mem_limit = 1024M
# Full-text field declarations.
# !*: Do not change these.
rt_field = title
rt_field = filename
rt_attr_uint = dummy
rt_attr_string = title
rt_attr_string = filename
rt_attr_string = source
}
indexer
{
# Memory limit, in bytes, kiloytes (16384K) or megabytes (256M)
# Default is 32M, max is 2047M, recommended is 256M to 1024M
# !*: http://sphinxsearch.com/docs/current.html#conf-mem-limit
mem_limit = 1024M
# Maximum IO calls per second (for I/O throttling)
# optional, default is 0 (unlimited)
# !*: http://sphinxsearch.com/docs/current.html#conf-max-iops
# max_iops = 0
# Maximum IO call size, bytes (for I/O throttling)
# optional, default is 0 (unlimited)
# !*: http://sphinxsearch.com/docs/current.html#conf-max-iosize
# max_iosize = 0
# Write buffer size, bytes
# several (currently up to 4) buffers will be allocated
# write buffers are allocated in addition to mem_limit
# optional, default is 1M
# !*: http://sphinxsearch.com/docs/current.html#conf-write-buffer
# write_buffer = 1M
# maximum file field adaptive buffer size
# optional, default is 8M, minimum is 1M
# !*: http://sphinxsearch.com/docs/current.html#conf-max-file-field-buffer
# max_file_field_buffer = 8M
# Lemmatizer cache size. Optional, default is 256K.
# !*: http://sphinxsearch.com/docs/current.html#conf-lemmatizer-cache
# lemmatizer_cache = 256K
}
searchd
{
# [hostname:]port[:protocol], or /unix/socket/path to listen on
# known protocols are 'sphinx' (SphinxAPI) and 'mysql41' (SphinxQL)
#
# multi-value, multiple listen points are allowed
# optional, defaults are 9312:sphinx and 9306:mysql41, as below
# listen = 127.0.0.1
# listen = 192.168.0.1:9312
# listen = 9312
# listen = /var/run/searchd.sock
# Setting anything else can cause issues, beware.
# The first listen is for the sphinxse plugin in MySQL to communicate with the sphinx server,
# so we can select from the RT index.
# The second listen is for sphinxql, to insert and delete data from the RT index.
# !*: http://sphinxsearch.com/docs/current.html#conf-listen
listen = 9312
listen = 9306:mysql41
# log file, searchd run info is logged here
# optional, default is 'searchd.log'
# !*: Make sure this folder exists and is writable, if you have issues starting sphinx,
# look at /var/log/upstart/sphinxsearch.log also.
# !*: http://sphinxsearch.com/docs/current.html#conf-log
log = /var/log/manticore/searchd.log
# query log file, all search queries are logged here
# optional, default is empty (do not log queries)
# !*: Not recommended enabling this.
# !*: http://sphinxsearch.com/docs/current.html#conf-query-log
# query_log = /var/log/sphinxsearch/query.log
# query log file format
# optional, known values are plain and sphinxql, default is plain
# !*: http://sphinxsearch.com/docs/current.html#conf-query-log-format
# query_log_format = sphinxql
# client read timeout, seconds
# optional, default is 5
# !*: http://sphinxsearch.com/docs/current.html#conf-read-timeout
read_timeout = 5
# request timeout, seconds
# optional, default is 5 minutes
# !*: http://sphinxsearch.com/docs/current.html#conf-client-timeout
client_timeout = 300
# maximum amount of children to fork (concurrent searches to run)
# optional, default is 0 (unlimited)
# !*: http://sphinxsearch.com/docs/current.html#conf-max-children
# max_children = 0
# PID file, searchd process ID file name
# mandatory
# !*: Sphinx will not start if this folder does not exist.
# !*: http://sphinxsearch.com/docs/current.html#conf-pid-file
pid_file = /var/run/manticore/searchd.pid
# max amount of matches the daemon ever keeps in RAM, per-index
# WARNING, THERE'S ALSO PER-QUERY LIMIT, SEE SetLimits() API CALL
# default is 1000 (just like Google)
# !*: Note, this is deprecated in v2.2.3 of sphinx.
#max_matches = 10000
# seamless rotate, prevents rotate stalls if precaching huge datasets
# optional, default is 1
# !*: http://sphinxsearch.com/docs/current.html#conf-seamless-rotate
seamless_rotate = 1
# whether to forcibly preopen all indexes on startup
# optional, default is 1 (preopen everything)
# !*: http://sphinxsearch.com/docs/current.html#conf-preopen-indexes
preopen_indexes = 1
# whether to unlink .old index copies on succesful rotation.
# optional, default is 1 (do unlink)
# !*: http://sphinxsearch.com/docs/current.html#conf-unlink-old
unlink_old = 1
# attribute updates periodic flush timeout, seconds
# updates will be automatically dumped to disk this frequently
# optional, default is 0 (disable periodic flush)
# !*: http://sphinxsearch.com/docs/current.html#conf-attr-flush-period
# attr_flush_period = 0
# max allowed network packet size
# limits both query packets from clients, and responses from agents
# optional, default size is 8M
# !*: http://sphinxsearch.com/docs/current.html#conf-max-packet-size
max_packet_size = 16M
# MVA updates pool size
# shared between all instances of searchd, disables attr flushes!
# optional, default size is 1M
# mva_updates_pool = 1M
# max allowed per-query filter count
# optional, default is 256
# !*: http://sphinxsearch.com/docs/current.html#conf-max-filters
max_filters = 256
# max allowed per-filter values count
# optional, default is 4096
# !*: http://sphinxsearch.com/docs/current.html#conf-max-filter-values
max_filter_values = 4096
# socket listen queue length
# optional, default is 5
# !*: http://sphinxsearch.com/docs/current.html#conf-listen-backlog
# listen_backlog = 5
# per-keyword read buffer size
# optional, default is 256K
# !*: http://sphinxsearch.com/docs/current.html#conf-read-buffer
# read_buffer = 256K
# unhinted read size (currently used when reading hits)
# optional, default is 32K
# !*: http://sphinxsearch.com/docs/current.html#conf-read-unhinted
# read_unhinted = 32K
# max allowed per-batch query count (aka multi-query count)
# optional, default is 32
# !*: http://sphinxsearch.com/docs/current.html#conf-max-batch-queries
# max_batch_queries = 32
# max common subtree document cache size, per-query
# optional, default is 0 (disable subtree optimization)
# !*: http://sphinxsearch.com/docs/current.html#conf-subtree-docs-cache
# subtree_docs_cache = 4M
# max common subtree hit cache size, per-query
# optional, default is 0 (disable subtree optimization)
# !*: http://sphinxsearch.com/docs/current.html#conf-subtree-hits-cache
# subtree_hits_cache = 8M
# multi-processing mode (MPM)
# known values are none, fork, prefork, and threads
# optional, default is fork
# !*: Do not change this.
# !*: http://sphinxsearch.com/docs/current.html#conf-workers
workers = threads
# max threads to create for searching local parts of a distributed index
# optional, default is 0, which means disable multi-threaded searching
# should work with all MPMs (ie. does NOT require workers=threads)
# !*: http://sphinxsearch.com/docs/current.html#conf-dist-threads
# dist_threads = 4
# binlog files path; use empty string to disable binlog
# optional, default is build-time configured data directory
# binlog_path = # disable logging
# !*: This is recommended, it rebuilds indexes if your server crashes.
# !*: http://sphinxsearch.com/docs/current.html#conf-binlog-path
binlog_path = /var/lib/manticore/data
# binlog flush/sync mode
# 0 means flush and sync every second
# 1 means flush and sync every transaction
# 2 means flush every transaction, sync every second
# optional, default is 2
# !*: You should leave this to 2
# !*: http://sphinxsearch.com/docs/current.html#conf-binlog-flush
binlog_flush = 2
# binlog per-file size limit
# optional, default is 128M, 0 means no limit
# !*: http://sphinxsearch.com/docs/current.html#conf-binlog-max-log-size
binlog_max_log_size = 512M
# default server-wide collation
# optional, default is libc_ci
# !*: http://sphinxsearch.com/docs/current.html#conf-collation-server
# collation_server = utf8_general_ci
# server-wide locale for libc based collations
# optional, default is C
# !*: http://sphinxsearch.com/docs/current.html#conf-collation-libc-locale
# collation_libc_locale = ru_RU.UTF-8
# trusted plugin directory
# optional, default is empty (disable UDFs)
# !*: http://sphinxsearch.com/docs/current.html#conf-plugin-dir
# plugin_dir = /usr/local/sphinx/lib
# version string returned to MySQL network protocol clients
# optional, default is empty (use Sphinx version)
# !*: http://sphinxsearch.com/docs/current.html#conf-mysql-version-string
# mysql_version_string = 5.0.37
# RT RAM chunks flush period
# optional, default is 0 (no periodic flush)
# !*: http://sphinxsearch.com/docs/current.html#conf-rt-flush-period
rt_flush_period = 900
# per-thread stack size, only affects workers=threads mode
# optional, default is 64K
# !*: http://sphinxsearch.com/docs/current.html#conf-thread-stack
# thread_stack = 128K
# per-keyword expansion limit (for dict=keywords prefix searches)
# optional, default is 0 (no limit)
# !*: http://sphinxsearch.com/docs/current.html#conf-expansion-limit
expansion_limit = 1000
# threaded server watchdog (only used in workers=threads mode)
# optional, values are 0 and 1, default is 1 (watchdog on)
# !*: Do not set this to 0.
# !*: http://sphinxsearch.com/docs/current.html#conf-watchdog
# watchdog = 1
# SphinxQL compatibility mode (legacy columns and their names)
# optional, default is 0 (SQL compliant syntax and result sets)
# !*: Deprecated in v2.2.1
# compat_sphinxql_magics = 1
# A maximum number of I/O operations (per second) that the RT chunks merge thread is allowed to start.
# This directive lets you throttle down the I/O impact arising from the OPTIMIZE statements.
# Optional, default is 0 (no limit).
# !*: http://sphinxsearch.com/docs/current.html#conf-rt-merge-iops
# rt_merge_iops = 0
# A maximum size of an I/O operation that the RT chunks merge thread is allowed to start.
# This directive lets you throttle down the I/O impact arising from the OPTIMIZE statements.
# Optional, default is 0 (no limit).
# !*: http://sphinxsearch.com/docs/current.html#conf-rt-merge-maxiosize
# rt_merge_maxiosize = 0
}
# --eof--