Добавлен профиль taiga для настройки Taiga.io в контейнере

akrasnyh 49
parent 8c1fdc8bb2
commit 65dc16c678

@ -8,7 +8,8 @@
# AMD64 Profiles
amd64 CCS/amd64/20 stable
amd64 CDC/amd64/20 stable
amd64 CDC/amd64/20 dev
amd64 CCG/amd64/20 stable
amd64 taiga/amd64/20 dev
# vim: set ts=8

@ -0,0 +1,2 @@
calculate:default/amd64/20/server
../..

@ -0,0 +1,2 @@
../../../../calculate/profiles/default/amd64/18/server
..

@ -0,0 +1,3 @@
[main]
os_linux_name = 'Calculate Taiga'
os_linux_shortname = 'taiga'

@ -0,0 +1,10 @@
# Calculate name=world format=world
#?in(os_linux_pkglist, taiga)!=#
dev-db/postgresql:12
dev-python/nodeenv
dev-python/setuptools
net-misc/rabbitmq-server
sys-devel/gettext
www-servers/nginx
#in#

@ -1,10 +1,10 @@
# Calculate name=world format=world
#?in(os_linux_pkglist, CCDX, CDC, CCG, CCS)!=#
#?in(os_linux_pkglist, CCDX, CDC, CCG, CCS, taiga)!=#
app-text/tree
#in#
#?in(os_linux_pkglist, CCDX, CDC, CCG)!=#
#?in(os_linux_pkglist, CCDX, CDC, CCG, taiga)!=#
app-admin/logrotate
app-admin/syslog-ng
app-arch/lbzip2

@ -0,0 +1 @@
# Calculate os_linux_shortname==taiga cl_name==calculate-core append=skip

@ -0,0 +1 @@
# Calculate env=install ac_install_merge==on mergepkg(www-servers/nginx)!= append=skip

@ -0,0 +1,85 @@
# Calculate path=/etc/nginx/sites-enabled comment=#
server {
listen 80 default_server;
server_name taiga.example.org;
large_client_header_buffers 4 32k;
client_max_body_size 50M;
charset utf-8;
access_log /var/log/nginx/taiga-access.log;
error_log /var/log/nginx/taiga-error.log;
# TLS: Configure your TLS following the best practices inside your company
# Other configurations
# Frontend
location / {
alias /var/calculate/www/taiga/taiga-front-dist/dist/;
index index.html;
try_files $uri $uri/ index.html =404;
}
# API
location /api/ {
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Scheme $scheme;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass http://127.0.0.1:8001/api/;
proxy_redirect off;
}
# Admin
location /admin/ {
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Scheme $scheme;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass http://127.0.0.1:8001/admin/;
proxy_redirect off;
}
# Static files
location /static/ {
alias /var/calculate/www/taiga/taiga-back/static/;
}
# Media
location /_protected/ {
internal;
alias /var/calculate/www/taiga/taiga-back/media/;
add_header Content-disposition "attachment";
}
# Unprotected section
location /media/exports/ {
alias /var/calculate/www/taiga/taiga-back/media/exports/;
add_header Content-disposition "attachment";
}
location /media/ {
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Scheme $scheme;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass http://127.0.0.1:8003/;
proxy_redirect off;
}
# Events
location /events {
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_connect_timeout 7d;
proxy_send_timeout 7d;
proxy_read_timeout 7d;
proxy_pass http://127.0.0.1:8888/events;
}
}

@ -0,0 +1 @@
# Calculate env=install ac_install_merge==on mergepkg(dev-db/postgresql)!= append=skip

@ -0,0 +1 @@
# Calculate path=/var/calculate name=postgresql chmod=700 chown=postgres:postgres

@ -0,0 +1 @@
# Calculate path=/etc name=postgresql-#-cut(1)-#

@ -0,0 +1,10 @@
# Calculate chmod=600 comment=# chown=postgres:postgres
# TYPE DATABASE USER ADDRESS METHOD
# "local" is for Unix domain socket connections only
local all all trust
# IPv4 local connections:
host all all 127.0.0.1/32 trust
# IPv6 local connections:
host all all ::1/128 trust

@ -0,0 +1 @@
# Calculate chmod=600 comment=# chown=postgres:postgres

@ -0,0 +1,18 @@
# Calculate chmod=600 comment=# chown=postgres:postgres
max_connections = 100 # (change requires restart)
shared_buffers = 128MB # min 128kB
dynamic_shared_memory_type = posix # the default is the first option
max_wal_size = 1GB
min_wal_size = 80MB
log_timezone = 'W-SU'
datestyle = 'iso, dmy'
timezone = 'W-SU'
lc_messages = 'ru_RU.UTF-8' # locale for system error message
lc_monetary = 'ru_RU.UTF-8' # locale for monetary formatting
lc_numeric = 'C' # locale for number formatting
lc_time = 'ru_RU.UTF-8' # locale for time formatting
default_text_search_config = 'pg_catalog.russian'
plperl.on_init = 'use utf8; use re; package utf8; require "utf8_heavy.pl";'
listen_addresses = '127.0.0.1'

@ -0,0 +1 @@
# Calculate path=/var/lib name=postgresql link=/var/calculate/postgresql symbolic protected

@ -0,0 +1 @@
# Calculate env=install ac_install_merge==on mergepkg(net-misc/rabbitmq-server)!= append=skip

@ -0,0 +1 @@
# Calculate path=/var/calculate name=rabbitmq chmod=750 chown=rabbitmq:rabbitmq

@ -0,0 +1 @@
# Calculate path=/var/lib name=rabbitmq link=/var/calculate/rabbitmq symbolic protected

@ -0,0 +1 @@
# Calculate env=install ac_install_merge==on mergepkg(www-servers/nginx)!= append=skip

@ -0,0 +1,2 @@
# Calculate append=after path=/etc name=#-cut(2,.)-# grep(/etc/#-cut(2,.)-#,#-cut(1,.)-#)== protected
taiga:x:1000:

@ -0,0 +1,2 @@
# Calculate append=after path=/etc name=#-cut(2,.)-# grep(/etc/#-cut(2,.)-#,#-cut(1,.)-#)== protected
taiga:x:1000:1000::/var/calculate/www/taiga:/bin/bash

@ -0,0 +1,2 @@
# Calculate append=after path=/etc name=#-cut(2,.)-# grep(/etc/#-cut(2,.)-#,#-cut(1,.)-#)== protected
taiga:!:19297:0:99999:7:::

@ -0,0 +1,3 @@
# Calculate format=openrc path=/etc/conf.d name=#-cut(1,.)-#
export PYTHONUNBUFFERED=true
export DJANGO_SETTINGS_MODULE=settings.config

@ -0,0 +1,3 @@
# Calculate format=openrc path=/etc/conf.d name=#-cut(1,.)-#
export PYTHONUNBUFFERED=true
export DJANGO_SETTINGS_MODULE=settings.config

@ -0,0 +1,2 @@
# Calculate format=openrc path=/etc/conf.d name=#-cut(1,.)-#
export PYTHONUNBUFFERED=true

@ -0,0 +1,15 @@
# Calculate path=/var/calculate/config name=#-cut(1,.)-# chmod=600 chown=taiga:taiga comment=# grep(/var/calculate/config/#-cut(1,.)-#,PROTOCOL)== protected
PROTOCOL='http'
TAIGA_SITES_DOMAIN='taiga.example.org'
FROM_EMAIL='taiga@example.org'
SMTP_HOST='smtp@example.org'
SMTP_PORT=25
SMTP_TLS='False'
SMTP_SSL='False'
SMTP_USER=
SMTP_PASSWORD=
NODE='12.22.12'
SECRET_KEY='#-rnd(pas,16)-#'
PGSQL_PASSWORD='#-rnd(pas,16)-#'
RABBITMQ_USER='taiga'
RABBITMQ_PASSWORD='#-rnd(pas,16)-#'

@ -0,0 +1,26 @@
# Calculate path=/etc/init.d name=#-cut(1,.)-# chmod=755 comment=#
#!/sbin/openrc-run
# Copyright 2022 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2
name="Taiga daemon"
description=""
pidfile=/run/taiga-back.pid
command_user=taiga
output_log=/var/log/taiga-back.log
error_log=/var/log/taiga-back.log
directory=/var/calculate/www/taiga/taiga-back
start_stop_daemon_args=""
command="/var/calculate/www/taiga/taiga-back/.venv/bin/gunicorn"
command_args="--workers 4 --timeout 60 --log-level=info --access-logfile - --bind 0.0.0.0:8001 taiga.wsgi"
source /var/calculate/www/taiga/taiga-back/.venv/bin/activate
command_background=true
depend() {
need nginx postgresql
need taiga-async taiga-events taiga-protected
}
start_pre() {
checkpath -f -o taiga -m 0600 /var/log/taiga-back.log
}

@ -0,0 +1,25 @@
# Calculate path=/etc/init.d name=#-cut(1,.)-# chmod=755 comment=#
#!/sbin/openrc-run
# Copyright 2022 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2
name="Taiga-async-tasks daemon"
description="Async tasks, like bulk email or exports generation"
pidfile=/run/taiga-async.pid
command_user=taiga
output_log=/var/log/taiga-async.log
error_log=/var/log/taiga-async.log
directory=/var/calculate/www/taiga/taiga-back
start_stop_daemon_args=""
command="/var/calculate/www/taiga/taiga-back/.venv/bin/celery"
command_args="-A taiga.celery worker -B --concurrency 4 -l INFO"
source /var/calculate/www/taiga/taiga-back/.venv/bin/activate
command_background=true
depend() {
need rabbitmq
}
start_pre() {
checkpath -f -o taiga -m 0600 /var/log/taiga-async.log
}

@ -0,0 +1,22 @@
# Calculate path=/etc/init.d name=#-cut(1,.)-# chmod=755 comment=#
#!/sbin/openrc-run
# Copyright 2022 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2
name="Taiga-events daemon"
description="Websockets gateway"
pidfile=/run/taiga-events.pid
command_user=taiga
output_log=/var/log/taiga-events.log
error_log=/var/log/taiga-events.log
directory=/var/calculate/www/taiga/taiga-events
start_stop_daemon_args=""
command="npm"
command_args="run start:production"
source /var/calculate/www/taiga/.node-live/bin/activate
command_background=true
start_pre() {
checkpath -f -o taiga -m 0600 /var/log/taiga-events.log
}

@ -0,0 +1,21 @@
# Calculate path=/etc/init.d name=#-cut(1,.)-# chmod=755 comment=#
#!/sbin/openrc-run
# Copyright 2022 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2
name="Taiga-protected daemon"
description="Protected attachments"
pidfile=/run/taiga-protected.pid
command_user=taiga
output_log=/var/log/taiga-protected.log
error_log=/var/log/taiga-protected.log
directory=/var/calculate/www/taiga/taiga-protected
start_stop_daemon_args=""
command="/var/calculate/www/taiga/taiga-protected/.venv/bin/gunicorn"
command_args="--workers 4 --timeout 60 --log-level=info --access-logfile - --bind 0.0.0.0:8003 server:app"
source /var/calculate/www/taiga/taiga-protected/.venv/bin/activate
command_background=true
start_pre() {
checkpath -f -o taiga -m 0600 /var/log/taiga-protected.log
}

@ -0,0 +1 @@
# Calculate path=/etc/runlevels/default name=#-cut(1,.)-# link=/etc/init.d/#-cut(1,.)-# protected symbolic

@ -0,0 +1,123 @@
# Calculate path=/var/calculate/bin name=#-cut(1,.)-# chmod=755 comment=#
#!/bin/bash
set -eo pipefail
export PATH="/lib/rc/bin:$PATH"
if [[ $UID == 0 ]]
then
exec su - taiga -c /var/calculate/bin/install-taiga
fi
source /var/calculate/config/taiga
if [[ ! -e ~/.node-live ]]
then
einfo Установка Node.js
cd ~
nodeenv --node=$NODE .node-${NODE%%.*}
ln -sfT .node-${NODE%%.*} .node-live
fi
source ~/.node-live/bin/activate
set -u
install_taiga_back(){
cd ~
einfo 'Получение кода taiga_back'
git clone https://github.com/kaleidos-ventures/taiga-back.git taiga-back
cd taiga-back
git checkout stable
einfo 'Создание виртуальной среды'
python -m venv .venv --prompt taiga-back
source .venv/bin/activate
pip install --upgrade pip wheel
einfo 'Установка всех зависимостей Python'
pip install -r requirements.txt
einfo 'Установка taiga-contrib-protected'
pip install git+https://github.com/kaleidos-ventures/taiga-contrib-protected.git@stable#egg=taiga-contrib-protected
ebegin 'Копирование фала настроек'
cp settings/config.py.prod.example settings/config.py
eend
}
install_taiga_front_dist(){
cd ~
einfo 'Получeние кода taiga_front_dist'
git clone https://github.com/kaleidos-ventures/taiga-front-dist.git taiga-front-dist
cd taiga-front-dist
git checkout stable
ebegin 'Копирование примера файла конфигурации'
cp ~/taiga-front-dist/dist/conf.example.json ~/taiga-front-dist/dist/conf.json
eend
}
install_taiga_events(){
cd ~
einfo 'Получение кода taiga_events'
git clone https://github.com/kaleidos-ventures/taiga-events.git taiga-events
cd taiga-events
git checkout stable
einfo 'Установка необходимых зависимостей JavaScript'
#source ~/.node-live/bin/activate
npm install
npm audit fix
ebegin 'Создание .env файла на основе предоставленного примера'
cp .env.example .env
eend
}
install_taiga_protected(){
cd ~
einfo 'Получение кода taiga_protected'
git clone https://github.com/kaleidos-ventures/taiga-protected.git taiga-protected
cd taiga-protected
git checkout stable
einfo 'Создание виртуальной среды'
python -m venv .venv --prompt taiga-protected
source .venv/bin/activate
pip install --upgrade pip wheel
einfo 'Установка всех зависимостей Python'
pip install -r requirements.txt
ebegin 'Копирование примера файла конфигурации'
cp ~/taiga-protected/env.sample ~/taiga-protected/.env
eend
}
migrate_pgsql(){
cd ~
cd taiga-back
source .venv/bin/activate
DJANGO_SETTINGS_MODULE=settings.config python manage.py migrate --noinput
einfo create an administrator with strong password
CELERY_ENABLED=False DJANGO_SETTINGS_MODULE=settings.config python manage.py createsuperuser
DJANGO_SETTINGS_MODULE=settings.config python manage.py loaddata initial_project_templates
DJANGO_SETTINGS_MODULE=settings.config python manage.py compilemessages
DJANGO_SETTINGS_MODULE=settings.config python manage.py collectstatic --noinput
}
#-----------------------------------------------------------------------------
# Запуск
#-----------------------------------------------------------------------------
[[ ! -e ~/taiga-back ]] && install_taiga_back
[[ ! -e ~/taiga-front-dist ]] && install_taiga_front_dist
[[ ! -e ~/taiga-events ]] && install_taiga_events
[[ ! -e ~/taiga-protected ]] && install_taiga_protected
einfo "Все установлено! Для настройки Taiga выполните 'setup-taiga'."
#migrate_pgsql

@ -0,0 +1,32 @@
# Calculate path=/var/calculate/bin name=#-cut(1,.)-# chmod=755 comment=#
#!/bin/bash
set -ueo pipefail
export PATH="/lib/rc/bin:$PATH"
source /var/calculate/config/taiga
ebegin 'Проверка выполненной базовой настройки'
if [[ ! -e /var/lib/postgresql/12 ]]
then
echo Выполните настройку 'emerge --config =dev-db/postgresql-12.12'.
exit 1
fi
eend
ebegin 'Проверка запущенного PostgreSQL'
if [[ $(ls /run/postgresql/.*lock 2>/dev/null | wc -l) == 0 ]]
then
echo Запустите PostgreSQL
exit 1
fi
eend
ebegin 'Проверка наличия роли taiga'
$(psql -U taiga -d taiga -c '\dt' 2&>/dev/null) || {
echo Пароль: $PGSQL_PASSWORD
createuser -U postgres -P taiga
createdb -U postgres -O taiga taiga
}
eend
cl-core-setup -n postgresql

@ -0,0 +1,18 @@
# Calculate path=/var/calculate/bin name=#-cut(1,.)-# chmod=755 comment=#
#!/bin/bash
set -ueo pipefail
export PATH="/lib/rc/bin:$PATH"
source /var/calculate/config/taiga
rabbit_configure(){
if [[ ! -e /var/lib/rabbitmq/mnesia ]]
then
/etc/init.d/rabbitmq start
rabbitmqctl add_user $RABBITMQ_USER $RABBITMQ_PASSWORD
rabbitmqctl add_vhost taiga
rabbitmqctl set_permissions -p taiga $RABBITMQ_USER ".*" ".*" ".*"
fi
}
rabbit_configure

@ -0,0 +1,164 @@
# Calculate path=/var/calculate/bin name=#-cut(1,.)-# chmod=755 comment=#
#!/bin/bash
export PATH="/lib/rc/bin:$PATH"
set -ueo pipefail
source /var/calculate/config/taiga
replace=(
"taiga-back/settings/config.py" ""
"('PASSWORD':).*" "\1 '${PGSQL_PASSWORD}',"
"^.*(SECRET_KEY =).*" "\1 \"${SECRET_KEY}\""
"^.*(TAIGA_SITES_SCHEME =).*" "\1 \"${PROTOCOL}\""
"^.*(TAIGA_SITES_DOMAIN =).*" "\1 \"${TAIGA_SITES_DOMAIN}\""
"^.*(MEDIA_ROOT =).*" "\1 '/var/calculate/www/taiga/taiga-back/media'"
"^.*(DEFAULT_FROM_EMAIL =).*" "\1 '${FROM_EMAIL}'"
"^.*(EMAIL_USE_TLS =).*" "\1 '${SMTP_TLS}'"
"^.*(EMAIL_USE_SSL =).*" "\1 '${SMTP_SSL}'"
"^.*(EMAIL_HOST =).*" "\1 '${SMTP_HOST}'"
"^.*(EMAIL_PORT =).*" "\1 ${SMTP_PORT}"
"^.*(EMAIL_HOST_USER =).*" "\1 '${SMTP_USER}'"
"^.*(EMAIL_HOST_PASSWORD =).*" "\1 '${SMTP_PASSWORD}'"
"(\"url\": \"amqp://).*(:5672/taiga\")" "\1${RABBITMQ_USER}:${RABBITMQ_PASSWORD}@localhost\2"
"^.*(CELERY_BROKER_URL =).*" "\1 \"amqp://${RABBITMQ_USER}:${RABBITMQ_PASSWORD}@localhost:5672/taiga\""
"^.*(CELERY_TIMEZONE =).*" "\1 'Europe/Moscow'"
"^.*(ENABLE_TELEMETRY =).*" "\1 False"
"^.*(PUBLIC_REGISTER_ENABLED =).*" "\1 True"
"taiga-front-dist/dist/conf.json" ""
"(\"api\":).*" "\1 \"${PROTOCOL}://${TAIGA_SITES_DOMAIN}/api/v1/\","
"(\"eventsUrl\":).*" "\1 \"wss://${TAIGA_SITES_DOMAIN}/events\","
"(\"defaultLanguage\":).*" "\1 \"ru\","
"(\"publicRegisterEnabled\":).*" "\1 true,"
"(\"supportUrl\":).*" "\1 \"${PROTOCOL}://${TAIGA_SITES_DOMAIN}\","
"(\"gravatar\":).*" "\1 false,"
"taiga-events/.env" ""
"^.*(RABBITMQ_URL=).*" "\1\"amqp://${RABBITMQ_USER}:${RABBITMQ_PASSWORD}@localhost:5672/taiga\""
"^.*(SECRET=).*" "\1\"${SECRET_KEY}\""
"taiga-protected/.env" ""
"^.*(SECRET_KEY=).*" "\1\"${SECRET_KEY}\""
)
homedir=/var/calculate/www/taiga
if [[ -d $homedir ]]
then
cd $homedir
else
eerror "Отсутствует директория $homedir!"
exit 1
fi
check_conf(){
conf=
for (( i=0; i < ${#replace[@]}; i += 2 ))
do
from=${replace[$i]}
to=${replace[$i+1]}
if [[ $to == '' ]]
then
conf=$from
continue
fi
if [[ ! -e $conf ]]
then
eerror "Не найден файл ~/taiga/$conf. Установите Taiga выполнив 'install-taiga'."
exit 2
fi
grep -qE "$from" $conf || exit 1
done
}
check_show(){
conf=
for (( i=0; i < ${#replace[@]}; i += 2 ))
do
from=${replace[$i]}
to=${replace[$i+1]}
if [[ $to == '' ]]
then
conf=$from
echo "$conf"
continue
fi
err=0
grep -qE "$from" $conf || err=1
if [[ $err == 0 ]]
then
einfo $from
else
eerror $from || true
fi
eend $err || true
done
}
configure_conf(){
conf=
for (( i=0; i < ${#replace[@]}; i += 2 ))
do
from=${replace[$i]}
to=${replace[$i+1]}
if [[ $to == '' ]]
then
if [[ $conf != '' ]]
then
eend
fi
conf=$from
ebegin $conf
continue
fi
sed -i -E "s|$from|$to|g" $conf
done
eend
}
show_conf(){
conf=
for (( i=0; i < ${#replace[@]}; i += 2 ))
do
from=${replace[$i]}
to=${replace[$i+1]}
if [[ $to == '' ]]
then
conf=$from
echo '#-------------------------------------------------------------------------'
echo " $conf"
echo '#-------------------------------------------------------------------------'
continue
fi
grep -E "$from" $conf
done
}
ebegin 'Проверка настраиваемых переменных'
`check_conf` || {
if [[ $? == 1 ]]
then
check_show
fi
exit
}
eend
einfo 'Настройка конфигурационных файлов:'
configure_conf
if [[ $# == 0 ]]
then
einfo "Для отображения настроенных опций выполните '$0 show'."
else
einfo 'Настроенные параметры:'
show_conf
fi

@ -0,0 +1 @@
# Calculate chmod=750 chown=taiga:nginx
Loading…
Cancel
Save