Advertisement
Guest User

Untitled

a guest
Mar 4th, 2017
181
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.50 KB | None | 0 0
  1. _templates:
  2. local_volumes: &local_volumes
  3. /config: !BindRO /work/config/local
  4. snippets:
  5. - &trunk_stuff
  6. - !Copy
  7. source: /work/config/trunk
  8. path: /config
  9. - !EnsureDir /log
  10. - !EnsureDir /lithos
  11. - !Copy
  12. source: /work/lithos/trunk
  13. path: /lithos
  14.  
  15. - &production_stuff
  16. - !Copy
  17. source: /work/config/production
  18. path: /config
  19. - !EnsureDir /log
  20. - !EnsureDir /lithos
  21. - !Copy
  22. source: /work/lithos/production
  23. path: /lithos
  24.  
  25. - &host_resolution
  26. - !EnsureDir /state
  27. - !Sh |
  28. /bin/ln -sfn /state/hosts /etc/hosts
  29. /bin/ln -sfn /state/resolv.conf /etc/resolv.conf
  30.  
  31. containers:
  32. _base_alpine:
  33. setup:
  34. - !Alpine v3.4
  35. - !AlpineRepo {branch: edge, repo: main, tag: main}
  36. - !AlpineRepo {branch: edge, repo: testing, tag: testing}
  37. - !AlpineRepo {branch: edge, repo: community, tag: community}
  38. - !EnsureDir /config
  39. - !Sh "chmod +r /bin/bbsuid"
  40.  
  41. frontend:
  42. image-cache-url: https://dl.uwtech.org/vagga/get/${container_name}.${short_hash}.tar.xz
  43. setup:
  44. - !Container _base_alpine
  45. - !Install [nodejs]
  46. - !NpmDependencies
  47. environ:
  48. NODE_PATH: /usr/lib/node_modules
  49.  
  50. mysql:
  51. image-cache-url: https://dl.uwtech.org/vagga/get/${container_name}.${short_hash}.tar.xz
  52. setup:
  53. - !Container _base_alpine
  54. - !Install
  55. - mariadb
  56. - mariadb-client
  57. - !EnsureDir /storage
  58. volumes:
  59. <<: *local_volumes
  60. /storage: !Persistent {name: storage_mysql, init-command: _init_db}
  61.  
  62. nginx:
  63. setup:
  64. - !Container _base_alpine
  65. - !Install [nginx]
  66. volumes:
  67. <<: *local_volumes
  68. /var/log/nginx: !Snapshot
  69.  
  70. php:
  71. image-cache-url: https://dl.uwtech.org/vagga/get/${container_name}.${short_hash}.tar.xz
  72. setup:
  73. - !Container _base_alpine
  74. - !Install
  75. - php7@community
  76. - php7-fpm@community
  77. - php7-mysqli@community
  78. - php7-json@community
  79. - php7-ctype@community
  80. - php7-session@community
  81. - php7-zlib@community
  82. - !ComposerDependencies
  83. optimize_autoloader: true
  84. - !EnsureDir /log
  85. - !EnsureDir /storage
  86.  
  87. php-dev:
  88. setup:
  89. - !Container php
  90. volumes:
  91. <<: *local_volumes
  92. /storage: !Persistent {name: storage_php}
  93. /log: !Persistent {name: php_log}
  94. /var/log: !Snapshot
  95.  
  96. mysql-trunk:
  97. setup:
  98. - !Container mysql
  99. - !*Unpack
  100. - *trunk_stuff
  101. - *host_resolution
  102. resolv-conf-path: /state/resolv.conf
  103. hosts-file-path: /state/hosts
  104.  
  105. php-trunk:
  106. setup:
  107. - !Container php
  108. - !AlpineRepo {branch: edge, repo: main, tag: main}
  109. - !AlpineRepo {branch: edge, repo: testing, tag: testing}
  110. - !AlpineRepo {branch: edge, repo: community, tag: community}
  111. - !*Unpack
  112. - *trunk_stuff
  113. - *host_resolution
  114. - !EnsureDir /app
  115. - !Copy
  116. source: /work
  117. path: /app
  118. include-regex: ^(application|content|system)/*
  119. - !Copy
  120. source: /work/index.php
  121. path: /app/index.php
  122. - !Build
  123. container: frontend-trunk
  124. source: /static
  125. temporary-mount: /mnt
  126. - !Copy
  127. source: /mnt/frontend.ver
  128. path: /app/frontend.ver
  129. resolv-conf-path: /state/resolv.conf
  130. hosts-file-path: /state/hosts
  131.  
  132. mysql-production:
  133. setup:
  134. - !Container mysql
  135. - !*Unpack
  136. - *production_stuff
  137. - *host_resolution
  138. resolv-conf-path: /state/resolv.conf
  139. hosts-file-path: /state/hosts
  140.  
  141. php-production:
  142. setup:
  143. - !Container php
  144. - !AlpineRepo {branch: edge, repo: main, tag: main}
  145. - !AlpineRepo {branch: edge, repo: testing, tag: testing}
  146. - !AlpineRepo {branch: edge, repo: community, tag: community}
  147. - !*Unpack
  148. - *production_stuff
  149. - *host_resolution
  150. - !EnsureDir /app
  151. - !Copy
  152. source: /work
  153. path: /app
  154. include-regex: ^(application|content|system)/*
  155. - !Copy
  156. source: /work/index.php
  157. path: /app/index.php
  158. - !Build
  159. container: frontend-production
  160. source: /static
  161. temporary-mount: /mnt
  162. - !Copy
  163. source: /mnt/frontend.ver
  164. path: /app/frontend.ver
  165. resolv-conf-path: /state/resolv.conf
  166. hosts-file-path: /state/hosts
  167. <<:
  168. - !*Include "vagga.trunk.yaml"
  169. - !*Include "vagga.production.yaml"
  170.  
  171. commands:
  172. _init_db: !Command
  173. description: Initialize MySQL database
  174. container: mysql
  175. environ:
  176. DB_HOST: 127.0.0.1
  177. DB_DATABASE: get
  178. DB_USERNAME: get
  179. DB_PASSWORD: get
  180. run: |
  181. mysql_install_db --datadir=/storage
  182. mysqld_safe --defaults-extra-file=/config/mysql/my.cnf --skip-syslog --no-auto-restart
  183. while [ ! -f /tmp/mysqld.pid ]; do sleep 0.1; done
  184. mysqladmin --defaults-extra-file=/config/mysql/my.cnf create $DB_DATABASE
  185. mysql --defaults-extra-file=/config/mysql/my.cnf -e "CREATE USER '$DB_USERNAME'@'$DB_HOST' IDENTIFIED BY '$DB_PASSWORD';"
  186. mysql --defaults-extra-file=/config/mysql/my.cnf -e "GRANT ALL PRIVILEGES ON $DB_DATABASE.* TO '$DB_USERNAME'@'$DB_HOST';"
  187. mysqladmin --defaults-extra-file=/config/mysql/my.cnf flush-privileges
  188. mysqladmin --defaults-extra-file=/config/mysql/my.cnf shutdown
  189.  
  190. mysql: &mysql !Command
  191. container: mysql
  192. description: Run mysql database server
  193. user-id: 1
  194. external-user-id: 0
  195. run: mysqld_safe --defaults-extra-file=/config/mysql/my.cnf --skip-syslog --console --debug-gdb
  196.  
  197. nginx: &nginx !Command
  198. container: nginx
  199. description: Run nginx webserver
  200. run: nginx -c /config/nginx.conf
  201.  
  202. php: &php !Command
  203. container: php-dev
  204. description: Run php-fpm (application)
  205. user-id: 1
  206. external-user-id: 0
  207. run: [php-fpm7, -e, -F, -O, -y, /config/php/php-fpm.conf, -c, /config/php/php.ini]
  208.  
  209. migration: &migration !Command
  210. container: php
  211. description: Run latest migration
  212. run: |
  213. cd /work/
  214. php7 index.php cli migration last
  215.  
  216. _clean-old-static: !Command
  217. container: frontend
  218. description: Clean static files
  219. run: |
  220. mkdir -vp /work/static
  221. rm -rf /work/static/*
  222.  
  223. build-static: !Command
  224. prerequisites: [_clean-old-static]
  225. container: frontend
  226. description: Build static files
  227. run: [npm, run-script, webpack:trunk]
  228.  
  229. watch-static: !Command
  230. prerequisites: [_clean-old-static]
  231. container: frontend
  232. description: Watch and auto-rebuild changed static files
  233. run: [npm, run-script, webpack:watch]
  234.  
  235. run: !Supervise
  236. description: Run full server stack
  237. kill-unresponsive-after: 5
  238. children:
  239. mysql: *mysql
  240. nginx: *nginx
  241. php: *php
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement