ponyFiction/vagga.yaml

371 lines
8.7 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
environ:
local_db: &local_db
DB_HOST: 127.0.0.1
DB_DATABASE: stories
DB_USERNAME: celestia
DB_PASSWORD: solar_eclipse
containers:
_base_alpine:
setup:
- !Alpine v3.5
- !AlpineRepo {branch: edge, repo: main, tag: main}
- !AlpineRepo {branch: edge, repo: testing, tag: testing}
- !AlpineRepo {branch: edge, repo: community, tag: community}
- !EnsureDir /config
- !EnsureDir /storage
- !Sh "chmod +r /bin/bbsuid"
frontend-build:
setup:
- !Container _base_alpine
- !NpmDependencies
file: package.json
peer: true
optional: true
dev: true
- !Sh npm rebuild node-sass
volumes:
/root: !Snapshot
trunk-scripts:
setup:
- !Container frontend-build
- !EnsureDir /static
- !Copy
source: /work/assets
path: /tmp/assets
- !Copy
source: /work/.bootstraprc
path: /tmp/.bootstraprc
- !Copy
source: /work/webpack.config.babel.js
path: /tmp/webpack.config.babel.js
- !Copy
source: /work/package.json
path: /tmp/package.json
- !Env
NODE_PATH: /usr/lib/node_modules
NODE_ENV: trunk
- !RunAs
work-dir: /tmp
script: webpack --progress
- !Copy
source: /tmp/static
path: /static
- !Copy
source: /tmp/frontend.version
path: /frontend.version
# Ugly hack for old character widget :(
- !EnsureDir /static/images
- !Copy
source: /work/assets/images/characters
path: /static/images/characters
auto-clean: true
data-dirs: [/static, /frontend.version]
bundled-static:
setup:
- !Container uwsgi-dev
- !RunAs
work-dir: /work
script: python3 manage.py collectstatic --noinput --settings app --pythonpath /work/config/trunk/python
auto-clean: true
data-dirs: [/srv]
static-trunk:
setup:
- !Container _base_alpine
- !EnsureDir /static
# Copy all static from build system
- !Build
container: trunk-scripts
source: /
path: /
# Then append static from bundled Django apps
- !Build
container: bundled-static
source: /srv
temporary-mount: /srv
- !RunAs
work-dir: /
script: cp -r /srv/* /static/`cat frontend.version`/
data-dirs: [/static, /frontend.version]
redis-dev:
setup:
- !Container _base_alpine
- !Install [redis]
volumes:
<<: *local_volumes
/storage: !Tmpfs
size: 128Mi
mode: 0o1700
redis-trunk:
setup:
- !Container redis-dev
- !*Unpack
- *trunk_stuff
- *host_resolution
resolv-conf-path: /state/resolv.conf
hosts-file-path: /state/hosts
redis-production:
setup:
- !Container redis-dev
- !*Unpack
- *production_stuff
- *host_resolution
resolv-conf-path: /state/resolv.conf
hosts-file-path: /state/hosts
nginx:
setup:
- !Container _base_alpine
- !Install [nginx]
volumes:
<<: *local_volumes
/var/log/nginx: !Snapshot
sphinx-dev:
setup:
- !Container _base_alpine
- !Install [sphinx@community]
volumes:
<<: *local_volumes
/storage: !Persistent {name: sphinx}
sphinx-trunk:
setup:
- !Container sphinx-dev
- !*Unpack
- *trunk_stuff
- *host_resolution
resolv-conf-path: /state/resolv.conf
hosts-file-path: /state/hosts
sphinx-production:
setup:
- !Container sphinx-dev
- !*Unpack
- *production_stuff
- *host_resolution
resolv-conf-path: /state/resolv.conf
hosts-file-path: /state/hosts
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
- !EnsureDir /backup
volumes:
/storage: !Persistent
name: mysql
init-command: _init_db
/backup: !Persistent {name: backup}
/etc/mysql: !BindRO /work/config/local/mysql
mysql-trunk:
setup:
- !Container mysql-dev
- !*Unpack
- *trunk_stuff
- *host_resolution
- !Copy
source: /config/mysql
path: /etc/mysql
- !Copy
source: /work/fixtures
path: /fixtures
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
- !Copy
source: /work/fixtures
path: /fixtures
resolv-conf-path: /state/resolv.conf
hosts-file-path: /state/hosts
uwsgi-dev:
setup:
- !Container _base_alpine
- !Install
- uwsgi-python3
- libxslt-dev
- mariadb-dev
- ca-certificates
- !Py3Requirements requirements.txt
volumes:
<<: *local_volumes
uwsgi-trunk:
setup:
- !Container uwsgi-dev
- !*Unpack
- *trunk_stuff
- *host_resolution
- !EnsureDir /app
- !Sh cp -r /work/ponyFiction /app
- !Sh python3 -m compileall /app
- !BuildDeps [git]
- !Sh git describe --always > /app/backend.version
- !Build
container: static-trunk
source: /frontend.version
path: /app/frontend.version
resolv-conf-path: /state/resolv.conf
hosts-file-path: /state/hosts
commands:
_init_db: !Command
description: Initialize and populate MySQL database
container: mysql-dev
environ: *local_db
run: !*Include vagga/init_db.yaml
load_fixture: !Command
description: Load fixture into database
container: mysql-dev
environ: *local_db
accepts-arguments: true
run: !*Include vagga/load_fixture.yaml
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
redis-cli: &redis !Command
container: redis-dev
description: Run redis CLI
run: [redis-cli]
redis: &redis !Command
container: redis-dev
description: Run redis server (cache and broker for celery)
run: redis-server /config/redis/redis.conf
nginx: &nginx !Command
container: nginx
description: Run nginx webserver
run: nginx -c /config/nginx/nginx.conf
sphinx: &sphinx !Command
container: sphinx-dev
description: Run sphinx search service
run:
- searchd
- --console
- --config
- /config/sphinx/sphinx.conf
uwsgi: &uwsgi !Command
container: uwsgi-dev
description: Run application
environ:
PYTHONPATH: /config/python
DJANGO_SETTINGS_MODULE: app
run:
- uwsgi
- /config/uwsgi/uwsgi.ini
celery: &celery !Command
container: uwsgi-dev
description: Run celery worker
environ:
PYTHONPATH: /config/python
DJANGO_SETTINGS_MODULE: app
run:
- celery
- worker
- -A
- ponyFiction
- --loglevel=INFO
webpack: !Command
container: frontend-build
description: Webpack command
environ:
NODE_PATH: /usr/lib/node_modules
NODE_ENV: local
run: [webpack, --progress]
collectstatic: !Command
container: uwsgi-dev
run: |
python3 manage.py collectstatic --noinput --settings app --pythonpath /work/config/local/python
mkdir -p /work/static/images
cp -r /work/assets/images/characters /work/static/images/characters
run: !Supervise
description: Run full server stack
kill-unresponsive-after: 5
children:
redis: *redis
mysql: *mysql
sphinx: *sphinx
uwsgi: *uwsgi
nginx: *nginx
manage.py: !Command
description: Django management tool
container: uwsgi-dev
environ:
PYTHONPATH: /config/python:/work/debug/pycharm-debug.egg
DJANGO_SETTINGS_MODULE: app
run:
- python3
- manage.py