Advertisement
Guest User

Untitled

a guest
Nov 20th, 2016
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
YAML 3.43 KB | None | 0 0
  1. templates:
  2.   local_volumes: &local_volumes
  3.     /config: !BindRO /work/config/local
  4.  
  5. containers:
  6.   _base_alpine:
  7.     setup:
  8.      - !Alpine v3.4
  9.       - !EnsureDir /config
  10.  
  11.   frontend:
  12.       setup:
  13.      - !Container _base_alpine
  14.       - !Install [nodejs]
  15.       - !Sh 'npm install'
  16.       environ:
  17.         NODE_PATH: /usr/lib/node_modules
  18.  
  19.   mysql:
  20.     setup:
  21.      - !Container _base_alpine
  22.       - !Install
  23.         - mariadb
  24.         - mariadb-client
  25.     volumes:
  26.       <<: *local_volumes
  27.       /var/lib/mysql: !Persistent {name: mysql, init-command: _init_db}
  28.  
  29.   nginx:
  30.     setup:
  31.      - !Container _base_alpine
  32.       - !Install [nginx]
  33.     volumes:
  34.       <<: *local_volumes
  35.       /var/log/nginx: !Snapshot
  36.  
  37.   php:
  38.     setup:
  39.      - !Alpine v3.4
  40.       - !AlpineRepo {branch: edge, repo: main, tag: main}
  41.       - !AlpineRepo {branch: edge, repo: testing, tag: testing}
  42.       - !AlpineRepo {branch: edge, repo: community, tag: community}
  43.       - !Install
  44.         - php5-fpm
  45.         - php5-mysqli
  46.         - php5-json
  47.         - php5-cli
  48.         - php5-ctype
  49.       - !Copy
  50.         source: /work/config/local/php-fpm.conf
  51.         path: /etc/php5/fpm.d/app.pool.conf
  52.       - !EnsureDir /log
  53.       - !EnsureDir /config
  54.     volumes:
  55.       <<: *local_volumes
  56.       /log: !Persistent {name: php_log}
  57.       /var/log: !Snapshot
  58.  
  59. commands:
  60.   _init_db: !Command
  61.     description: Initialize MySQL database
  62.     container: mysql
  63.     environ:
  64.       DB_HOST: 127.0.0.1
  65.       DB_DATABASE: <db>
  66.       DB_USERNAME: <user>
  67.       DB_PASSWORD: <pass>
  68.     run: |
  69.      mysql_install_db
  70.       mysqld_safe --defaults-extra-file=/config/mysql.conf --skip-syslog --no-auto-restart
  71.       while [ ! -f /tmp/mysqld.pid ]; do sleep 0.1; done
  72.       mysqladmin --defaults-extra-file=/config/mysql.conf create $DB_DATABASE
  73.       mysql --defaults-extra-file=/config/mysql.conf -e "CREATE USER '$DB_USERNAME'@'$DB_HOST' IDENTIFIED BY '$DB_PASSWORD';"
  74.       mysql --defaults-extra-file=/config/mysql.conf -e "GRANT ALL PRIVILEGES ON $DB_DATABASE.* TO '$DB_USERNAME'@'$DB_HOST';"
  75.       mysqladmin --defaults-extra-file=/config/mysql.conf flush-privileges
  76.       mysqladmin --defaults-extra-file=/config/mysql.conf shutdown
  77.  
  78.   mysql: &mysql !Command
  79.     container: mysql
  80.     description: Run mysql database server
  81.     user-id: 1
  82.     external-user-id: 0
  83.     run: mysqld_safe --defaults-extra-file=/config/mysql.conf --skip-syslog --console --debug-gdb
  84.  
  85.   nginx: &nginx !Command
  86.     container: nginx
  87.     description: Run nginx webserver
  88.     run: nginx -c /config/nginx.conf
  89.  
  90.   php: &php !Command
  91.     container: php
  92.     description: Run php-fpm (application)
  93.     user-id: 1
  94.     external-user-id: 0
  95.     run: [php-fpm, -eFO]
  96.  
  97.   migration: &migration !Command
  98.     container: php
  99.     description: Run latest migration
  100.     run: |
  101.      cd /work/
  102.       php index.php cli migration last
  103.  
  104.   _clean-old-static: !Command
  105.     container: frontend
  106.     description: Clean static files
  107.     run: |
  108.      mkdir -vp /work/static
  109.       rm -rf /work/static/*
  110.  
  111.   build-static: !Command
  112.     prerequisites: [_clean-old-static]
  113.     container: frontend
  114.     description: Build static files
  115.     run: [npm, run-script, webpack:trunk]
  116.  
  117.   watch-static: !Command
  118.     prerequisites: [_clean-old-static]
  119.     container: frontend
  120.     description: Watch and auto-rebuild changed static files
  121.     run: [npm, run-script, webpack:watch]
  122.  
  123.   run: !Supervise
  124.     description: Run full server stack
  125.     kill-unresponsive-after: 5
  126.     children:
  127.       mysql: *mysql
  128.       nginx: *nginx
  129.       php: *php
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement