596 lines
15 KiB
YAML
596 lines
15 KiB
YAML
minimum-vagga: v0.6.1
|
|
|
|
_templates:
|
|
local_volumes: &local_volumes
|
|
/config: !BindRO /work/config/local
|
|
snippets:
|
|
- &trunk_stuff
|
|
- !Copy
|
|
source: /work/config/trunk
|
|
path: /config
|
|
- !EnsureDir /log
|
|
- !EnsureDir /lithos
|
|
- !Copy
|
|
source: /work/lithos/trunk
|
|
path: /lithos
|
|
- &production_stuff
|
|
- !Copy
|
|
source: /work/config/production
|
|
path: /config
|
|
- !EnsureDir /local
|
|
- !EnsureDir /log
|
|
- !EnsureDir /lithos
|
|
- !Copy
|
|
source: /work/lithos/production
|
|
path: /lithos
|
|
- &host_resolution
|
|
- !EnsureDir /state
|
|
- !Sh |
|
|
/bin/ln -sfn /state/hosts /etc/hosts
|
|
/bin/ln -sfn /state/resolv.conf /etc/resolv.conf
|
|
|
|
containers:
|
|
_base_alpine:
|
|
setup:
|
|
- !Alpine v3.4
|
|
- !AlpineRepo {branch: edge, repo: main, tag: main}
|
|
- !AlpineRepo {branch: edge, repo: testing, tag: testing}
|
|
- !AlpineRepo {branch: edge, repo: community, tag: community}
|
|
- !EnsureDir /config
|
|
- !Sh "chmod +r /bin/bbsuid"
|
|
|
|
frontend:
|
|
setup:
|
|
- !Container _base_alpine
|
|
- !Env
|
|
TRAVIS: true
|
|
- !NpmDependencies
|
|
file: package.json
|
|
peer: true
|
|
optional: true
|
|
dev: true
|
|
- !Install
|
|
- gettext
|
|
environ:
|
|
NODE_PATH: /usr/lib/node_modules
|
|
|
|
static-trunk:
|
|
setup:
|
|
- !Container frontend
|
|
- !EnsureDir /static
|
|
- !Copy
|
|
source: /work/frontend
|
|
path: /tmp/frontend
|
|
- !Copy
|
|
source: /work/templates/skin/synio/locale
|
|
path: /tmp/locale
|
|
- !RunAs
|
|
work-dir: /tmp/locale/ru_RU/LC_MESSAGES
|
|
script: |
|
|
msgcat -n -F -o messages.po parts/*
|
|
msgfmt messages.po
|
|
po2json -f jed1.x messages.po messages.json
|
|
- !Copy
|
|
source: /work/webpack.config.coffee
|
|
path: /tmp/webpack.config.coffee
|
|
- !Env
|
|
NODE_PATH: /usr/lib/node_modules
|
|
- !RunAs
|
|
work-dir: /tmp
|
|
script: webpack --color
|
|
- !Copy
|
|
source: /tmp/static
|
|
path: /static
|
|
- !Copy
|
|
source: /tmp/frontend/images/local
|
|
path: /static/local
|
|
- !Copy
|
|
source: /tmp/frontend.version
|
|
path: /static/frontend.version
|
|
data-dirs: [/static]
|
|
|
|
static-production:
|
|
setup:
|
|
- !Container frontend
|
|
- !EnsureDir /static
|
|
- !Copy
|
|
source: /work/frontend
|
|
path: /tmp/frontend
|
|
- !Copy
|
|
source: /work/templates/skin/synio/locale
|
|
path: /tmp/locale
|
|
- !RunAs
|
|
work-dir: /tmp/locale/ru_RU/LC_MESSAGES
|
|
script: |
|
|
msgcat -n -F -o messages.po parts/*
|
|
msgfmt messages.po
|
|
po2json -f jed1.x messages.po messages.json
|
|
- !Copy
|
|
source: /work/webpack.config.coffee
|
|
path: /tmp/webpack.config.coffee
|
|
- !Env
|
|
NODE_PATH: /usr/lib/node_modules
|
|
NODE_ENV: production
|
|
- !RunAs
|
|
work-dir: /tmp
|
|
script: webpack --color
|
|
- !Copy
|
|
source: /tmp/static
|
|
path: /static
|
|
- !Copy
|
|
source: /tmp/frontend/images/local
|
|
path: /static/local
|
|
- !Copy
|
|
source: /tmp/frontend.version
|
|
path: /static/frontend.version
|
|
data-dirs: [/static]
|
|
|
|
celery:
|
|
setup:
|
|
- !Container _base_alpine
|
|
- !Install [python3]
|
|
- !PipConfig
|
|
dependencies: true
|
|
- !Py3Install
|
|
- celery[redis]
|
|
- beautifulsoup4
|
|
- elasticsearch
|
|
- !EnsureDir /app
|
|
volumes:
|
|
<<: *local_volumes
|
|
/app: !BindRO /work/celery_tasks
|
|
environ:
|
|
PYTHONPATH: /config/celeryconfig:/app
|
|
CELERY_CONFIG_MODULE: cfg
|
|
CELERY_MAILER_HOST: localhost
|
|
CELERY_MAILER_PORT: 1025
|
|
|
|
celery-trunk:
|
|
setup:
|
|
- !Container celery
|
|
- !*Unpack
|
|
- *trunk_stuff
|
|
- *host_resolution
|
|
- !Copy
|
|
source: /work/celery_tasks
|
|
path: /app
|
|
- !Sh python3 -m compileall /app
|
|
resolv-conf-path: /state/resolv.conf
|
|
hosts-file-path: /state/hosts
|
|
|
|
celery-production:
|
|
setup:
|
|
- !Container celery
|
|
- !*Unpack
|
|
- *production_stuff
|
|
- *host_resolution
|
|
- !Copy
|
|
source: /work/celery_tasks
|
|
path: /app
|
|
- !Sh python3 -m compileall /app
|
|
resolv-conf-path: /state/resolv.conf
|
|
hosts-file-path: /state/hosts
|
|
|
|
redis:
|
|
setup:
|
|
- !Container _base_alpine
|
|
- !Install [redis]
|
|
- !EnsureDir /storage
|
|
volumes:
|
|
<<: *local_volumes
|
|
/storage: !Persistent {name: redis}
|
|
|
|
redis-trunk:
|
|
setup:
|
|
- !Container redis
|
|
- !*Unpack
|
|
- *trunk_stuff
|
|
- *host_resolution
|
|
resolv-conf-path: /state/resolv.conf
|
|
hosts-file-path: /state/hosts
|
|
|
|
redis-production:
|
|
setup:
|
|
- !Container redis
|
|
- !*Unpack
|
|
- *production_stuff
|
|
- *host_resolution
|
|
resolv-conf-path: /state/resolv.conf
|
|
hosts-file-path: /state/hosts
|
|
|
|
nginx:
|
|
setup:
|
|
- !Container _base_alpine
|
|
- !Install [nginx]
|
|
- !EnsureDir /storage
|
|
volumes:
|
|
<<: *local_volumes
|
|
/storage: !Persistent {name: storage}
|
|
/var/log/nginx: !Snapshot
|
|
|
|
mysql-dev:
|
|
setup:
|
|
- !Container _base_alpine
|
|
# TODO: Replace with ordinary install when https://github.com/alpinelinux/aports/pull/808/files will be merged
|
|
- !Download
|
|
url: https://files.everypony.org/alpine/testing/x86_64/xtrabackup-2.4.5-r0.apk
|
|
path: /tmp/xtrabackup-2.4.5-r0.apk
|
|
- !Sh apk add /tmp/xtrabackup-2.4.5-r0.apk --allow-untrusted
|
|
- !Install
|
|
- mariadb
|
|
- mariadb-client
|
|
- perl
|
|
- perl-dbd-mysql
|
|
- rsync
|
|
- !Copy
|
|
source: /work/config/local/mysql
|
|
path: /etc/mysql
|
|
- !EnsureDir /storage
|
|
- !EnsureDir /backup
|
|
volumes:
|
|
/storage: !Persistent {name: mysql, init-command: _init_db}
|
|
/backup: !Persistent {name: backup}
|
|
|
|
mysql-trunk:
|
|
setup:
|
|
- !Container mysql-dev
|
|
- !*Unpack
|
|
- *trunk_stuff
|
|
- *host_resolution
|
|
- !Copy
|
|
source: /config/mysql
|
|
path: /etc/mysql
|
|
resolv-conf-path: /state/resolv.conf
|
|
hosts-file-path: /state/hosts
|
|
|
|
mysql-production:
|
|
setup:
|
|
- !Container mysql-dev
|
|
- !*Unpack
|
|
- *production_stuff
|
|
- *host_resolution
|
|
- !Copy
|
|
source: /config/mysql
|
|
path: /etc/mysql
|
|
resolv-conf-path: /state/resolv.conf
|
|
hosts-file-path: /state/hosts
|
|
|
|
_php-base:
|
|
setup:
|
|
- !Container _base_alpine
|
|
- !Install
|
|
- php5-fpm
|
|
- libressl@main
|
|
- php5-mysql
|
|
- php5-pdo_mysql
|
|
- php5-mcrypt
|
|
- php5-redis@testing
|
|
- php5-gettext
|
|
- php5-json
|
|
- php5-curl
|
|
- php5-imagick@community
|
|
- php5-bcmath
|
|
- imagemagick@main
|
|
- !ComposerDependencies
|
|
optimize_autoloader: true
|
|
- !EnsureDir /log
|
|
- !EnsureDir /storage
|
|
|
|
php-dev:
|
|
setup:
|
|
- !Container _php-base
|
|
- !Install
|
|
- php5-xdebug@community
|
|
- php5-cli
|
|
- git
|
|
- !Copy
|
|
source: /work/config/local/php
|
|
path: /etc/php5
|
|
volumes:
|
|
<<: *local_volumes
|
|
/storage: !Persistent {name: storage}
|
|
/log: !Persistent {name: php_log}
|
|
/var/log: !Snapshot
|
|
|
|
php-trunk:
|
|
setup:
|
|
- !Container _php-base
|
|
- !*Unpack
|
|
- *trunk_stuff
|
|
- *host_resolution
|
|
- !Copy
|
|
source: /config/php
|
|
path: /etc/php5
|
|
- !EnsureDir /app
|
|
- !Copy
|
|
source: /work
|
|
path: /app
|
|
include-regex: ^(classes|settings|engine|templates)/*
|
|
- !Copy
|
|
source: /work/index.php
|
|
path: /app/index.php
|
|
- !BuildDeps [gettext]
|
|
- !RunAs
|
|
work-dir: /app/templates/skin/synio/locale/ru_RU/LC_MESSAGES
|
|
script: |
|
|
msgcat -n -F -o messages.po parts/*
|
|
msgfmt messages.po
|
|
rm -vr messages.po parts
|
|
- !BuildDeps [git]
|
|
- !Sh git describe --always > /app/backend.version
|
|
- !Build
|
|
container: static-trunk
|
|
source: /static
|
|
temporary-mount: /mnt
|
|
- !Copy
|
|
source: /mnt/frontend.version
|
|
path: /app/frontend.version
|
|
resolv-conf-path: /state/resolv.conf
|
|
hosts-file-path: /state/hosts
|
|
|
|
php-production:
|
|
setup:
|
|
- !Container _php-base
|
|
- !Install [php5-xcache@main]
|
|
- !*Unpack
|
|
- *production_stuff
|
|
- *host_resolution
|
|
- !Copy
|
|
source: /config/php
|
|
path: /etc/php5
|
|
- !EnsureDir /app
|
|
- !Copy
|
|
source: /work
|
|
path: /app
|
|
include-regex: ^(classes|settings|engine|templates)/*
|
|
- !Copy
|
|
source: /work/index.php
|
|
path: /app/index.php
|
|
- !BuildDeps [gettext]
|
|
- !RunAs
|
|
work-dir: /app/templates/skin/synio/locale/ru_RU/LC_MESSAGES
|
|
script: |
|
|
msgcat -n -F -o messages.po parts/*
|
|
msgfmt messages.po
|
|
rm -vr messages.po parts
|
|
- !BuildDeps [git]
|
|
- !Sh git describe --always > /app/backend.version
|
|
- !Build
|
|
container: static-production
|
|
source: /static
|
|
temporary-mount: /mnt
|
|
- !Copy
|
|
source: /mnt/frontend.version
|
|
path: /app/frontend.version
|
|
resolv-conf-path: /state/resolv.conf
|
|
hosts-file-path: /state/hosts
|
|
|
|
elastic-dev:
|
|
setup:
|
|
- !Container _base_alpine
|
|
- !Install
|
|
- openjdk8-jre@community
|
|
- java-jna@community
|
|
- elasticsearch@community
|
|
- !EnsureDir /log
|
|
- !EnsureDir /storage
|
|
volumes:
|
|
/log: !Persistent {name: elastic_log}
|
|
/storage: !Persistent {name: elastic}
|
|
/etc/elasticsearch: !BindRO /work/config/local/elasticsearch
|
|
|
|
elastic-trunk:
|
|
setup:
|
|
- !Container elastic-dev
|
|
- !*Unpack
|
|
- *trunk_stuff
|
|
- *host_resolution
|
|
- !Copy
|
|
source: /config/elasticsearch
|
|
path: /etc/elasticsearch
|
|
resolv-conf-path: /state/resolv.conf
|
|
hosts-file-path: /state/hosts
|
|
|
|
elastic-production:
|
|
setup:
|
|
- !Container elastic-dev
|
|
- !*Unpack
|
|
- *production_stuff
|
|
- *host_resolution
|
|
- !Copy
|
|
source: /config/elasticsearch
|
|
path: /etc/elasticsearch
|
|
resolv-conf-path: /state/resolv.conf
|
|
hosts-file-path: /state/hosts
|
|
|
|
commands:
|
|
_write-version: !Command
|
|
container: php-dev
|
|
run: git describe --always --dirty=-dev > /work/backend.version
|
|
|
|
_init_db: !Command
|
|
description: Initialize and populate MySQL database
|
|
container: mysql-dev
|
|
environ:
|
|
DB_HOST: 127.0.0.1
|
|
DB_DATABASE: tabun
|
|
DB_USERNAME: tabun
|
|
DB_PASSWORD: tabun
|
|
run: |
|
|
mysql_install_db
|
|
mysqld_safe --skip-syslog --no-auto-restart
|
|
while [ ! -f /tmp/mysqld.pid ]; do sleep 0.1; done
|
|
mysqladmin create $DB_DATABASE
|
|
mysql -e "CREATE USER '$DB_USERNAME'@'$DB_HOST' IDENTIFIED BY '$DB_PASSWORD';"
|
|
mysql -e "GRANT ALL PRIVILEGES ON $DB_DATABASE.* TO '$DB_USERNAME'@'$DB_HOST';"
|
|
mysqladmin flush-privileges
|
|
|
|
MYSQL="mysql --user=$DB_USERNAME --password=$DB_PASSWORD --database=$DB_DATABASE"
|
|
|
|
for migration in $(ls -v /work/fixtures/migrations) ; do
|
|
echo "Applying migration $migration"
|
|
$MYSQL < /work/fixtures/migrations/$migration
|
|
done
|
|
|
|
for data in $(ls -v /work/fixtures/data) ; do
|
|
echo "Populating database with $data"
|
|
$MYSQL < /work/fixtures/data/$data
|
|
done
|
|
|
|
mysqladmin shutdown
|
|
|
|
_load_fixture: !Command
|
|
description: Load fixture into database
|
|
container: mysql-dev
|
|
environ:
|
|
DB_HOST: 127.0.0.1
|
|
DB_DATABASE: tabun
|
|
DB_USERNAME: tabun
|
|
DB_PASSWORD: tabun
|
|
accepts-arguments: true
|
|
run: |
|
|
mysqld_safe --skip-syslog --no-auto-restart
|
|
while [ ! -f /tmp/mysqld.pid ]; do sleep 0.1; done
|
|
if [ "$#" = 1 ] ; then
|
|
case "$1" in
|
|
*.gz )
|
|
echo "Loading compressed data from $1"
|
|
viewer=zcat
|
|
;;
|
|
*)
|
|
echo "Loading raw data from $1"
|
|
viewer=cat
|
|
;;
|
|
esac
|
|
$viewer $1 | mysql --user=$DB_USERNAME --password=$DB_PASSWORD --database=$DB_DATABASE
|
|
fi
|
|
mysqladmin shutdown
|
|
|
|
build-static: !Command
|
|
prerequisites: [_clean-old-static, compile-locales]
|
|
container: frontend
|
|
description: Build static files using webpack
|
|
run: |
|
|
webpack --progress
|
|
cp -r frontend/images/local static/local
|
|
|
|
_clean-old-static: !Command
|
|
container: frontend
|
|
description: Clean static files
|
|
run: |
|
|
mkdir -vp /work/static
|
|
rm -rf /work/static/*
|
|
|
|
compile-locales: !Command
|
|
container: frontend
|
|
description: Comlile locale files
|
|
work-dir: templates/skin/synio/locale/ru_RU/LC_MESSAGES
|
|
run: |
|
|
msgcat -n -F -o messages.po parts/*
|
|
msgfmt messages.po
|
|
po2json -f jed1.x messages.po messages.json
|
|
rm messages.po
|
|
|
|
watch-static: !Command
|
|
container: frontend
|
|
description: Watch and auto-rebuild changed static files
|
|
run: [webpack, --progress, --watch]
|
|
|
|
reindex: !Command
|
|
container: php-dev
|
|
description: Rebuild ES index
|
|
work-dir: engine/console
|
|
accepts-arguments: true
|
|
environ:
|
|
CONFIG: /config/app.conf.php
|
|
COMPOSER_DIR: /usr/local/lib/composer
|
|
run: [php, ls, reindex]
|
|
|
|
webpack: !Command
|
|
container: static
|
|
description: Webpack CLI
|
|
run: [webpack]
|
|
|
|
redis-cli: &redis !Command
|
|
container: redis
|
|
description: Run redis CLI
|
|
run: redis-cli
|
|
|
|
redis: &redis !Command
|
|
container: redis
|
|
description: Run redis server (cache and broker for celery)
|
|
run: redis-server /config/redis.conf
|
|
|
|
nginx: &nginx !Command
|
|
container: nginx
|
|
description: Run nginx webserver
|
|
run: nginx -c /config/nginx.conf
|
|
|
|
mysql: &mysql !Command
|
|
container: mysql-dev
|
|
description: Run mysql database server
|
|
user-id: 1
|
|
external-user-id: 0
|
|
run: mysqld_safe --skip-syslog --console --debug-gdb
|
|
|
|
innobackupex: &innobackupex !Command
|
|
container: mysql-dev
|
|
description: Run innobackupex command
|
|
user-id: 1
|
|
external-user-id: 0
|
|
run: [innobackupex]
|
|
|
|
mail: &mail !Command
|
|
container: celery
|
|
description: Run simple mail server (just for test)
|
|
run: python3 -m smtpd -c DebuggingServer -d -n 127.0.0.1:1025
|
|
|
|
celery: &celery !Command
|
|
container: celery
|
|
description: Run celery worker for async tasks
|
|
user-id: 1
|
|
group-id: 1
|
|
external-user-id: 0
|
|
run: celery worker --pool=solo
|
|
|
|
php: &php !Command
|
|
prerequisites: [_write-version]
|
|
container: php-dev
|
|
description: Run php-fpm (application)
|
|
user-id: 1
|
|
external-user-id: 0
|
|
run: [php-fpm, -eFO]
|
|
|
|
elastic: &elastic !Command
|
|
description: Run elasticsearch
|
|
container: elastic-dev
|
|
user-id: 1
|
|
external-user-id: 0
|
|
environ:
|
|
ES_HOME_DIR: /storage
|
|
ES_XMS: 256
|
|
ES_XMX: 2048
|
|
run: |
|
|
java -server \
|
|
-Xms${ES_XMS}M -Xmx${ES_XMX}M \
|
|
-Djna.nosys=true \
|
|
-XX:+DisableExplicitGC \
|
|
-Djava.awt.headless=true \
|
|
-Dfile.encoding=utf-8 \
|
|
-Des.path.conf=/etc/elasticsearch \
|
|
-Des.path.home=${ES_HOME_DIR} \
|
|
-cp /usr/share/java/elasticsearch/lib/elasticsearch-2.3.5.jar:/usr/share/java/elasticsearch/lib/* \
|
|
org.elasticsearch.bootstrap.Elasticsearch start
|
|
|
|
run: !Supervise
|
|
description: Run full server stack
|
|
kill-unresponsive-after: 5
|
|
children:
|
|
redis: *redis
|
|
nginx: *nginx
|
|
mysql: *mysql
|
|
mail: *mail
|
|
celery: *celery
|
|
php: *php
|
|
elastic: *elastic
|