smartmachine 0.6.0 → 0.7.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (229) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.rdoc +0 -0
  3. data/README.rdoc +87 -0
  4. data/bin/buildpacker +8 -0
  5. data/bin/prereceiver +8 -0
  6. data/bin/smartmachine +81 -0
  7. data/bin/smartrunner +28 -0
  8. data/lib/smart_machine.rb +24 -0
  9. data/lib/smart_machine/apps.rb +14 -0
  10. data/lib/smart_machine/apps/app.rb +182 -0
  11. data/lib/smart_machine/apps/rails.rb +250 -0
  12. data/lib/smart_machine/base.rb +11 -0
  13. data/lib/smart_machine/boot.rb +31 -0
  14. data/lib/smart_machine/buildpacker.rb +106 -0
  15. data/lib/smart_machine/credentials.rb +126 -0
  16. data/lib/smart_machine/docker.rb +144 -0
  17. data/lib/smart_machine/engine.rb +82 -0
  18. data/lib/smart_machine/engine/Dockerfile +27 -0
  19. data/lib/smart_machine/engine/buildpacks/rails/Dockerfile +21 -0
  20. data/lib/smart_machine/gem_version.rb +17 -0
  21. data/lib/smart_machine/grids.rb +15 -0
  22. data/lib/smart_machine/grids/elasticsearch.rb +97 -0
  23. data/lib/smart_machine/grids/elasticsearch/.keep +0 -0
  24. data/lib/smart_machine/grids/minio.rb +77 -0
  25. data/lib/smart_machine/grids/minio/.keep +0 -0
  26. data/lib/smart_machine/grids/mysql.rb +66 -0
  27. data/lib/smart_machine/grids/mysql/docker-entrypoint-initdb.d/.keep +0 -0
  28. data/lib/smart_machine/grids/nginx.rb +137 -0
  29. data/lib/smart_machine/grids/nginx/.keep +0 -0
  30. data/lib/smart_machine/grids/prereceiver.rb +170 -0
  31. data/lib/smart_machine/grids/prereceiver/Dockerfile +20 -0
  32. data/lib/smart_machine/grids/prereceiver/fcgiwrap/APKBUILD +49 -0
  33. data/lib/smart_machine/grids/prereceiver/fcgiwrap/fcgiwrap.confd +6 -0
  34. data/lib/smart_machine/grids/prereceiver/fcgiwrap/fcgiwrap.initd +43 -0
  35. data/lib/smart_machine/grids/prereceiver/fcgiwrap/fcgiwrap.pre-install +7 -0
  36. data/lib/smart_machine/grids/prereceiver/fcgiwrap/packages/main/x86_64/APKINDEX.tar.gz +0 -0
  37. data/lib/smart_machine/grids/prereceiver/fcgiwrap/packages/main/x86_64/fcgiwrap-1.1.1-r4.apk +0 -0
  38. data/lib/smart_machine/grids/prereceiver/fcgiwrap/packages/main/x86_64/fcgiwrap-doc-1.1.1-r4.apk +0 -0
  39. data/lib/smart_machine/grids/prereceiver/fcgiwrap/packages/main/x86_64/fcgiwrap-openrc-1.1.1-r4.apk +0 -0
  40. data/lib/smart_machine/grids/redis.rb +58 -0
  41. data/lib/smart_machine/grids/redis/.keep +0 -0
  42. data/lib/smart_machine/grids/solr.rb +99 -0
  43. data/lib/smart_machine/grids/solr/config/.keep +0 -0
  44. data/lib/smart_machine/grids/solr/config/README.txt +77 -0
  45. data/lib/smart_machine/grids/solr/config/configsets/_default/conf/lang/contractions_ca.txt +8 -0
  46. data/lib/smart_machine/grids/solr/config/configsets/_default/conf/lang/contractions_fr.txt +15 -0
  47. data/lib/smart_machine/grids/solr/config/configsets/_default/conf/lang/contractions_ga.txt +5 -0
  48. data/lib/smart_machine/grids/solr/config/configsets/_default/conf/lang/contractions_it.txt +23 -0
  49. data/lib/smart_machine/grids/solr/config/configsets/_default/conf/lang/hyphenations_ga.txt +5 -0
  50. data/lib/smart_machine/grids/solr/config/configsets/_default/conf/lang/stemdict_nl.txt +6 -0
  51. data/lib/smart_machine/grids/solr/config/configsets/_default/conf/lang/stoptags_ja.txt +420 -0
  52. data/lib/smart_machine/grids/solr/config/configsets/_default/conf/lang/stopwords_ar.txt +125 -0
  53. data/lib/smart_machine/grids/solr/config/configsets/_default/conf/lang/stopwords_bg.txt +193 -0
  54. data/lib/smart_machine/grids/solr/config/configsets/_default/conf/lang/stopwords_ca.txt +220 -0
  55. data/lib/smart_machine/grids/solr/config/configsets/_default/conf/lang/stopwords_cz.txt +172 -0
  56. data/lib/smart_machine/grids/solr/config/configsets/_default/conf/lang/stopwords_da.txt +110 -0
  57. data/lib/smart_machine/grids/solr/config/configsets/_default/conf/lang/stopwords_de.txt +294 -0
  58. data/lib/smart_machine/grids/solr/config/configsets/_default/conf/lang/stopwords_el.txt +78 -0
  59. data/lib/smart_machine/grids/solr/config/configsets/_default/conf/lang/stopwords_en.txt +54 -0
  60. data/lib/smart_machine/grids/solr/config/configsets/_default/conf/lang/stopwords_es.txt +356 -0
  61. data/lib/smart_machine/grids/solr/config/configsets/_default/conf/lang/stopwords_eu.txt +99 -0
  62. data/lib/smart_machine/grids/solr/config/configsets/_default/conf/lang/stopwords_fa.txt +313 -0
  63. data/lib/smart_machine/grids/solr/config/configsets/_default/conf/lang/stopwords_fi.txt +97 -0
  64. data/lib/smart_machine/grids/solr/config/configsets/_default/conf/lang/stopwords_fr.txt +186 -0
  65. data/lib/smart_machine/grids/solr/config/configsets/_default/conf/lang/stopwords_ga.txt +110 -0
  66. data/lib/smart_machine/grids/solr/config/configsets/_default/conf/lang/stopwords_gl.txt +161 -0
  67. data/lib/smart_machine/grids/solr/config/configsets/_default/conf/lang/stopwords_hi.txt +235 -0
  68. data/lib/smart_machine/grids/solr/config/configsets/_default/conf/lang/stopwords_hu.txt +211 -0
  69. data/lib/smart_machine/grids/solr/config/configsets/_default/conf/lang/stopwords_hy.txt +46 -0
  70. data/lib/smart_machine/grids/solr/config/configsets/_default/conf/lang/stopwords_id.txt +359 -0
  71. data/lib/smart_machine/grids/solr/config/configsets/_default/conf/lang/stopwords_it.txt +303 -0
  72. data/lib/smart_machine/grids/solr/config/configsets/_default/conf/lang/stopwords_ja.txt +127 -0
  73. data/lib/smart_machine/grids/solr/config/configsets/_default/conf/lang/stopwords_lv.txt +172 -0
  74. data/lib/smart_machine/grids/solr/config/configsets/_default/conf/lang/stopwords_nl.txt +119 -0
  75. data/lib/smart_machine/grids/solr/config/configsets/_default/conf/lang/stopwords_no.txt +194 -0
  76. data/lib/smart_machine/grids/solr/config/configsets/_default/conf/lang/stopwords_pt.txt +253 -0
  77. data/lib/smart_machine/grids/solr/config/configsets/_default/conf/lang/stopwords_ro.txt +233 -0
  78. data/lib/smart_machine/grids/solr/config/configsets/_default/conf/lang/stopwords_ru.txt +243 -0
  79. data/lib/smart_machine/grids/solr/config/configsets/_default/conf/lang/stopwords_sv.txt +133 -0
  80. data/lib/smart_machine/grids/solr/config/configsets/_default/conf/lang/stopwords_th.txt +119 -0
  81. data/lib/smart_machine/grids/solr/config/configsets/_default/conf/lang/stopwords_tr.txt +212 -0
  82. data/lib/smart_machine/grids/solr/config/configsets/_default/conf/lang/userdict_ja.txt +29 -0
  83. data/lib/smart_machine/grids/solr/config/configsets/_default/conf/managed-schema +1007 -0
  84. data/lib/smart_machine/grids/solr/config/configsets/_default/conf/params.json +20 -0
  85. data/lib/smart_machine/grids/solr/config/configsets/_default/conf/protwords.txt +21 -0
  86. data/lib/smart_machine/grids/solr/config/configsets/_default/conf/solrconfig.xml +1355 -0
  87. data/lib/smart_machine/grids/solr/config/configsets/_default/conf/stopwords.txt +14 -0
  88. data/lib/smart_machine/grids/solr/config/configsets/_default/conf/synonyms.txt +29 -0
  89. data/lib/smart_machine/grids/solr/config/configsets/sample_techproducts_configs/conf/_rest_managed.json +1 -0
  90. data/lib/smart_machine/grids/solr/config/configsets/sample_techproducts_configs/conf/_schema_analysis_stopwords_english.json +38 -0
  91. data/lib/smart_machine/grids/solr/config/configsets/sample_techproducts_configs/conf/_schema_analysis_synonyms_english.json +11 -0
  92. data/lib/smart_machine/grids/solr/config/configsets/sample_techproducts_configs/conf/clustering/carrot2/README.txt +11 -0
  93. data/lib/smart_machine/grids/solr/config/configsets/sample_techproducts_configs/conf/clustering/carrot2/kmeans-attributes.xml +19 -0
  94. data/lib/smart_machine/grids/solr/config/configsets/sample_techproducts_configs/conf/clustering/carrot2/lingo-attributes.xml +24 -0
  95. data/lib/smart_machine/grids/solr/config/configsets/sample_techproducts_configs/conf/clustering/carrot2/stc-attributes.xml +19 -0
  96. data/lib/smart_machine/grids/solr/config/configsets/sample_techproducts_configs/conf/currency.xml +67 -0
  97. data/lib/smart_machine/grids/solr/config/configsets/sample_techproducts_configs/conf/elevate.xml +42 -0
  98. data/lib/smart_machine/grids/solr/config/configsets/sample_techproducts_configs/conf/lang/contractions_ca.txt +8 -0
  99. data/lib/smart_machine/grids/solr/config/configsets/sample_techproducts_configs/conf/lang/contractions_fr.txt +15 -0
  100. data/lib/smart_machine/grids/solr/config/configsets/sample_techproducts_configs/conf/lang/contractions_ga.txt +5 -0
  101. data/lib/smart_machine/grids/solr/config/configsets/sample_techproducts_configs/conf/lang/contractions_it.txt +23 -0
  102. data/lib/smart_machine/grids/solr/config/configsets/sample_techproducts_configs/conf/lang/hyphenations_ga.txt +5 -0
  103. data/lib/smart_machine/grids/solr/config/configsets/sample_techproducts_configs/conf/lang/stemdict_nl.txt +6 -0
  104. data/lib/smart_machine/grids/solr/config/configsets/sample_techproducts_configs/conf/lang/stoptags_ja.txt +420 -0
  105. data/lib/smart_machine/grids/solr/config/configsets/sample_techproducts_configs/conf/lang/stopwords_ar.txt +125 -0
  106. data/lib/smart_machine/grids/solr/config/configsets/sample_techproducts_configs/conf/lang/stopwords_bg.txt +193 -0
  107. data/lib/smart_machine/grids/solr/config/configsets/sample_techproducts_configs/conf/lang/stopwords_ca.txt +220 -0
  108. data/lib/smart_machine/grids/solr/config/configsets/sample_techproducts_configs/conf/lang/stopwords_ckb.txt +136 -0
  109. data/lib/smart_machine/grids/solr/config/configsets/sample_techproducts_configs/conf/lang/stopwords_cz.txt +172 -0
  110. data/lib/smart_machine/grids/solr/config/configsets/sample_techproducts_configs/conf/lang/stopwords_da.txt +110 -0
  111. data/lib/smart_machine/grids/solr/config/configsets/sample_techproducts_configs/conf/lang/stopwords_de.txt +294 -0
  112. data/lib/smart_machine/grids/solr/config/configsets/sample_techproducts_configs/conf/lang/stopwords_el.txt +78 -0
  113. data/lib/smart_machine/grids/solr/config/configsets/sample_techproducts_configs/conf/lang/stopwords_en.txt +54 -0
  114. data/lib/smart_machine/grids/solr/config/configsets/sample_techproducts_configs/conf/lang/stopwords_es.txt +356 -0
  115. data/lib/smart_machine/grids/solr/config/configsets/sample_techproducts_configs/conf/lang/stopwords_eu.txt +99 -0
  116. data/lib/smart_machine/grids/solr/config/configsets/sample_techproducts_configs/conf/lang/stopwords_fa.txt +313 -0
  117. data/lib/smart_machine/grids/solr/config/configsets/sample_techproducts_configs/conf/lang/stopwords_fi.txt +97 -0
  118. data/lib/smart_machine/grids/solr/config/configsets/sample_techproducts_configs/conf/lang/stopwords_fr.txt +186 -0
  119. data/lib/smart_machine/grids/solr/config/configsets/sample_techproducts_configs/conf/lang/stopwords_ga.txt +110 -0
  120. data/lib/smart_machine/grids/solr/config/configsets/sample_techproducts_configs/conf/lang/stopwords_gl.txt +161 -0
  121. data/lib/smart_machine/grids/solr/config/configsets/sample_techproducts_configs/conf/lang/stopwords_hi.txt +235 -0
  122. data/lib/smart_machine/grids/solr/config/configsets/sample_techproducts_configs/conf/lang/stopwords_hu.txt +211 -0
  123. data/lib/smart_machine/grids/solr/config/configsets/sample_techproducts_configs/conf/lang/stopwords_hy.txt +46 -0
  124. data/lib/smart_machine/grids/solr/config/configsets/sample_techproducts_configs/conf/lang/stopwords_id.txt +359 -0
  125. data/lib/smart_machine/grids/solr/config/configsets/sample_techproducts_configs/conf/lang/stopwords_it.txt +303 -0
  126. data/lib/smart_machine/grids/solr/config/configsets/sample_techproducts_configs/conf/lang/stopwords_ja.txt +127 -0
  127. data/lib/smart_machine/grids/solr/config/configsets/sample_techproducts_configs/conf/lang/stopwords_lv.txt +172 -0
  128. data/lib/smart_machine/grids/solr/config/configsets/sample_techproducts_configs/conf/lang/stopwords_nl.txt +119 -0
  129. data/lib/smart_machine/grids/solr/config/configsets/sample_techproducts_configs/conf/lang/stopwords_no.txt +194 -0
  130. data/lib/smart_machine/grids/solr/config/configsets/sample_techproducts_configs/conf/lang/stopwords_pt.txt +253 -0
  131. data/lib/smart_machine/grids/solr/config/configsets/sample_techproducts_configs/conf/lang/stopwords_ro.txt +233 -0
  132. data/lib/smart_machine/grids/solr/config/configsets/sample_techproducts_configs/conf/lang/stopwords_ru.txt +243 -0
  133. data/lib/smart_machine/grids/solr/config/configsets/sample_techproducts_configs/conf/lang/stopwords_sv.txt +133 -0
  134. data/lib/smart_machine/grids/solr/config/configsets/sample_techproducts_configs/conf/lang/stopwords_th.txt +119 -0
  135. data/lib/smart_machine/grids/solr/config/configsets/sample_techproducts_configs/conf/lang/stopwords_tr.txt +212 -0
  136. data/lib/smart_machine/grids/solr/config/configsets/sample_techproducts_configs/conf/lang/userdict_ja.txt +29 -0
  137. data/lib/smart_machine/grids/solr/config/configsets/sample_techproducts_configs/conf/managed-schema +1187 -0
  138. data/lib/smart_machine/grids/solr/config/configsets/sample_techproducts_configs/conf/mapping-FoldToASCII.txt +3813 -0
  139. data/lib/smart_machine/grids/solr/config/configsets/sample_techproducts_configs/conf/mapping-ISOLatin1Accent.txt +246 -0
  140. data/lib/smart_machine/grids/solr/config/configsets/sample_techproducts_configs/conf/params.json +11 -0
  141. data/lib/smart_machine/grids/solr/config/configsets/sample_techproducts_configs/conf/protwords.txt +21 -0
  142. data/lib/smart_machine/grids/solr/config/configsets/sample_techproducts_configs/conf/solrconfig.xml +1616 -0
  143. data/lib/smart_machine/grids/solr/config/configsets/sample_techproducts_configs/conf/spellings.txt +2 -0
  144. data/lib/smart_machine/grids/solr/config/configsets/sample_techproducts_configs/conf/stopwords.txt +14 -0
  145. data/lib/smart_machine/grids/solr/config/configsets/sample_techproducts_configs/conf/synonyms.txt +29 -0
  146. data/lib/smart_machine/grids/solr/config/configsets/sample_techproducts_configs/conf/update-script.js +53 -0
  147. data/lib/smart_machine/grids/solr/config/configsets/sample_techproducts_configs/conf/velocity/README.txt +101 -0
  148. data/lib/smart_machine/grids/solr/config/configsets/sample_techproducts_configs/conf/velocity/VM_global_library.vm +186 -0
  149. data/lib/smart_machine/grids/solr/config/configsets/sample_techproducts_configs/conf/velocity/browse.vm +33 -0
  150. data/lib/smart_machine/grids/solr/config/configsets/sample_techproducts_configs/conf/velocity/cluster.vm +19 -0
  151. data/lib/smart_machine/grids/solr/config/configsets/sample_techproducts_configs/conf/velocity/cluster_results.vm +31 -0
  152. data/lib/smart_machine/grids/solr/config/configsets/sample_techproducts_configs/conf/velocity/debug.vm +28 -0
  153. data/lib/smart_machine/grids/solr/config/configsets/sample_techproducts_configs/conf/velocity/did_you_mean.vm +11 -0
  154. data/lib/smart_machine/grids/solr/config/configsets/sample_techproducts_configs/conf/velocity/error.vm +11 -0
  155. data/lib/smart_machine/grids/solr/config/configsets/sample_techproducts_configs/conf/velocity/facet_fields.vm +24 -0
  156. data/lib/smart_machine/grids/solr/config/configsets/sample_techproducts_configs/conf/velocity/facet_pivot.vm +12 -0
  157. data/lib/smart_machine/grids/solr/config/configsets/sample_techproducts_configs/conf/velocity/facet_queries.vm +12 -0
  158. data/lib/smart_machine/grids/solr/config/configsets/sample_techproducts_configs/conf/velocity/facet_ranges.vm +23 -0
  159. data/lib/smart_machine/grids/solr/config/configsets/sample_techproducts_configs/conf/velocity/facets.vm +10 -0
  160. data/lib/smart_machine/grids/solr/config/configsets/sample_techproducts_configs/conf/velocity/footer.vm +43 -0
  161. data/lib/smart_machine/grids/solr/config/configsets/sample_techproducts_configs/conf/velocity/head.vm +37 -0
  162. data/lib/smart_machine/grids/solr/config/configsets/sample_techproducts_configs/conf/velocity/header.vm +7 -0
  163. data/lib/smart_machine/grids/solr/config/configsets/sample_techproducts_configs/conf/velocity/hit.vm +25 -0
  164. data/lib/smart_machine/grids/solr/config/configsets/sample_techproducts_configs/conf/velocity/hit_grouped.vm +43 -0
  165. data/lib/smart_machine/grids/solr/config/configsets/sample_techproducts_configs/conf/velocity/hit_plain.vm +25 -0
  166. data/lib/smart_machine/grids/solr/config/configsets/sample_techproducts_configs/conf/velocity/join_doc.vm +20 -0
  167. data/lib/smart_machine/grids/solr/config/configsets/sample_techproducts_configs/conf/velocity/jquery.autocomplete.css +48 -0
  168. data/lib/smart_machine/grids/solr/config/configsets/sample_techproducts_configs/conf/velocity/jquery.autocomplete.js +763 -0
  169. data/lib/smart_machine/grids/solr/config/configsets/sample_techproducts_configs/conf/velocity/layout.vm +24 -0
  170. data/lib/smart_machine/grids/solr/config/configsets/sample_techproducts_configs/conf/velocity/main.css +231 -0
  171. data/lib/smart_machine/grids/solr/config/configsets/sample_techproducts_configs/conf/velocity/mime_type_lists.vm +68 -0
  172. data/lib/smart_machine/grids/solr/config/configsets/sample_techproducts_configs/conf/velocity/pagination_bottom.vm +22 -0
  173. data/lib/smart_machine/grids/solr/config/configsets/sample_techproducts_configs/conf/velocity/pagination_top.vm +29 -0
  174. data/lib/smart_machine/grids/solr/config/configsets/sample_techproducts_configs/conf/velocity/product_doc.vm +32 -0
  175. data/lib/smart_machine/grids/solr/config/configsets/sample_techproducts_configs/conf/velocity/query.vm +42 -0
  176. data/lib/smart_machine/grids/solr/config/configsets/sample_techproducts_configs/conf/velocity/query_form.vm +64 -0
  177. data/lib/smart_machine/grids/solr/config/configsets/sample_techproducts_configs/conf/velocity/query_group.vm +43 -0
  178. data/lib/smart_machine/grids/solr/config/configsets/sample_techproducts_configs/conf/velocity/query_spatial.vm +75 -0
  179. data/lib/smart_machine/grids/solr/config/configsets/sample_techproducts_configs/conf/velocity/results_list.vm +22 -0
  180. data/lib/smart_machine/grids/solr/config/configsets/sample_techproducts_configs/conf/velocity/richtext_doc.vm +153 -0
  181. data/lib/smart_machine/grids/solr/config/configsets/sample_techproducts_configs/conf/velocity/suggest.vm +8 -0
  182. data/lib/smart_machine/grids/solr/config/configsets/sample_techproducts_configs/conf/velocity/tabs.vm +50 -0
  183. data/lib/smart_machine/grids/solr/config/configsets/sample_techproducts_configs/conf/xslt/example.xsl +132 -0
  184. data/lib/smart_machine/grids/solr/config/configsets/sample_techproducts_configs/conf/xslt/example_atom.xsl +67 -0
  185. data/lib/smart_machine/grids/solr/config/configsets/sample_techproducts_configs/conf/xslt/example_rss.xsl +66 -0
  186. data/lib/smart_machine/grids/solr/config/configsets/sample_techproducts_configs/conf/xslt/luke.xsl +337 -0
  187. data/lib/smart_machine/grids/solr/config/configsets/sample_techproducts_configs/conf/xslt/updateXml.xsl +70 -0
  188. data/lib/smart_machine/grids/solr/config/configsets/sunspot/conf/_rest_managed.json +1 -0
  189. data/lib/smart_machine/grids/solr/config/configsets/sunspot/conf/admin-extra.html +31 -0
  190. data/lib/smart_machine/grids/solr/config/configsets/sunspot/conf/currency.xml +67 -0
  191. data/lib/smart_machine/grids/solr/config/configsets/sunspot/conf/elevate.xml +36 -0
  192. data/lib/smart_machine/grids/solr/config/configsets/sunspot/conf/lang/stopwords_en.txt +54 -0
  193. data/lib/smart_machine/grids/solr/config/configsets/sunspot/conf/mapping-ISOLatin1Accent.txt +246 -0
  194. data/lib/smart_machine/grids/solr/config/configsets/sunspot/conf/protwords.txt +21 -0
  195. data/lib/smart_machine/grids/solr/config/configsets/sunspot/conf/schema.xml +278 -0
  196. data/lib/smart_machine/grids/solr/config/configsets/sunspot/conf/scripts.conf +24 -0
  197. data/lib/smart_machine/grids/solr/config/configsets/sunspot/conf/solrconfig.xml +632 -0
  198. data/lib/smart_machine/grids/solr/config/configsets/sunspot/conf/spellings.txt +2 -0
  199. data/lib/smart_machine/grids/solr/config/configsets/sunspot/conf/synonyms.txt +29 -0
  200. data/lib/smart_machine/grids/solr/config/lib/.keep +0 -0
  201. data/lib/smart_machine/grids/solr/config/solr.xml +53 -0
  202. data/lib/smart_machine/grids/solr/config/zoo.cfg +31 -0
  203. data/lib/smart_machine/grids/solr/docker-entrypoint-initdb.d/.keep +0 -0
  204. data/lib/smart_machine/grids/solr/sunspot/conf/schema.xml +278 -0
  205. data/lib/smart_machine/grids/solr/sunspot/conf/solrconfig.xml +632 -0
  206. data/lib/smart_machine/logger.rb +35 -0
  207. data/lib/smart_machine/machine.rb +192 -0
  208. data/lib/smart_machine/ssh.rb +43 -0
  209. data/lib/smart_machine/sync.rb +108 -0
  210. data/lib/smart_machine/templates/dotsmartmachine/apps/containers/.keep +0 -0
  211. data/lib/smart_machine/templates/dotsmartmachine/apps/repositories/.keep +0 -0
  212. data/lib/smart_machine/templates/dotsmartmachine/config/environment.rb +18 -0
  213. data/lib/smart_machine/templates/dotsmartmachine/config/users.yml +4 -0
  214. data/lib/smart_machine/templates/dotsmartmachine/grids/elasticsearch/data/.keep +0 -0
  215. data/lib/smart_machine/templates/dotsmartmachine/grids/elasticsearch/logs/.keep +0 -0
  216. data/lib/smart_machine/templates/dotsmartmachine/grids/minio/data/.keep +0 -0
  217. data/lib/smart_machine/templates/dotsmartmachine/grids/mysql/data/.keep +0 -0
  218. data/lib/smart_machine/templates/dotsmartmachine/grids/nginx/certificates/.keep +0 -0
  219. data/lib/smart_machine/templates/dotsmartmachine/grids/nginx/fastcgi.conf +11 -0
  220. data/lib/smart_machine/templates/dotsmartmachine/grids/nginx/htpasswd/.keep +0 -0
  221. data/lib/smart_machine/templates/dotsmartmachine/grids/nginx/nginx.tmpl +373 -0
  222. data/lib/smart_machine/templates/dotsmartmachine/grids/prereceiver/pre-receive +17 -0
  223. data/lib/smart_machine/templates/dotsmartmachine/grids/redis/data/.keep +0 -0
  224. data/lib/smart_machine/templates/dotsmartmachine/grids/solr/solr/.keep +0 -0
  225. data/lib/smart_machine/templates/dotsmartmachine/tmp/.keep +0 -0
  226. data/lib/smart_machine/user.rb +38 -0
  227. data/lib/smart_machine/version.rb +10 -0
  228. metadata +297 -12
  229. data/README.md +0 -9
@@ -0,0 +1,144 @@
1
+ # The main SmartMachine Docker driver
2
+ module SmartMachine
3
+ class Docker < SmartMachine::Base
4
+ def initialize
5
+ end
6
+
7
+ # Installing Docker!
8
+ #
9
+ # Example:
10
+ # => Installation Complete
11
+ #
12
+ # Arguments:
13
+ # none
14
+ def install
15
+ puts "-----> Installing Docker"
16
+
17
+ ssh = SmartMachine::SSH.new
18
+
19
+ print "-----> Installing Docker Engine ... "
20
+ commands = [
21
+ "sudo apt-get -y update",
22
+ "sudo apt-get -y install apt-transport-https ca-certificates curl software-properties-common",
23
+ "curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -",
24
+ "sudo apt-key fingerprint 0EBFCD88",
25
+ "sudo add-apt-repository \"deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable\"",
26
+ "sudo apt-get -y update",
27
+ "sudo apt-get -y install docker-ce",
28
+ "sudo usermod -aG docker $USER",
29
+ "docker run --rm hello-world",
30
+ "docker rmi hello-world"
31
+ ]
32
+ ssh.run commands
33
+ puts "done"
34
+
35
+ print "-----> Installing Docker Compose ... "
36
+ commands = [
37
+ "sudo curl -L --fail https://github.com/docker/compose/releases/download/1.24.0/run.sh -o /usr/local/bin/docker-compose",
38
+ "sudo chmod +x /usr/local/bin/docker-compose",
39
+ "docker-compose --version",
40
+ "sudo curl -L https://raw.githubusercontent.com/docker/compose/1.24.0/contrib/completion/bash/docker-compose -o /etc/bash_completion.d/docker-compose"
41
+ ]
42
+ ssh.run commands
43
+ puts "done"
44
+
45
+ self.add_ufw_rules
46
+
47
+ puts "-----> Docker Installation Complete"
48
+ end
49
+
50
+ # Uninstalling Docker!
51
+ #
52
+ # Example:
53
+ # => Uninstallation Complete
54
+ #
55
+ # Arguments:
56
+ # none
57
+ def uninstall
58
+ puts "-----> Uninstalling Docker"
59
+
60
+ ssh = SmartMachine::SSH.new
61
+
62
+ print "-----> Uninstalling Docker Compose ... "
63
+ commands = ["sudo rm /usr/local/bin/docker-compose"]
64
+ ssh.run commands
65
+ puts "done"
66
+
67
+ print "-----> Uninstalling Docker Engine ... "
68
+ commands = ["sudo apt-get purge docker-ce", "sudo rm -rf /var/lib/docker"]
69
+ ssh.run commands
70
+ puts "done"
71
+
72
+ self.remove_ufw_rules
73
+
74
+ puts "-----> You must delete any edited configuration files manually."
75
+
76
+ puts "-----> Docker Uninstallation Complete"
77
+ end
78
+
79
+ def update
80
+ end
81
+
82
+ def add_ufw_rules
83
+ puts '-----> Add the following rules to the end of the file /etc/ufw/after.rules and reload ufw using - sudo ufw reload'
84
+ puts '# BEGIN UFW AND DOCKER
85
+ *filter
86
+ :ufw-user-forward - [0:0]
87
+ :DOCKER-USER - [0:0]
88
+ -A DOCKER-USER -m conntrack --ctstate RELATED,ESTABLISHED -j ACCEPT
89
+ -A DOCKER-USER -m conntrack --ctstate INVALID -j DROP
90
+ -A DOCKER-USER -i eth0 -j ufw-user-forward
91
+ -A DOCKER-USER -i eth0 -j DROP
92
+ COMMIT
93
+ # END UFW AND DOCKER'
94
+
95
+ # puts "-----> Adding UFW rules for Docker"
96
+ # interface_name = system("ip route show | sed -e 's/^default via [0-9.]* dev \(\w\+\).*/\1/'")
97
+ # puts interface_name
98
+
99
+ # system("sed '/^# BEGIN UFW AND DOCKER/,/^# END UFW AND DOCKER/d' '/etc/ufw/after.rules'")
100
+ # system("sudo tee -a '/etc/ufw/after.rules' > /dev/null <<EOT
101
+ # # BEGIN UFW AND DOCKER
102
+ # *filter
103
+ # :ufw-user-forward - [0:0]
104
+ # :DOCKER-USER - [0:0]
105
+ # -A DOCKER-USER -m conntrack --ctstate RELATED,ESTABLISHED -j ACCEPT
106
+ # -A DOCKER-USER -m conntrack --ctstate INVALID -j DROP
107
+ # -A DOCKER-USER -i eth0 -j ufw-user-forward
108
+ # -A DOCKER-USER -i eth0 -j DROP
109
+ # COMMIT
110
+ # # END UFW AND DOCKER
111
+ # EOT")
112
+ # system("sudo ufw reload")
113
+ end
114
+
115
+ def remove_ufw_rules
116
+ puts '-----> Remove the following rules at the end of the file /etc/ufw/after.rules and reload ufw using - sudo ufw reload'
117
+ puts '# BEGIN UFW AND DOCKER
118
+ *filter
119
+ :ufw-user-forward - [0:0]
120
+ :DOCKER-USER - [0:0]
121
+ -A DOCKER-USER -m conntrack --ctstate RELATED,ESTABLISHED -j ACCEPT
122
+ -A DOCKER-USER -m conntrack --ctstate INVALID -j DROP
123
+ -A DOCKER-USER -i eth0 -j ufw-user-forward
124
+ -A DOCKER-USER -i eth0 -j DROP
125
+ COMMIT
126
+ # END UFW AND DOCKER'
127
+
128
+ # puts "-----> Removing UFW rules for Docker"
129
+ # system("sed '/^# BEGIN UFW AND DOCKER/,/^# END UFW AND DOCKER/d' '/etc/ufw/after.rules'")
130
+ # system("sudo ufw reload")
131
+ end
132
+
133
+ # Below methods are non ssh methods and should be executed on the server only.
134
+
135
+ def self.running?
136
+ if system("docker info", [:out, :err] => File::NULL)
137
+ true
138
+ else
139
+ puts "Error: Docker daemon is not running. Have you installed docker? Please ensure docker daemon is running and try again."
140
+ false
141
+ end
142
+ end
143
+ end
144
+ end
@@ -0,0 +1,82 @@
1
+ # The main SmartMachine Engine driver
2
+ module SmartMachine
3
+ class Engine < SmartMachine::Base
4
+ def initialize
5
+ end
6
+
7
+ def install
8
+ puts "-----> Installing SmartMachine Engine"
9
+
10
+ SmartMachine::User.create_htpasswd_files
11
+
12
+ ssh = SmartMachine::SSH.new
13
+ machine = SmartMachine::Machine.new
14
+ sync = SmartMachine::Sync.new
15
+
16
+ system("mkdir -p ./tmp/engine")
17
+ system("cp #{SmartMachine.config.root_path}/lib/smart_machine/engine/Dockerfile ./tmp/engine/Dockerfile")
18
+
19
+ gem_file_path = File.expand_path("../../cache/smartmachine-#{SmartMachine.version}.gem", SmartMachine.config.root_path)
20
+ system("cp #{gem_file_path} ./tmp/engine/smartmachine-#{SmartMachine.version}.gem")
21
+
22
+ sync.run only: :push
23
+
24
+ print "-----> Creating image for SmartMachine ... "
25
+ ssh.run "docker image build --quiet --tag #{engine_image_name} \
26
+ --build-arg SMARTMACHINE_MASTER_KEY=#{SmartMachine::Credentials.new.read_key} \
27
+ --build-arg SMARTMACHINE_VERSION=#{SmartMachine.version} \
28
+ --build-arg USER_NAME=`id -un` \
29
+ --build-arg USER_UID=`id -u` \
30
+ --build-arg DOCKER_GID=`getent group docker | cut -d: -f3` \
31
+ ~/.smartmachine/tmp/engine"
32
+ puts "done"
33
+
34
+ print "-----> Adding SmartMachine to PATH ... "
35
+ ssh.run "mkdir -p ~/.smartmachine/bin && touch ~/.smartmachine/bin/smartmachine.sh"
36
+ ssh.run "echo '#{smartmachine_binary_template}' > ~/.smartmachine/bin/smartmachine.sh"
37
+ ssh.run "chmod +x ~/.smartmachine/bin/smartmachine.sh && sudo ln -sf ~/.smartmachine/bin/smartmachine.sh /usr/local/bin/smartmachine"
38
+ puts "done"
39
+
40
+ system("rm ./tmp/engine/Dockerfile")
41
+ system("rm ./tmp/engine/smartmachine-#{SmartMachine.version}.gem")
42
+
43
+ sync.run
44
+
45
+ puts "-----> SmartMachine Engine Installation Complete"
46
+ end
47
+
48
+ def uninstall
49
+ puts "-----> Uninstalling SmartMachine Engine"
50
+
51
+ ssh = SmartMachine::SSH.new
52
+
53
+ ssh.run "sudo rm /usr/local/bin/smartmachine"
54
+ ssh.run "docker rmi $(docker images -q smartmachine)"
55
+
56
+ puts "-----> SmartMachine Engine Uninstallation Complete"
57
+ end
58
+
59
+ def update
60
+ self.uninstall
61
+ self.install
62
+ end
63
+
64
+ def smartmachine_binary_template
65
+ <<~BASH
66
+ #!/bin/bash
67
+
68
+ docker run -it --rm \
69
+ -v "/home/$(whoami)/.smartmachine:/home/$(whoami)/.smartmachine" \
70
+ -v "/var/run/docker.sock:/var/run/docker.sock" \
71
+ -w "/home/$(whoami)/.smartmachine" \
72
+ -u `id -u` \
73
+ --entrypoint "smartmachine" \
74
+ #{engine_image_name} "$@"
75
+ BASH
76
+ end
77
+
78
+ def engine_image_name
79
+ "smartmachine:#{SmartMachine.version}"
80
+ end
81
+ end
82
+ end
@@ -0,0 +1,27 @@
1
+ FROM ruby:2.7.0-alpine3.11
2
+ LABEL maintainer="Timeboard <hello@timeboard.me>"
3
+
4
+ # User
5
+ # --- Fix to change gid of 999 to 99 so that addgroup is free to create a group with 999 as gid
6
+ ARG USER_NAME
7
+ ARG USER_UID
8
+ ARG DOCKER_GID
9
+ RUN sed -i "s/999/99/" /etc/group && \
10
+ adduser --disabled-password --gecos "" --uid "$USER_UID" "$USER_NAME" && \
11
+ addgroup --gid "$DOCKER_GID" "docker" && adduser "$USER_NAME" "docker"
12
+
13
+ # Essentials
14
+ RUN apk add --update build-base && \
15
+ apk add --update docker && \
16
+ apk add --update git && \
17
+ rm -rf /var/cache/apk/*
18
+
19
+ # smartmachine gem
20
+ ARG SMARTMACHINE_VERSION
21
+ COPY ./smartmachine-$SMARTMACHINE_VERSION.gem ./smartmachine-$SMARTMACHINE_VERSION.gem
22
+ RUN gem install --no-document smartmachine-$SMARTMACHINE_VERSION.gem && \
23
+ rm ./smartmachine-$SMARTMACHINE_VERSION.gem
24
+
25
+ # smartmachine master key
26
+ ARG SMARTMACHINE_MASTER_KEY
27
+ ENV SMARTMACHINE_MASTER_KEY=$SMARTMACHINE_MASTER_KEY
@@ -0,0 +1,21 @@
1
+ ARG SMARTMACHINE_VERSION
2
+
3
+ FROM smartmachine:$SMARTMACHINE_VERSION
4
+ LABEL maintainer="Timeboard <hello@timeboard.me>"
5
+
6
+ # Ruby on Rails Essentials
7
+ RUN apk add --update build-base && \
8
+ apk add --update tzdata && \
9
+ apk add --update nodejs && \
10
+ apk add --update yarn && \
11
+ apk add --update mariadb-dev && \
12
+ apk add --update imagemagick && \
13
+ apk add --update ffmpeg && \
14
+ apk add --update mupdf && \
15
+ apk add --update mupdf-tools && \
16
+ rm -rf /var/cache/apk/*
17
+
18
+ # Gems
19
+ RUN gem install bundler -v 2.1.4
20
+
21
+ CMD ["buildpacker", "pack"]
@@ -0,0 +1,17 @@
1
+ # frozen_string_literal: true
2
+
3
+ module SmartMachine
4
+ # Returns the version of the currently loaded SmartMachine as a <tt>Gem::Version</tt>.
5
+ def self.gem_version
6
+ Gem::Version.new VERSION::STRING
7
+ end
8
+
9
+ module VERSION
10
+ MAJOR = 0
11
+ MINOR = 7
12
+ TINY = 0
13
+ PRE = nil
14
+
15
+ STRING = [MAJOR, MINOR, TINY, PRE].compact.join(".")
16
+ end
17
+ end
@@ -0,0 +1,15 @@
1
+ # The main SmartMachine Grids
2
+ module SmartMachine
3
+ class Grids < SmartMachine::Base
4
+ def run(*args)
5
+ args.flatten!
6
+
7
+ grid_name = args.shift
8
+ action = args.shift
9
+
10
+ raise "invalid action on the grid" unless ['up', 'down'].include? action
11
+
12
+ Object.const_get("SmartMachine::Grids::#{grid_name.capitalize}").new.public_send(action, *args)
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,97 @@
1
+ # The main SmartMachine Grids Elasticsearch driver
2
+ module SmartMachine
3
+ class Grids
4
+ class Elasticsearch < SmartMachine::Base
5
+ def initialize
6
+ end
7
+
8
+ def install
9
+ puts "-----> Installing Elasticsearch"
10
+
11
+ print "-----> Creating settings for elasticsearch ... "
12
+ ssh = SmartMachine::SSH.new
13
+ ssh.run "echo 'vm.max_map_count=262144' | sudo tee /etc/sysctl.d/60-smartmachine-elasticsearch.conf && sudo sysctl --system"
14
+ puts "done"
15
+
16
+ puts "-----> Elasticsearch Installation Complete"
17
+ end
18
+
19
+ def uninstall
20
+ puts "-----> Uninstalling Elasticsearch"
21
+
22
+ print "-----> Removing settings for elasticsearch ... "
23
+ ssh = SmartMachine::SSH.new
24
+ # NOTE: sysctl does not reset this setting until restart of system even after sudo sysctl --system is run.
25
+ ssh.run "test -f /etc/sysctl.d/60-smartmachine-elasticsearch.conf && sudo rm /etc/sysctl.d/60-smartmachine-elasticsearch.conf && sudo sysctl --system"
26
+ puts "done"
27
+
28
+ puts "-----> Elasticsearch Uninstallation Complete"
29
+ end
30
+
31
+ def update
32
+ self.uninstall
33
+ self.install
34
+ end
35
+
36
+ def up(*args)
37
+ args.flatten!
38
+ exposed = args.empty? ? '' : args.shift
39
+
40
+ if SmartMachine::Docker.running?
41
+ # Creating networks
42
+ unless system("docker network inspect elasticsearch-network", [:out, :err] => File::NULL)
43
+ print "-----> Creating network elasticsearch-network ... "
44
+ if system("docker network create elasticsearch-network", out: File::NULL)
45
+ puts "done"
46
+ end
47
+ end
48
+
49
+ # Creating & Starting containers
50
+ print "-----> Creating container elasticsearch ... "
51
+ if system("docker create \
52
+ --name='elasticsearch' \
53
+ --env discovery.type=single-node \
54
+ --env cluster.name=elasticsearch-cluster \
55
+ --env 'ES_JAVA_OPTS=-Xms512m -Xmx512m -Des.enforce.bootstrap.checks=true' \
56
+ --env bootstrap.memory_lock=true \
57
+ --ulimit memlock=-1:-1 \
58
+ --ulimit nofile=65535:65535 \
59
+ --user `id -u`:`id -g` \
60
+ #{"--publish='#{SmartMachine.credentials.elasticsearch[:port]}:#{SmartMachine.credentials.elasticsearch[:port]}'" if exposed == '--exposed'} \
61
+ --volume='#{SmartMachine.config.user_home_path}/.smartmachine/grids/elasticsearch/data:/usr/share/elasticsearch/data' \
62
+ --volume='#{SmartMachine.config.user_home_path}/.smartmachine/grids/elasticsearch/logs:/usr/share/elasticsearch/logs' \
63
+ --restart='always' \
64
+ --network='elasticsearch-network' \
65
+ elasticsearch:7.4.1", out: File::NULL)
66
+
67
+ puts "done"
68
+ print "-----> Starting container elasticsearch ... "
69
+ if system("docker start elasticsearch", out: File::NULL)
70
+ puts "done"
71
+ end
72
+ end
73
+ end
74
+ end
75
+
76
+ def down
77
+ if SmartMachine::Docker.running?
78
+ # Stopping & Removing containers - in reverse order
79
+ print "-----> Stopping container elasticsearch ... "
80
+ if system("docker stop 'elasticsearch'", out: File::NULL)
81
+ puts "done"
82
+ print "-----> Removing container elasticsearch ... "
83
+ if system("docker rm 'elasticsearch'", out: File::NULL)
84
+ puts "done"
85
+ end
86
+ end
87
+
88
+ # Removing networks
89
+ print "-----> Removing network elasticsearch-network ... "
90
+ if system("docker network rm elasticsearch-network", out: File::NULL)
91
+ puts "done"
92
+ end
93
+ end
94
+ end
95
+ end
96
+ end
97
+ end
File without changes
@@ -0,0 +1,77 @@
1
+ # The main SmartMachine Grids Minio driver
2
+ module SmartMachine
3
+ class Grids
4
+ class Minio < SmartMachine::Base
5
+ def initialize
6
+ end
7
+
8
+ def up(*args)
9
+ args.flatten!
10
+ exposed = args.empty? ? '' : args.shift
11
+
12
+ if SmartMachine::Docker.running?
13
+ # Creating networks
14
+ unless system("docker network inspect minio-network", [:out, :err] => File::NULL)
15
+ print "-----> Creating network minio-network ... "
16
+ if system("docker network create minio-network", out: File::NULL)
17
+ puts "done"
18
+ end
19
+ end
20
+
21
+ # Creating & Starting containers
22
+ print "-----> Creating container minio ... "
23
+ if system("docker create \
24
+ --name='minio' \
25
+ --env VIRTUAL_HOST=#{SmartMachine.credentials.minio[:name]}.#{SmartMachine.config.apps_domain} \
26
+ --env LETSENCRYPT_HOST=#{SmartMachine.credentials.minio[:name]}.#{SmartMachine.config.apps_domain} \
27
+ --env LETSENCRYPT_EMAIL=#{SmartMachine.config.sysadmin_email} \
28
+ --env LETSENCRYPT_TEST=false \
29
+ --env MINIO_ACCESS_KEY=#{SmartMachine.credentials.minio[:access_key]} \
30
+ --env MINIO_SECRET_KEY=#{SmartMachine.credentials.minio[:secret_key]} \
31
+ --env MINIO_BROWSER=#{SmartMachine.credentials.minio[:browser]} \
32
+ --env MINIO_WORM=#{SmartMachine.credentials.minio[:worm]} \
33
+ --user `id -u`:`id -g` \
34
+ --volume='#{SmartMachine.config.user_home_path}/.smartmachine/grids/minio/data:/data' \
35
+ --restart='always' \
36
+ --network='minio-network' \
37
+ minio/minio:RELEASE.2020-02-27T00-23-05Z server /data", out: File::NULL)
38
+
39
+ # The alias is necessary to support internal network requests directed to minio container using public url
40
+ system("docker network connect --alias #{SmartMachine.credentials.minio[:name]}.#{SmartMachine.config.apps_domain} minio-network nginx")
41
+ system("docker network connect nginx-network minio")
42
+
43
+ puts "done"
44
+ print "-----> Starting container minio ... "
45
+ if system("docker start minio", out: File::NULL)
46
+ puts "done"
47
+ end
48
+ end
49
+ end
50
+ end
51
+
52
+ def down
53
+ if SmartMachine::Docker.running?
54
+ # Disconnecting networks
55
+ system("docker network disconnect nginx-network minio")
56
+ system("docker network disconnect minio-network nginx")
57
+
58
+ # Stopping & Removing containers - in reverse order
59
+ print "-----> Stopping container minio ... "
60
+ if system("docker stop 'minio'", out: File::NULL)
61
+ puts "done"
62
+ print "-----> Removing container minio ... "
63
+ if system("docker rm 'minio'", out: File::NULL)
64
+ puts "done"
65
+ end
66
+ end
67
+
68
+ # Removing networks
69
+ print "-----> Removing network minio-network ... "
70
+ if system("docker network rm minio-network", out: File::NULL)
71
+ puts "done"
72
+ end
73
+ end
74
+ end
75
+ end
76
+ end
77
+ end