Advertisement
Guest User

Untitled

a guest
Oct 14th, 2016
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.89 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. - !Sh "chmod +r /bin/bbsuid"
  11. mysql:
  12. setup:
  13. - !Container _base_alpine
  14. - !Install
  15. - mariadb
  16. - mariadb-client
  17. volumes:
  18. <<: *local_volumes
  19. /var/lib/mysql: !Persistent {name: mysql, init-command: _init_db}
  20.  
  21. nginx:
  22. setup:
  23. - !Container _base_alpine
  24. - !Install [nginx]
  25. volumes:
  26. <<: *local_volumes
  27. /var/log/nginx: !Snapshot
  28.  
  29. php:
  30. setup:
  31. - !Alpine v3.4
  32. - !Sh "chmod +r /bin/bbsuid"
  33. - !AlpineRepo {branch: edge, repo: main, tag: main}
  34. - !AlpineRepo {branch: edge, repo: testing, tag: testing}
  35. - !AlpineRepo {branch: edge, repo: community, tag: community}
  36. - !Install
  37. - php5-fpm@main
  38. - php5-mysqli
  39. - php5-json
  40. - php5-cli
  41. - php5-ctype
  42. - !Copy
  43. source: /work/config/local/php-fpm.conf
  44. path: /etc/php5/fpm.d/app.pool.conf
  45. - !EnsureDir /log
  46. - !EnsureDir /config
  47. volumes:
  48. <<: *local_volumes
  49. /log: !Persistent {name: php_log}
  50. /var/log: !Snapshot
  51.  
  52. commands:
  53. _init_db: !Command
  54. description: Initialize MySQL database
  55. container: mysql
  56. environ:
  57. DB_HOST: 127.0.0.1
  58. DB_DATABASE: getexam
  59. DB_USERNAME: getexam
  60. DB_PASSWORD: getexam
  61. run: |
  62. mysql_install_db
  63. mysqld_safe --defaults-extra-file=/config/mysql.conf --skip-syslog --no-auto-restart
  64. while [ ! -f /tmp/mysqld.pid ]; do sleep 0.1; done
  65. mysqladmin --defaults-extra-file=/config/mysql.conf create $DB_DATABASE
  66. mysql --defaults-extra-file=/config/mysql.conf -e "CREATE USER '$DB_USERNAME'@'$DB_HOST' IDENTIFIED BY '$DB_PASSWORD';"
  67. mysql --defaults-extra-file=/config/mysql.conf -e "GRANT ALL PRIVILEGES ON $DB_DATABASE.* TO '$DB_USERNAME'@'$DB_HOST';"
  68. mysqladmin --defaults-extra-file=/config/mysql.conf flush-privileges
  69. mysqladmin --defaults-extra-file=/config/mysql.conf shutdown
  70.  
  71. mysql: &mysql !Command
  72. container: mysql
  73. description: Run mysql database server
  74. user-id: 1
  75. external-user-id: 0
  76. run: mysqld_safe --defaults-extra-file=/config/mysql.conf --skip-syslog --console --debug-gdb
  77.  
  78. nginx: &nginx !Command
  79. container: nginx
  80. description: Run nginx webserver
  81. run: nginx -c /config/nginx.conf
  82.  
  83. php: &php !Command
  84. container: php
  85. description: Run php-fpm (application)
  86. user-id: 1
  87. external-user-id: 0
  88. run: [php-fpm, -eFO]
  89.  
  90. migration: &migration !Command
  91. container: php
  92. description: Run latest migration
  93. user-id: 1
  94. external-user-id: 0
  95. run: |
  96. cd /work/
  97. php index.php cli migration last
  98.  
  99. run: !Supervise
  100. description: Run full server stack
  101. kill-unresponsive-after: 5
  102. children:
  103. mysql: *mysql
  104. nginx: *nginx
  105. php: *php
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement