smartcloud 0.0.208 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (213) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +3 -3
  3. data/bin/buildpacker +2 -2
  4. data/bin/prereceiver +8 -0
  5. data/bin/smartcloud +68 -62
  6. data/lib/smartcloud.rb +7 -0
  7. data/lib/smartcloud/apps/app.rb +182 -0
  8. data/lib/smartcloud/apps/rails.rb +240 -0
  9. data/lib/smartcloud/base.rb +1 -0
  10. data/lib/smartcloud/boot.rb +11 -80
  11. data/lib/smartcloud/buildpacker.rb +75 -0
  12. data/lib/smartcloud/credentials.rb +127 -0
  13. data/lib/smartcloud/docker.rb +41 -25
  14. data/lib/smartcloud/engine.rb +39 -30
  15. data/lib/smartcloud/engine/Dockerfile +18 -18
  16. data/lib/smartcloud/{grids/grid-runner → engine}/buildpacks/rails/Dockerfile +3 -14
  17. data/lib/smartcloud/grids/{grid-buildpacker → grid-nginx}/.keep +0 -0
  18. data/lib/smartcloud/grids/{grid-runner → grid-prereceiver}/Dockerfile +1 -18
  19. data/lib/smartcloud/grids/{grid-runner → grid-prereceiver}/fcgiwrap/APKBUILD +0 -0
  20. data/lib/smartcloud/grids/{grid-runner → grid-prereceiver}/fcgiwrap/fcgiwrap.confd +0 -0
  21. data/lib/smartcloud/grids/{grid-runner → grid-prereceiver}/fcgiwrap/fcgiwrap.initd +0 -0
  22. data/lib/smartcloud/grids/{grid-runner → grid-prereceiver}/fcgiwrap/fcgiwrap.pre-install +0 -0
  23. data/lib/smartcloud/grids/{grid-runner → grid-prereceiver}/fcgiwrap/packages/main/x86_64/APKINDEX.tar.gz +0 -0
  24. data/lib/smartcloud/grids/{grid-runner → grid-prereceiver}/fcgiwrap/packages/main/x86_64/fcgiwrap-1.1.1-r4.apk +0 -0
  25. data/lib/smartcloud/grids/{grid-runner → grid-prereceiver}/fcgiwrap/packages/main/x86_64/fcgiwrap-doc-1.1.1-r4.apk +0 -0
  26. data/lib/smartcloud/grids/{grid-runner → grid-prereceiver}/fcgiwrap/packages/main/x86_64/fcgiwrap-openrc-1.1.1-r4.apk +0 -0
  27. data/lib/smartcloud/{templates/dotsmartcloud/grids/grid-buildpacker → grids/grid-redmine}/.keep +0 -0
  28. data/lib/smartcloud/{templates/dotsmartcloud/grids/grid-runner/apps/containers → grids/grid-solr/config}/.keep +0 -0
  29. data/lib/smartcloud/{templates/dotsmartcloud/grids/grid-solr/data → grids/grid-solr/config}/README.txt +0 -0
  30. data/lib/smartcloud/{templates/dotsmartcloud/grids/grid-solr/data → grids/grid-solr/config}/configsets/_default/conf/lang/contractions_ca.txt +0 -0
  31. data/lib/smartcloud/{templates/dotsmartcloud/grids/grid-solr/data → grids/grid-solr/config}/configsets/_default/conf/lang/contractions_fr.txt +0 -0
  32. data/lib/smartcloud/{templates/dotsmartcloud/grids/grid-solr/data → grids/grid-solr/config}/configsets/_default/conf/lang/contractions_ga.txt +0 -0
  33. data/lib/smartcloud/{templates/dotsmartcloud/grids/grid-solr/data → grids/grid-solr/config}/configsets/_default/conf/lang/contractions_it.txt +0 -0
  34. data/lib/smartcloud/{templates/dotsmartcloud/grids/grid-solr/data → grids/grid-solr/config}/configsets/_default/conf/lang/hyphenations_ga.txt +0 -0
  35. data/lib/smartcloud/{templates/dotsmartcloud/grids/grid-solr/data → grids/grid-solr/config}/configsets/_default/conf/lang/stemdict_nl.txt +0 -0
  36. data/lib/smartcloud/{templates/dotsmartcloud/grids/grid-solr/data → grids/grid-solr/config}/configsets/_default/conf/lang/stoptags_ja.txt +0 -0
  37. data/lib/smartcloud/{templates/dotsmartcloud/grids/grid-solr/data → grids/grid-solr/config}/configsets/_default/conf/lang/stopwords_ar.txt +0 -0
  38. data/lib/smartcloud/{templates/dotsmartcloud/grids/grid-solr/data → grids/grid-solr/config}/configsets/_default/conf/lang/stopwords_bg.txt +0 -0
  39. data/lib/smartcloud/{templates/dotsmartcloud/grids/grid-solr/data → grids/grid-solr/config}/configsets/_default/conf/lang/stopwords_ca.txt +0 -0
  40. data/lib/smartcloud/{templates/dotsmartcloud/grids/grid-solr/data → grids/grid-solr/config}/configsets/_default/conf/lang/stopwords_cz.txt +0 -0
  41. data/lib/smartcloud/{templates/dotsmartcloud/grids/grid-solr/data → grids/grid-solr/config}/configsets/_default/conf/lang/stopwords_da.txt +0 -0
  42. data/lib/smartcloud/{templates/dotsmartcloud/grids/grid-solr/data → grids/grid-solr/config}/configsets/_default/conf/lang/stopwords_de.txt +0 -0
  43. data/lib/smartcloud/{templates/dotsmartcloud/grids/grid-solr/data → grids/grid-solr/config}/configsets/_default/conf/lang/stopwords_el.txt +0 -0
  44. data/lib/smartcloud/{templates/dotsmartcloud/grids/grid-solr/data → grids/grid-solr/config}/configsets/_default/conf/lang/stopwords_en.txt +0 -0
  45. data/lib/smartcloud/{templates/dotsmartcloud/grids/grid-solr/data → grids/grid-solr/config}/configsets/_default/conf/lang/stopwords_es.txt +0 -0
  46. data/lib/smartcloud/{templates/dotsmartcloud/grids/grid-solr/data → grids/grid-solr/config}/configsets/_default/conf/lang/stopwords_eu.txt +0 -0
  47. data/lib/smartcloud/{templates/dotsmartcloud/grids/grid-solr/data → grids/grid-solr/config}/configsets/_default/conf/lang/stopwords_fa.txt +0 -0
  48. data/lib/smartcloud/{templates/dotsmartcloud/grids/grid-solr/data → grids/grid-solr/config}/configsets/_default/conf/lang/stopwords_fi.txt +0 -0
  49. data/lib/smartcloud/{templates/dotsmartcloud/grids/grid-solr/data → grids/grid-solr/config}/configsets/_default/conf/lang/stopwords_fr.txt +0 -0
  50. data/lib/smartcloud/{templates/dotsmartcloud/grids/grid-solr/data → grids/grid-solr/config}/configsets/_default/conf/lang/stopwords_ga.txt +0 -0
  51. data/lib/smartcloud/{templates/dotsmartcloud/grids/grid-solr/data → grids/grid-solr/config}/configsets/_default/conf/lang/stopwords_gl.txt +0 -0
  52. data/lib/smartcloud/{templates/dotsmartcloud/grids/grid-solr/data → grids/grid-solr/config}/configsets/_default/conf/lang/stopwords_hi.txt +0 -0
  53. data/lib/smartcloud/{templates/dotsmartcloud/grids/grid-solr/data → grids/grid-solr/config}/configsets/_default/conf/lang/stopwords_hu.txt +0 -0
  54. data/lib/smartcloud/{templates/dotsmartcloud/grids/grid-solr/data → grids/grid-solr/config}/configsets/_default/conf/lang/stopwords_hy.txt +0 -0
  55. data/lib/smartcloud/{templates/dotsmartcloud/grids/grid-solr/data → grids/grid-solr/config}/configsets/_default/conf/lang/stopwords_id.txt +0 -0
  56. data/lib/smartcloud/{templates/dotsmartcloud/grids/grid-solr/data → grids/grid-solr/config}/configsets/_default/conf/lang/stopwords_it.txt +0 -0
  57. data/lib/smartcloud/{templates/dotsmartcloud/grids/grid-solr/data → grids/grid-solr/config}/configsets/_default/conf/lang/stopwords_ja.txt +0 -0
  58. data/lib/smartcloud/{templates/dotsmartcloud/grids/grid-solr/data → grids/grid-solr/config}/configsets/_default/conf/lang/stopwords_lv.txt +0 -0
  59. data/lib/smartcloud/{templates/dotsmartcloud/grids/grid-solr/data → grids/grid-solr/config}/configsets/_default/conf/lang/stopwords_nl.txt +0 -0
  60. data/lib/smartcloud/{templates/dotsmartcloud/grids/grid-solr/data → grids/grid-solr/config}/configsets/_default/conf/lang/stopwords_no.txt +0 -0
  61. data/lib/smartcloud/{templates/dotsmartcloud/grids/grid-solr/data → grids/grid-solr/config}/configsets/_default/conf/lang/stopwords_pt.txt +0 -0
  62. data/lib/smartcloud/{templates/dotsmartcloud/grids/grid-solr/data → grids/grid-solr/config}/configsets/_default/conf/lang/stopwords_ro.txt +0 -0
  63. data/lib/smartcloud/{templates/dotsmartcloud/grids/grid-solr/data → grids/grid-solr/config}/configsets/_default/conf/lang/stopwords_ru.txt +0 -0
  64. data/lib/smartcloud/{templates/dotsmartcloud/grids/grid-solr/data → grids/grid-solr/config}/configsets/_default/conf/lang/stopwords_sv.txt +0 -0
  65. data/lib/smartcloud/{templates/dotsmartcloud/grids/grid-solr/data → grids/grid-solr/config}/configsets/_default/conf/lang/stopwords_th.txt +0 -0
  66. data/lib/smartcloud/{templates/dotsmartcloud/grids/grid-solr/data → grids/grid-solr/config}/configsets/_default/conf/lang/stopwords_tr.txt +0 -0
  67. data/lib/smartcloud/{templates/dotsmartcloud/grids/grid-solr/data → grids/grid-solr/config}/configsets/_default/conf/lang/userdict_ja.txt +0 -0
  68. data/lib/smartcloud/{templates/dotsmartcloud/grids/grid-solr/data → grids/grid-solr/config}/configsets/_default/conf/managed-schema +0 -0
  69. data/lib/smartcloud/{templates/dotsmartcloud/grids/grid-solr/data → grids/grid-solr/config}/configsets/_default/conf/params.json +0 -0
  70. data/lib/smartcloud/{templates/dotsmartcloud/grids/grid-solr/data → grids/grid-solr/config}/configsets/_default/conf/protwords.txt +0 -0
  71. data/lib/smartcloud/{templates/dotsmartcloud/grids/grid-solr/data → grids/grid-solr/config}/configsets/_default/conf/solrconfig.xml +0 -0
  72. data/lib/smartcloud/{templates/dotsmartcloud/grids/grid-solr/data → grids/grid-solr/config}/configsets/_default/conf/stopwords.txt +0 -0
  73. data/lib/smartcloud/{templates/dotsmartcloud/grids/grid-solr/data → grids/grid-solr/config}/configsets/_default/conf/synonyms.txt +0 -0
  74. data/lib/smartcloud/{templates/dotsmartcloud/grids/grid-solr/data → grids/grid-solr/config}/configsets/sample_techproducts_configs/conf/_rest_managed.json +0 -0
  75. data/lib/smartcloud/{templates/dotsmartcloud/grids/grid-solr/data → grids/grid-solr/config}/configsets/sample_techproducts_configs/conf/_schema_analysis_stopwords_english.json +0 -0
  76. data/lib/smartcloud/{templates/dotsmartcloud/grids/grid-solr/data → grids/grid-solr/config}/configsets/sample_techproducts_configs/conf/_schema_analysis_synonyms_english.json +0 -0
  77. data/lib/smartcloud/{templates/dotsmartcloud/grids/grid-solr/data → grids/grid-solr/config}/configsets/sample_techproducts_configs/conf/clustering/carrot2/README.txt +0 -0
  78. data/lib/smartcloud/{templates/dotsmartcloud/grids/grid-solr/data → grids/grid-solr/config}/configsets/sample_techproducts_configs/conf/clustering/carrot2/kmeans-attributes.xml +0 -0
  79. data/lib/smartcloud/{templates/dotsmartcloud/grids/grid-solr/data → grids/grid-solr/config}/configsets/sample_techproducts_configs/conf/clustering/carrot2/lingo-attributes.xml +0 -0
  80. data/lib/smartcloud/{templates/dotsmartcloud/grids/grid-solr/data → grids/grid-solr/config}/configsets/sample_techproducts_configs/conf/clustering/carrot2/stc-attributes.xml +0 -0
  81. data/lib/smartcloud/{templates/dotsmartcloud/grids/grid-solr/data → grids/grid-solr/config}/configsets/sample_techproducts_configs/conf/currency.xml +0 -0
  82. data/lib/smartcloud/{templates/dotsmartcloud/grids/grid-solr/data → grids/grid-solr/config}/configsets/sample_techproducts_configs/conf/elevate.xml +0 -0
  83. data/lib/smartcloud/{templates/dotsmartcloud/grids/grid-solr/data → grids/grid-solr/config}/configsets/sample_techproducts_configs/conf/lang/contractions_ca.txt +0 -0
  84. data/lib/smartcloud/{templates/dotsmartcloud/grids/grid-solr/data → grids/grid-solr/config}/configsets/sample_techproducts_configs/conf/lang/contractions_fr.txt +0 -0
  85. data/lib/smartcloud/{templates/dotsmartcloud/grids/grid-solr/data → grids/grid-solr/config}/configsets/sample_techproducts_configs/conf/lang/contractions_ga.txt +0 -0
  86. data/lib/smartcloud/{templates/dotsmartcloud/grids/grid-solr/data → grids/grid-solr/config}/configsets/sample_techproducts_configs/conf/lang/contractions_it.txt +0 -0
  87. data/lib/smartcloud/{templates/dotsmartcloud/grids/grid-solr/data → grids/grid-solr/config}/configsets/sample_techproducts_configs/conf/lang/hyphenations_ga.txt +0 -0
  88. data/lib/smartcloud/{templates/dotsmartcloud/grids/grid-solr/data → grids/grid-solr/config}/configsets/sample_techproducts_configs/conf/lang/stemdict_nl.txt +0 -0
  89. data/lib/smartcloud/{templates/dotsmartcloud/grids/grid-solr/data → grids/grid-solr/config}/configsets/sample_techproducts_configs/conf/lang/stoptags_ja.txt +0 -0
  90. data/lib/smartcloud/{templates/dotsmartcloud/grids/grid-solr/data → grids/grid-solr/config}/configsets/sample_techproducts_configs/conf/lang/stopwords_ar.txt +0 -0
  91. data/lib/smartcloud/{templates/dotsmartcloud/grids/grid-solr/data → grids/grid-solr/config}/configsets/sample_techproducts_configs/conf/lang/stopwords_bg.txt +0 -0
  92. data/lib/smartcloud/{templates/dotsmartcloud/grids/grid-solr/data → grids/grid-solr/config}/configsets/sample_techproducts_configs/conf/lang/stopwords_ca.txt +0 -0
  93. data/lib/smartcloud/{templates/dotsmartcloud/grids/grid-solr/data → grids/grid-solr/config}/configsets/sample_techproducts_configs/conf/lang/stopwords_ckb.txt +0 -0
  94. data/lib/smartcloud/{templates/dotsmartcloud/grids/grid-solr/data → grids/grid-solr/config}/configsets/sample_techproducts_configs/conf/lang/stopwords_cz.txt +0 -0
  95. data/lib/smartcloud/{templates/dotsmartcloud/grids/grid-solr/data → grids/grid-solr/config}/configsets/sample_techproducts_configs/conf/lang/stopwords_da.txt +0 -0
  96. data/lib/smartcloud/{templates/dotsmartcloud/grids/grid-solr/data → grids/grid-solr/config}/configsets/sample_techproducts_configs/conf/lang/stopwords_de.txt +0 -0
  97. data/lib/smartcloud/{templates/dotsmartcloud/grids/grid-solr/data → grids/grid-solr/config}/configsets/sample_techproducts_configs/conf/lang/stopwords_el.txt +0 -0
  98. data/lib/smartcloud/{templates/dotsmartcloud/grids/grid-solr/data → grids/grid-solr/config}/configsets/sample_techproducts_configs/conf/lang/stopwords_en.txt +0 -0
  99. data/lib/smartcloud/{templates/dotsmartcloud/grids/grid-solr/data → grids/grid-solr/config}/configsets/sample_techproducts_configs/conf/lang/stopwords_es.txt +0 -0
  100. data/lib/smartcloud/{templates/dotsmartcloud/grids/grid-solr/data → grids/grid-solr/config}/configsets/sample_techproducts_configs/conf/lang/stopwords_eu.txt +0 -0
  101. data/lib/smartcloud/{templates/dotsmartcloud/grids/grid-solr/data → grids/grid-solr/config}/configsets/sample_techproducts_configs/conf/lang/stopwords_fa.txt +0 -0
  102. data/lib/smartcloud/{templates/dotsmartcloud/grids/grid-solr/data → grids/grid-solr/config}/configsets/sample_techproducts_configs/conf/lang/stopwords_fi.txt +0 -0
  103. data/lib/smartcloud/{templates/dotsmartcloud/grids/grid-solr/data → grids/grid-solr/config}/configsets/sample_techproducts_configs/conf/lang/stopwords_fr.txt +0 -0
  104. data/lib/smartcloud/{templates/dotsmartcloud/grids/grid-solr/data → grids/grid-solr/config}/configsets/sample_techproducts_configs/conf/lang/stopwords_ga.txt +0 -0
  105. data/lib/smartcloud/{templates/dotsmartcloud/grids/grid-solr/data → grids/grid-solr/config}/configsets/sample_techproducts_configs/conf/lang/stopwords_gl.txt +0 -0
  106. data/lib/smartcloud/{templates/dotsmartcloud/grids/grid-solr/data → grids/grid-solr/config}/configsets/sample_techproducts_configs/conf/lang/stopwords_hi.txt +0 -0
  107. data/lib/smartcloud/{templates/dotsmartcloud/grids/grid-solr/data → grids/grid-solr/config}/configsets/sample_techproducts_configs/conf/lang/stopwords_hu.txt +0 -0
  108. data/lib/smartcloud/{templates/dotsmartcloud/grids/grid-solr/data → grids/grid-solr/config}/configsets/sample_techproducts_configs/conf/lang/stopwords_hy.txt +0 -0
  109. data/lib/smartcloud/{templates/dotsmartcloud/grids/grid-solr/data → grids/grid-solr/config}/configsets/sample_techproducts_configs/conf/lang/stopwords_id.txt +0 -0
  110. data/lib/smartcloud/{templates/dotsmartcloud/grids/grid-solr/data → grids/grid-solr/config}/configsets/sample_techproducts_configs/conf/lang/stopwords_it.txt +0 -0
  111. data/lib/smartcloud/{templates/dotsmartcloud/grids/grid-solr/data → grids/grid-solr/config}/configsets/sample_techproducts_configs/conf/lang/stopwords_ja.txt +0 -0
  112. data/lib/smartcloud/{templates/dotsmartcloud/grids/grid-solr/data → grids/grid-solr/config}/configsets/sample_techproducts_configs/conf/lang/stopwords_lv.txt +0 -0
  113. data/lib/smartcloud/{templates/dotsmartcloud/grids/grid-solr/data → grids/grid-solr/config}/configsets/sample_techproducts_configs/conf/lang/stopwords_nl.txt +0 -0
  114. data/lib/smartcloud/{templates/dotsmartcloud/grids/grid-solr/data → grids/grid-solr/config}/configsets/sample_techproducts_configs/conf/lang/stopwords_no.txt +0 -0
  115. data/lib/smartcloud/{templates/dotsmartcloud/grids/grid-solr/data → grids/grid-solr/config}/configsets/sample_techproducts_configs/conf/lang/stopwords_pt.txt +0 -0
  116. data/lib/smartcloud/{templates/dotsmartcloud/grids/grid-solr/data → grids/grid-solr/config}/configsets/sample_techproducts_configs/conf/lang/stopwords_ro.txt +0 -0
  117. data/lib/smartcloud/{templates/dotsmartcloud/grids/grid-solr/data → grids/grid-solr/config}/configsets/sample_techproducts_configs/conf/lang/stopwords_ru.txt +0 -0
  118. data/lib/smartcloud/{templates/dotsmartcloud/grids/grid-solr/data → grids/grid-solr/config}/configsets/sample_techproducts_configs/conf/lang/stopwords_sv.txt +0 -0
  119. data/lib/smartcloud/{templates/dotsmartcloud/grids/grid-solr/data → grids/grid-solr/config}/configsets/sample_techproducts_configs/conf/lang/stopwords_th.txt +0 -0
  120. data/lib/smartcloud/{templates/dotsmartcloud/grids/grid-solr/data → grids/grid-solr/config}/configsets/sample_techproducts_configs/conf/lang/stopwords_tr.txt +0 -0
  121. data/lib/smartcloud/{templates/dotsmartcloud/grids/grid-solr/data → grids/grid-solr/config}/configsets/sample_techproducts_configs/conf/lang/userdict_ja.txt +0 -0
  122. data/lib/smartcloud/{templates/dotsmartcloud/grids/grid-solr/data → grids/grid-solr/config}/configsets/sample_techproducts_configs/conf/managed-schema +0 -0
  123. data/lib/smartcloud/{templates/dotsmartcloud/grids/grid-solr/data → grids/grid-solr/config}/configsets/sample_techproducts_configs/conf/mapping-FoldToASCII.txt +0 -0
  124. data/lib/smartcloud/{templates/dotsmartcloud/grids/grid-solr/data → grids/grid-solr/config}/configsets/sample_techproducts_configs/conf/mapping-ISOLatin1Accent.txt +0 -0
  125. data/lib/smartcloud/{templates/dotsmartcloud/grids/grid-solr/data → grids/grid-solr/config}/configsets/sample_techproducts_configs/conf/params.json +0 -0
  126. data/lib/smartcloud/{templates/dotsmartcloud/grids/grid-solr/data → grids/grid-solr/config}/configsets/sample_techproducts_configs/conf/protwords.txt +0 -0
  127. data/lib/smartcloud/{templates/dotsmartcloud/grids/grid-solr/data → grids/grid-solr/config}/configsets/sample_techproducts_configs/conf/solrconfig.xml +0 -0
  128. data/lib/smartcloud/{templates/dotsmartcloud/grids/grid-solr/data → grids/grid-solr/config}/configsets/sample_techproducts_configs/conf/spellings.txt +0 -0
  129. data/lib/smartcloud/{templates/dotsmartcloud/grids/grid-solr/data → grids/grid-solr/config}/configsets/sample_techproducts_configs/conf/stopwords.txt +0 -0
  130. data/lib/smartcloud/{templates/dotsmartcloud/grids/grid-solr/data → grids/grid-solr/config}/configsets/sample_techproducts_configs/conf/synonyms.txt +0 -0
  131. data/lib/smartcloud/{templates/dotsmartcloud/grids/grid-solr/data → grids/grid-solr/config}/configsets/sample_techproducts_configs/conf/update-script.js +0 -0
  132. data/lib/smartcloud/{templates/dotsmartcloud/grids/grid-solr/data → grids/grid-solr/config}/configsets/sample_techproducts_configs/conf/velocity/README.txt +0 -0
  133. data/lib/smartcloud/{templates/dotsmartcloud/grids/grid-solr/data → grids/grid-solr/config}/configsets/sample_techproducts_configs/conf/velocity/VM_global_library.vm +0 -0
  134. data/lib/smartcloud/{templates/dotsmartcloud/grids/grid-solr/data → grids/grid-solr/config}/configsets/sample_techproducts_configs/conf/velocity/browse.vm +0 -0
  135. data/lib/smartcloud/{templates/dotsmartcloud/grids/grid-solr/data → grids/grid-solr/config}/configsets/sample_techproducts_configs/conf/velocity/cluster.vm +0 -0
  136. data/lib/smartcloud/{templates/dotsmartcloud/grids/grid-solr/data → grids/grid-solr/config}/configsets/sample_techproducts_configs/conf/velocity/cluster_results.vm +0 -0
  137. data/lib/smartcloud/{templates/dotsmartcloud/grids/grid-solr/data → grids/grid-solr/config}/configsets/sample_techproducts_configs/conf/velocity/debug.vm +0 -0
  138. data/lib/smartcloud/{templates/dotsmartcloud/grids/grid-solr/data → grids/grid-solr/config}/configsets/sample_techproducts_configs/conf/velocity/did_you_mean.vm +0 -0
  139. data/lib/smartcloud/{templates/dotsmartcloud/grids/grid-solr/data → grids/grid-solr/config}/configsets/sample_techproducts_configs/conf/velocity/error.vm +0 -0
  140. data/lib/smartcloud/{templates/dotsmartcloud/grids/grid-solr/data → grids/grid-solr/config}/configsets/sample_techproducts_configs/conf/velocity/facet_fields.vm +0 -0
  141. data/lib/smartcloud/{templates/dotsmartcloud/grids/grid-solr/data → grids/grid-solr/config}/configsets/sample_techproducts_configs/conf/velocity/facet_pivot.vm +0 -0
  142. data/lib/smartcloud/{templates/dotsmartcloud/grids/grid-solr/data → grids/grid-solr/config}/configsets/sample_techproducts_configs/conf/velocity/facet_queries.vm +0 -0
  143. data/lib/smartcloud/{templates/dotsmartcloud/grids/grid-solr/data → grids/grid-solr/config}/configsets/sample_techproducts_configs/conf/velocity/facet_ranges.vm +0 -0
  144. data/lib/smartcloud/{templates/dotsmartcloud/grids/grid-solr/data → grids/grid-solr/config}/configsets/sample_techproducts_configs/conf/velocity/facets.vm +0 -0
  145. data/lib/smartcloud/{templates/dotsmartcloud/grids/grid-solr/data → grids/grid-solr/config}/configsets/sample_techproducts_configs/conf/velocity/footer.vm +0 -0
  146. data/lib/smartcloud/{templates/dotsmartcloud/grids/grid-solr/data → grids/grid-solr/config}/configsets/sample_techproducts_configs/conf/velocity/head.vm +0 -0
  147. data/lib/smartcloud/{templates/dotsmartcloud/grids/grid-solr/data → grids/grid-solr/config}/configsets/sample_techproducts_configs/conf/velocity/header.vm +0 -0
  148. data/lib/smartcloud/{templates/dotsmartcloud/grids/grid-solr/data → grids/grid-solr/config}/configsets/sample_techproducts_configs/conf/velocity/hit.vm +0 -0
  149. data/lib/smartcloud/{templates/dotsmartcloud/grids/grid-solr/data → grids/grid-solr/config}/configsets/sample_techproducts_configs/conf/velocity/hit_grouped.vm +0 -0
  150. data/lib/smartcloud/{templates/dotsmartcloud/grids/grid-solr/data → grids/grid-solr/config}/configsets/sample_techproducts_configs/conf/velocity/hit_plain.vm +0 -0
  151. data/lib/smartcloud/{templates/dotsmartcloud/grids/grid-solr/data → grids/grid-solr/config}/configsets/sample_techproducts_configs/conf/velocity/join_doc.vm +0 -0
  152. data/lib/smartcloud/{templates/dotsmartcloud/grids/grid-solr/data → grids/grid-solr/config}/configsets/sample_techproducts_configs/conf/velocity/jquery.autocomplete.css +0 -0
  153. data/lib/smartcloud/{templates/dotsmartcloud/grids/grid-solr/data → grids/grid-solr/config}/configsets/sample_techproducts_configs/conf/velocity/jquery.autocomplete.js +0 -0
  154. data/lib/smartcloud/{templates/dotsmartcloud/grids/grid-solr/data → grids/grid-solr/config}/configsets/sample_techproducts_configs/conf/velocity/layout.vm +0 -0
  155. data/lib/smartcloud/{templates/dotsmartcloud/grids/grid-solr/data → grids/grid-solr/config}/configsets/sample_techproducts_configs/conf/velocity/main.css +0 -0
  156. data/lib/smartcloud/{templates/dotsmartcloud/grids/grid-solr/data → grids/grid-solr/config}/configsets/sample_techproducts_configs/conf/velocity/mime_type_lists.vm +0 -0
  157. data/lib/smartcloud/{templates/dotsmartcloud/grids/grid-solr/data → grids/grid-solr/config}/configsets/sample_techproducts_configs/conf/velocity/pagination_bottom.vm +0 -0
  158. data/lib/smartcloud/{templates/dotsmartcloud/grids/grid-solr/data → grids/grid-solr/config}/configsets/sample_techproducts_configs/conf/velocity/pagination_top.vm +0 -0
  159. data/lib/smartcloud/{templates/dotsmartcloud/grids/grid-solr/data → grids/grid-solr/config}/configsets/sample_techproducts_configs/conf/velocity/product_doc.vm +0 -0
  160. data/lib/smartcloud/{templates/dotsmartcloud/grids/grid-solr/data → grids/grid-solr/config}/configsets/sample_techproducts_configs/conf/velocity/query.vm +0 -0
  161. data/lib/smartcloud/{templates/dotsmartcloud/grids/grid-solr/data → grids/grid-solr/config}/configsets/sample_techproducts_configs/conf/velocity/query_form.vm +0 -0
  162. data/lib/smartcloud/{templates/dotsmartcloud/grids/grid-solr/data → grids/grid-solr/config}/configsets/sample_techproducts_configs/conf/velocity/query_group.vm +0 -0
  163. data/lib/smartcloud/{templates/dotsmartcloud/grids/grid-solr/data → grids/grid-solr/config}/configsets/sample_techproducts_configs/conf/velocity/query_spatial.vm +0 -0
  164. data/lib/smartcloud/{templates/dotsmartcloud/grids/grid-solr/data → grids/grid-solr/config}/configsets/sample_techproducts_configs/conf/velocity/results_list.vm +0 -0
  165. data/lib/smartcloud/{templates/dotsmartcloud/grids/grid-solr/data → grids/grid-solr/config}/configsets/sample_techproducts_configs/conf/velocity/richtext_doc.vm +0 -0
  166. data/lib/smartcloud/{templates/dotsmartcloud/grids/grid-solr/data → grids/grid-solr/config}/configsets/sample_techproducts_configs/conf/velocity/suggest.vm +0 -0
  167. data/lib/smartcloud/{templates/dotsmartcloud/grids/grid-solr/data → grids/grid-solr/config}/configsets/sample_techproducts_configs/conf/velocity/tabs.vm +0 -0
  168. data/lib/smartcloud/{templates/dotsmartcloud/grids/grid-solr/data → grids/grid-solr/config}/configsets/sample_techproducts_configs/conf/xslt/example.xsl +0 -0
  169. data/lib/smartcloud/{templates/dotsmartcloud/grids/grid-solr/data → grids/grid-solr/config}/configsets/sample_techproducts_configs/conf/xslt/example_atom.xsl +0 -0
  170. data/lib/smartcloud/{templates/dotsmartcloud/grids/grid-solr/data → grids/grid-solr/config}/configsets/sample_techproducts_configs/conf/xslt/example_rss.xsl +0 -0
  171. data/lib/smartcloud/{templates/dotsmartcloud/grids/grid-solr/data → grids/grid-solr/config}/configsets/sample_techproducts_configs/conf/xslt/luke.xsl +0 -0
  172. data/lib/smartcloud/{templates/dotsmartcloud/grids/grid-solr/data → grids/grid-solr/config}/configsets/sample_techproducts_configs/conf/xslt/updateXml.xsl +0 -0
  173. data/lib/smartcloud/{templates/dotsmartcloud/grids/grid-solr/data → grids/grid-solr/config}/configsets/sunspot/conf/_rest_managed.json +0 -0
  174. data/lib/smartcloud/{templates/dotsmartcloud/grids/grid-solr/data → grids/grid-solr/config}/configsets/sunspot/conf/admin-extra.html +0 -0
  175. data/lib/smartcloud/{templates/dotsmartcloud/grids/grid-solr/data → grids/grid-solr/config}/configsets/sunspot/conf/currency.xml +0 -0
  176. data/lib/smartcloud/{templates/dotsmartcloud/grids/grid-solr/data → grids/grid-solr/config}/configsets/sunspot/conf/elevate.xml +0 -0
  177. data/lib/smartcloud/{templates/dotsmartcloud/grids/grid-solr/data → grids/grid-solr/config}/configsets/sunspot/conf/lang/stopwords_en.txt +0 -0
  178. data/lib/smartcloud/{templates/dotsmartcloud/grids/grid-solr/data → grids/grid-solr/config}/configsets/sunspot/conf/mapping-ISOLatin1Accent.txt +0 -0
  179. data/lib/smartcloud/{templates/dotsmartcloud/grids/grid-solr/data → grids/grid-solr/config}/configsets/sunspot/conf/protwords.txt +0 -0
  180. data/lib/smartcloud/{templates/dotsmartcloud/grids/grid-solr/data → grids/grid-solr/config}/configsets/sunspot/conf/schema.xml +0 -0
  181. data/lib/smartcloud/{templates/dotsmartcloud/grids/grid-solr/data → grids/grid-solr/config}/configsets/sunspot/conf/scripts.conf +0 -0
  182. data/lib/smartcloud/{templates/dotsmartcloud/grids/grid-solr/data → grids/grid-solr/config}/configsets/sunspot/conf/solrconfig.xml +0 -0
  183. data/lib/smartcloud/{templates/dotsmartcloud/grids/grid-solr/data → grids/grid-solr/config}/configsets/sunspot/conf/spellings.txt +0 -0
  184. data/lib/smartcloud/{templates/dotsmartcloud/grids/grid-solr/data → grids/grid-solr/config}/configsets/sunspot/conf/synonyms.txt +0 -0
  185. data/lib/smartcloud/{templates/dotsmartcloud/grids/grid-runner/apps/repositories → grids/grid-solr/config/lib}/.keep +0 -0
  186. data/lib/smartcloud/{templates/dotsmartcloud/grids/grid-solr/data → grids/grid-solr/config}/solr.xml +0 -0
  187. data/lib/smartcloud/{templates/dotsmartcloud/grids/grid-solr/data → grids/grid-solr/config}/zoo.cfg +0 -0
  188. data/lib/smartcloud/grids/mysql.rb +11 -5
  189. data/lib/smartcloud/grids/nginx.rb +7 -4
  190. data/lib/smartcloud/grids/prereceiver.rb +131 -0
  191. data/lib/smartcloud/grids/redmine.rb +56 -0
  192. data/lib/smartcloud/grids/solr.rb +17 -10
  193. data/lib/smartcloud/machine.rb +170 -20
  194. data/lib/smartcloud/ssh.rb +43 -0
  195. data/lib/smartcloud/templates/dotsmartcloud/{grids/grid-solr/data → apps/containers}/.keep +0 -0
  196. data/lib/smartcloud/templates/dotsmartcloud/{grids/grid-solr/data/lib → apps/repositories}/.keep +0 -0
  197. data/lib/smartcloud/templates/dotsmartcloud/bin/smartcloud.sh +9 -0
  198. data/lib/smartcloud/templates/dotsmartcloud/config/environment.rb +5 -3
  199. data/lib/smartcloud/templates/dotsmartcloud/config/users.yml +4 -0
  200. data/lib/smartcloud/{grids → templates/dotsmartcloud/grids}/grid-nginx/fastcgi.conf +1 -1
  201. data/lib/smartcloud/{grids → templates/dotsmartcloud/grids}/grid-nginx/nginx.tmpl +0 -0
  202. data/lib/smartcloud/templates/dotsmartcloud/grids/{grid-runner → grid-prereceiver}/pre-receive +1 -1
  203. data/lib/smartcloud/templates/dotsmartcloud/grids/grid-redmine/files/.keep +0 -0
  204. data/lib/smartcloud/templates/dotsmartcloud/grids/grid-solr/solr/.keep +0 -0
  205. data/lib/smartcloud/templates/dotsmartcloud/tmp/.keep +0 -0
  206. data/lib/smartcloud/user.rb +11 -45
  207. data/lib/smartcloud/version.rb +13 -0
  208. metadata +228 -185
  209. data/bin/runner +0 -20
  210. data/lib/smartcloud/grids/buildpacker.rb +0 -96
  211. data/lib/smartcloud/grids/runner.rb +0 -404
  212. data/lib/smartcloud/templates/dotsmartcloud/grids/grid-nginx/users.yml +0 -1
  213. data/lib/smartcloud/templates/machine/config/machine.yml +0 -5
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: adafe9e2ccf72714c0082606352ca61345bd7350ff481d36756da5e3d5081898
4
- data.tar.gz: 3d6ded3d6f1ef28480e127087d0af3adb6d802a630057f215aa17f002098c77a
3
+ metadata.gz: 3e7bb97a049814c0c3f7008920644356a8ee69d6ea2396d3105003fc3dd3c5d0
4
+ data.tar.gz: 5e6f3d66f5833a08ce634c80b3d85d4cce1f95fea1eb1896d0ccf6d6abcf7f18
5
5
  SHA512:
6
- metadata.gz: b03934f35ec7a363799e42cf55aee578edbd9f72112303a42bc9265de620f016739f8337b5d047f2f683be6f5cc002f0e1e5cf2170b45566eaf2e55a7239f0f3
7
- data.tar.gz: 5ecf75135df067e5966d047c1cac1c3f2f5e0352fd6f8b74e48f6a416d62d0dd67ce542d6f947f26d18b225e0606323b47959905f3d7392b6384f957ed4a86dd
6
+ metadata.gz: 7d99e4e4169dd773a5ff36152e05f0dabbc5f59155cc2936cc460097862d8edf63153d7173ef5a2796c1849b9a4f5c1cb4b9b7917aec3e312f1c83fb207cc9ad
7
+ data.tar.gz: e3d72619f363bc2d1b2ff368d37e93a859ee6baee6ecb7d8ef044619010563e4847001ff72cdfcfa6ff1efa398f39f69ca07385ca9ba0745e0f2c8731b953fb9
data/README.md CHANGED
@@ -8,7 +8,7 @@ Deploy your Rails apps to your own server with - git push production master
8
8
  After you run the below commands, you get.
9
9
  1. Setup of basic best practices of setting up and securing a VPS server.
10
10
  2. Setup and installation of Docker.
11
- 3. Setup and installation of docker based Mysql, Solr, Nginx, App Runner.
11
+ 3. Setup and installation of docker based Mysql, Solr, Nginx, App Prereceiver.
12
12
  4. Deployment of your Rails apps to your own server with - git push production master
13
13
 
14
14
  ## Setup a New Machine - Ubuntu 18.04 LTS
@@ -67,9 +67,9 @@ $ smartcloud grids solr up
67
67
  ```
68
68
  $ smartcloud grids nginx up
69
69
  ```
70
- 4. Start runner grid:
70
+ 4. Start prereceiver grid:
71
71
  ```
72
- $ smartcloud grids runner up
72
+ $ smartcloud grids prereceiver up
73
73
  ```
74
74
 
75
75
  ## TODO - Creating New App
@@ -2,7 +2,7 @@
2
2
 
3
3
  require 'smartcloud'
4
4
 
5
- if ARGV[0] == 'start'
6
- buildpacker = Smartcloud::Grids::Buildpacker.new
5
+ if ARGV[0] == 'pack'
6
+ buildpacker = Smartcloud::Buildpacker.new
7
7
  buildpacker.pack
8
8
  end
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'smartcloud'
4
+
5
+ if ARGV[0] == 'prereceive'
6
+ raise "Please provide appname, username, oldrev, newrev and refname" unless ARGV[1] && ARGV[2] && ARGV[3] && ARGV[4] && ARGV[5]
7
+ Smartcloud::Grids::Prereceiver.prereceive(ARGV[1], ARGV[2], ARGV[3], ARGV[4], ARGV[5])
8
+ end
@@ -2,73 +2,79 @@
2
2
 
3
3
  require 'smartcloud'
4
4
 
5
- if ARGV[0] == 'init'
6
- Smartcloud::Boot.init
7
- elsif !Smartcloud::Boot.initialized?
8
- puts "Smartcloud has not been initialized. Please run command 'smartcloud init'."
9
- exit
10
- end
5
+ command = ARGV.shift
11
6
 
12
- # if ARGV[0] == 'new'
13
- # machine = Smartcloud::Machine.new
14
- # raise "Please specify machine name" unless ARGV[1]
15
- # machine.create(ARGV[1])
16
- # elsif ARGV[0] == 'install'
17
- # machine = Smartcloud::Machine.new
18
- # machine.install_docker
19
- # machine.install_engine
20
- # elsif ARGV[0] == 'uninstall'
21
- # machine = Smartcloud::Machine.new
22
- # machine.uninstall_engine
23
- # machine.uninstall_docker
24
- # elsif ARGV[0] == 'run'
25
- # machine = Smartcloud::Machine.new
26
- # ARGV.shift
27
- # raise "Please specify command to run" unless ARGV[0]
28
- # machine.run(ARGV)
7
+ if command == '--version'
8
+ puts "Smartcloud #{Smartcloud.version}"
9
+ return
10
+ end
29
11
 
30
- if ARGV[0] == 'docker'
31
- if ARGV[1] == 'install'
32
- Smartcloud::Docker.install
33
- elsif ARGV[1] == 'uninstall'
34
- Smartcloud::Docker.uninstall
12
+ if Smartcloud::Machine.smartcloud_local?
13
+ if command == 'start'
14
+ machine = Smartcloud::Machine.new
15
+ machine.start
16
+ elsif command == 'stop'
17
+ machine = Smartcloud::Machine.new
18
+ machine.stop
19
+ elsif command == 'ssh'
20
+ machine = Smartcloud::Machine.new
21
+ machine.ssh
22
+ elsif command == 'sync'
23
+ machine = Smartcloud::Machine.new
24
+ machine.sync
25
+ elsif command == 'grid'
26
+ machine = Smartcloud::Machine.new
27
+ machine.grid ARGV
28
+ elsif command == 'app'
29
+ machine = Smartcloud::Machine.new
30
+ machine.app ARGV
31
+ elsif command == 'ps'
32
+ ssh = Smartcloud::SSH.new
33
+ ssh.run "smartcloud ps #{ARGV.join(' ')}"
34
+ elsif command == 'logs'
35
+ ssh = Smartcloud::SSH.new
36
+ ssh.run "smartcloud logs #{ARGV.join(' ')}"
37
+ elsif command == 'credentials:edit'
38
+ credentials = Smartcloud::Credentials.new
39
+ credentials.edit
40
+ else
41
+ puts "Specify a valid local command to execute."
35
42
  end
36
- elsif ARGV[0] == 'grids'
37
- if ARGV[1] == 'runner'
38
- if ARGV[2] == 'up'
39
- Smartcloud::Grids::Runner.up
40
- elsif ARGV[2] == 'down'
41
- Smartcloud::Grids::Runner.down
42
- end
43
- elsif ARGV[1] == 'mysql'
44
- if ARGV[2] == 'up'
45
- Smartcloud::Grids::Mysql.up(ARGV[3])
46
- elsif ARGV[2] == 'down'
47
- Smartcloud::Grids::Mysql.down
43
+ elsif Smartcloud::Machine.smartcloud_server?
44
+ if command == 'run'
45
+ machine = Smartcloud::Machine.new
46
+ machine.run ARGV
47
+ elsif command == 'buildpacker'
48
+ buildpacker = Smartcloud::Buildpacker.new
49
+ action = ARGV.shift
50
+ if action == "install"
51
+ buildpacker.install
52
+ elsif action == "uninstall"
53
+ buildpacker.uninstall
48
54
  end
49
- elsif ARGV[1] == 'nginx'
50
- if ARGV[2] == 'up'
51
- Smartcloud::Grids::Nginx.up(ARGV[3])
52
- elsif ARGV[2] == 'down'
53
- Smartcloud::Grids::Nginx.down
54
- end
55
- elsif ARGV[1] == 'solr'
56
- if ARGV[2] == 'up'
57
- Smartcloud::Grids::Solr.up(ARGV[3])
58
- elsif ARGV[2] == 'down'
59
- Smartcloud::Grids::Solr.down
60
- elsif ARGV[2] == 'create_core'
61
- Smartcloud::Grids::Solr.create_core(ARGV[3])
62
- elsif ARGV[2] == 'destroy_core'
63
- Smartcloud::Grids::Solr.destroy_core(ARGV[3])
55
+ elsif command == 'prereceiver'
56
+ prereceiver = Smartcloud::Grids::Prereceiver.new
57
+ action = ARGV.shift
58
+ if action == "install"
59
+ prereceiver.install
60
+ elsif action == "uninstall"
61
+ prereceiver.uninstall
64
62
  end
63
+ elsif command == 'ps'
64
+ exec "docker ps #{ARGV.join(' ')}"
65
+ elsif command == 'logs'
66
+ exec "docker logs #{ARGV.join(' ')}"
67
+ elsif command == 'shell'
68
+ exec '/bin/sh -c sh'
69
+ else
70
+ puts "Specify a valid server command to execute."
65
71
  end
66
- # elsif ARGV[0] == 'user'
67
- # if ARGV[1] == 'create'
68
- # Smartcloud::User.create(ARGV[2], ARGV[3], ARGV[4])
69
- # elsif ARGV[1] == 'destroy'
70
- # Smartcloud::User.destroy(ARGV[2], ARGV[3])
71
- # end
72
72
  else
73
- puts "Specify a command to execute."
73
+ if command == 'new'
74
+ raise "Please specify a machine name" if ARGV.empty?
75
+ machine = Smartcloud::Machine.new
76
+ machine.create ARGV
77
+ else
78
+ puts "Specify a valid smartcloud command to execute. Are you in the correct directory to run this command?"
79
+ end
74
80
  end
@@ -1,12 +1,19 @@
1
1
  require "ostruct"
2
+ require "yaml"
2
3
 
3
4
  # The main Smartcloud driver
4
5
  module Smartcloud
5
6
  def self.config
6
7
  @@config ||= OpenStruct.new
7
8
  end
9
+
10
+ def self.credentials
11
+ @@credentials ||= OpenStruct.new(Smartcloud::Credentials.new.config)
12
+ end
8
13
  end
9
14
 
15
+ require 'smartcloud/version'
16
+
10
17
  Smartcloud.config.root_path = File.expand_path('../..', __FILE__)
11
18
  Smartcloud.config.user_home_path = File.expand_path('~')
12
19
  if File.exist?("#{Smartcloud.config.user_home_path}/.smartcloud/config/environment.rb")
@@ -0,0 +1,182 @@
1
+ # The main Smartcloud App driver
2
+ module Smartcloud
3
+ module Apps
4
+ class App < Smartcloud::Base
5
+ def initialize
6
+ end
7
+
8
+ # Creating App!
9
+ #
10
+ # Example:
11
+ # >> Smartcloud::Apps::Rails.create
12
+ # => Creation Complete
13
+ #
14
+ # Arguments:
15
+ # appname => (String)
16
+ # username => (String)
17
+ def self.create(*args)
18
+ args.flatten!
19
+ appname = args.empty? ? '' : args.shift
20
+ username = args.empty? ? '' : args.shift
21
+
22
+ raise "Please provide appname and username" if appname.empty? || username.empty?
23
+
24
+ if Smartcloud::Docker.running?
25
+ repository_path = "#{Smartcloud.config.user_home_path}/.smartcloud/apps/repositories/#{appname}.git"
26
+ container_path = "#{Smartcloud.config.user_home_path}/.smartcloud/apps/containers/#{appname}"
27
+ print "-----> Creating Application ... "
28
+
29
+ # Checking if app with given name already exists
30
+ if Dir.exist?(repository_path)
31
+ puts "failed. App with name '#{appname}' already exists."
32
+ exit
33
+ end
34
+
35
+ # Creating Directories
36
+ FileUtils.mkdir_p(repository_path)
37
+ FileUtils.mkdir_p(container_path)
38
+
39
+ # Initializing bare repo and pre-receive
40
+ Dir.chdir(repository_path) do
41
+ %x[git init --bare]
42
+ %x[chmod +x #{Smartcloud.config.user_home_path}/.smartcloud/grids/grid-prereceiver/pre-receive]
43
+ %x[ln -s #{Smartcloud.config.user_home_path}/.smartcloud/grids/grid-prereceiver/pre-receive #{repository_path}/hooks/pre-receive]
44
+ puts "done"
45
+ end
46
+
47
+ # Creating Environment File
48
+ if File.exist?("#{Smartcloud.config.user_home_path}/.smartcloud/config/environment.rb")
49
+ require "#{Smartcloud.config.user_home_path}/.smartcloud/config/environment"
50
+ end
51
+ unless File.exist? "#{container_path}/env"
52
+ print "-----> Creating App Environment ... "
53
+ page = <<~HEREDOC
54
+ ## System
55
+ USERNAME=#{username}
56
+ KEEP_RELEASES=3
57
+
58
+ ## Docker
59
+ VIRTUAL_HOST=#{appname}.#{Smartcloud.config.apps_domain}
60
+ LETSENCRYPT_HOST=#{appname}.#{Smartcloud.config.apps_domain}
61
+ LETSENCRYPT_EMAIL=#{Smartcloud.config.sysadmin_email}
62
+ LETSENCRYPT_TEST=false
63
+ HEREDOC
64
+ puts "done" if system("echo '#{page}' > #{container_path}/env")
65
+ end
66
+ end
67
+ end
68
+
69
+ def self.destroy(*args)
70
+ args.flatten!
71
+ appname = args.empty? ? '' : args.shift
72
+
73
+ raise "Please provide appname" if appname.empty?
74
+
75
+ if Smartcloud::Docker.running?
76
+ # Stopping & Removing old container
77
+ self.stop(appname)
78
+
79
+ # Destroying Directories
80
+ print "-----> Deleting App #{appname} ... "
81
+ repository_path = "#{Smartcloud.config.user_home_path}/.smartcloud/apps/repositories/#{appname}.git"
82
+ container_path = "#{Smartcloud.config.user_home_path}/.smartcloud/apps/containers/#{appname}"
83
+ FileUtils.rm_r(repository_path)
84
+ FileUtils.rm_r(container_path)
85
+ puts "done"
86
+ end
87
+ end
88
+
89
+ def self.start(*args)
90
+ args.flatten!
91
+ appname = args.empty? ? '' : args.shift
92
+ app_version = args.empty? ? 0 : args.shift.to_i
93
+
94
+ raise "Please provide appname" if appname.empty?
95
+
96
+ logger.formatter = proc do |severity, datetime, progname, message|
97
+ severity_text = { "DEBUG" => "\u{1f527} #{severity}:", "INFO" => " \u{276f}", "WARN" => "\u{2757} #{severity}:",
98
+ "ERROR" => "\u{274c} #{severity}:", "FATAL" => "\u{2b55} #{severity}:", "UNKNOWN" => "\u{2753} #{severity}:"
99
+ }
100
+ "\t\t\t\t#{severity_text[severity]} #{message}\n"
101
+ end
102
+
103
+ if Smartcloud::Docker.running?
104
+ container_path = "#{Smartcloud.config.user_home_path}/.smartcloud/apps/containers/#{appname}"
105
+
106
+ Dir.chdir("#{container_path}/releases") do
107
+ # Getting App Version
108
+ if app_version == 0
109
+ app_versions = Dir.glob('*').select { |f| File.directory? f }.sort
110
+ app_version = app_versions.last
111
+ end
112
+ container_path_with_version = "#{container_path}/releases/#{app_version}"
113
+
114
+ logger.info "Launching Application ..."
115
+
116
+ app = Smartcloud::Apps::Rails.new
117
+ app.start(appname, container_path, container_path_with_version)
118
+ end
119
+ end
120
+
121
+ logger.formatter = nil
122
+ end
123
+
124
+ def self.stop(*args)
125
+ args.flatten!
126
+ appname = args.empty? ? '' : args.shift
127
+
128
+ raise "Please provide appname" if appname.empty?
129
+
130
+ container_name = appname
131
+
132
+ if Smartcloud::Docker.running?
133
+ container_id = `docker ps -a -q --filter='name=^#{container_name}$'`.chomp
134
+ unless container_id.empty?
135
+ logger.debug "Stopping & Removing container #{container_name} ..."
136
+ if system("docker stop #{container_name} && docker rm #{container_name}", out: File::NULL)
137
+ logger.debug "Stopped & Removed container #{container_name} ..."
138
+ end
139
+ else
140
+ logger.debug "Container '#{container_name}' does not exist to stop."
141
+ end
142
+ end
143
+ end
144
+
145
+ def self.clean_up(container_path)
146
+ env_vars = Smartcloud::Apps::App.get_env_vars(container_path)
147
+ return unless env_vars
148
+
149
+ logger.info "Cleaning up ..."
150
+
151
+ # Clean up very old versions
152
+ Dir.chdir("#{container_path}/releases") do
153
+ app_versions = Dir.glob('*').select { |f| File.directory? f }.sort
154
+ destroy_count = app_versions.count - env_vars['KEEP_RELEASES'].to_i
155
+ if destroy_count > 0
156
+ logger.debug "Deleting older application releases ..."
157
+ destroy_count.times do
158
+ FileUtils.rm_r(File.join(Dir.pwd, app_versions.shift))
159
+ end
160
+ end
161
+ end
162
+ end
163
+
164
+ def self.get_env_vars(container_path)
165
+ unless File.exist? "#{container_path}/env"
166
+ logger.fatal "Environment could not be loaded ... Failed."
167
+ return false
168
+ end
169
+
170
+ env_vars = {}
171
+ File.open("#{container_path}/env").each_line do |line|
172
+ line.chomp!
173
+ next if line.empty? || line.start_with?('#')
174
+ key, value = line.split "="
175
+ env_vars[key] = value
176
+ end
177
+
178
+ env_vars
179
+ end
180
+ end
181
+ end
182
+ end
@@ -0,0 +1,240 @@
1
+ # The main Smartcloud Apps Rails driver
2
+ module Smartcloud
3
+ module Apps
4
+ class Rails < Smartcloud::Base
5
+ def initialize
6
+ end
7
+
8
+ def start(appname, container_path, container_path_with_version)
9
+ return unless File.exist? "#{container_path_with_version}/bin/rails"
10
+
11
+ logger.formatter = proc do |severity, datetime, progname, message|
12
+ severity_text = { "DEBUG" => "\u{1f527} #{severity}:", "INFO" => " \u{276f}", "WARN" => "\u{2757} #{severity}:",
13
+ "ERROR" => "\u{274c} #{severity}:", "FATAL" => "\u{2b55} #{severity}:", "UNKNOWN" => "\u{2753} #{severity}:"
14
+ }
15
+ "\t\t\t\t#{severity_text[severity]} #{message}\n"
16
+ end
17
+
18
+ logger.info "Ruby on Rails application detected."
19
+
20
+ # Setup rails env
21
+ env_path = "#{container_path}/env"
22
+ system("grep -q '^## Rails' #{env_path} || echo '## Rails' >> #{env_path}")
23
+ system("grep -q '^MALLOC_ARENA_MAX=' #{env_path} || echo '# MALLOC_ARENA_MAX=2' >> #{env_path}")
24
+ system("grep -q '^RAILS_ENV=' #{env_path} || echo 'RAILS_ENV=production' >> #{env_path}")
25
+ system("grep -q '^RACK_ENV=' #{env_path} || echo 'RACK_ENV=production' >> #{env_path}")
26
+ system("grep -q '^RAILS_LOG_TO_STDOUT=' #{env_path} || echo 'RAILS_LOG_TO_STDOUT=enabled' >> #{env_path}")
27
+ system("grep -q '^RAILS_SERVE_STATIC_FILES=' #{env_path} || echo 'RAILS_SERVE_STATIC_FILES=enabled' >> #{env_path}")
28
+ system("grep -q '^LANG=' #{env_path} || echo 'LANG=en_US.UTF-8' >> #{env_path}")
29
+ system("grep -q '^RAILS_MASTER_KEY=' #{env_path} || echo 'RAILS_MASTER_KEY=yourmasterkey' >> #{env_path}")
30
+ logger.warn "Please set your RAILS_MASTER_KEY env var for this rails app." if system("grep -q '^RAILS_MASTER_KEY=yourmasterkey' #{env_path}")
31
+
32
+ # Setup app folders needed for volumes. If this is not created then docker will create it while running the container,
33
+ # but the folder will have root user assigned instead of the current user.
34
+ FileUtils.mkdir_p("#{container_path}/app/vendor/bundle")
35
+ FileUtils.mkdir_p("#{container_path}/app/public/assets")
36
+ FileUtils.mkdir_p("#{container_path}/app/public/packs")
37
+ FileUtils.mkdir_p("#{container_path}/app/node_modules")
38
+ FileUtils.mkdir_p("#{container_path_with_version}/vendor/bundle")
39
+ FileUtils.mkdir_p("#{container_path_with_version}/public/assets")
40
+ FileUtils.mkdir_p("#{container_path_with_version}/public/packs")
41
+ FileUtils.mkdir_p("#{container_path_with_version}/node_modules")
42
+
43
+ # Creating & Starting container
44
+ container_id = `docker ps -a -q --filter='name=^#{appname}_1$' --filter='status=running'`.chomp
45
+ new_container = container_id.empty? ? "#{appname}_1" : "#{appname}_2"
46
+ old_container = container_id.empty? ? "#{appname}_2" : "#{appname}_1"
47
+
48
+ Smartcloud::Apps::App.stop("#{new_container}")
49
+ if system("docker create \
50
+ --name='#{new_container}' \
51
+ --env-file='#{container_path}/env' \
52
+ --user `id -u`:`id -g` \
53
+ --workdir /app \
54
+ --expose='3000' \
55
+ --volume='#{Smartcloud.config.user_home_path}/.smartcloud/config:#{Smartcloud.config.user_home_path}/.smartcloud/config' \
56
+ --volume='#{container_path_with_version}:/app' \
57
+ --volume='#{container_path}/app/vendor/bundle:/app/vendor/bundle' \
58
+ --volume='#{container_path}/app/public:/app/public/assets' \
59
+ --volume='#{container_path}/app/public:/app/public/packs' \
60
+ --volume='#{container_path}/app/node_modules:/app/node_modules' \
61
+ --restart='always' \
62
+ --init \
63
+ --network='nginx-network' \
64
+ smartcloud/buildpacks/rails", out: File::NULL)
65
+
66
+ # system("docker network connect solr-network #{new_container}")
67
+ system("docker network connect mysql-network #{new_container}")
68
+
69
+ if system("docker start --attach #{new_container}")
70
+ logger.debug "Starting Web Server ..."
71
+ if system("docker start #{new_container}", out: File::NULL)
72
+ sleep 7
73
+ logger.info "Web Server started successfully."
74
+ Smartcloud::Apps::App.stop(old_container)
75
+ Smartcloud::Apps::App.clean_up(container_path)
76
+ logger.info "Launched Application ... Success."
77
+ exit 10
78
+ end
79
+ else
80
+ Smartcloud::Apps::App.stop("#{new_container}")
81
+ end
82
+ end
83
+
84
+ logger.formatter = nil
85
+ end
86
+
87
+ def pack
88
+ set_logger_formatter_arrow
89
+
90
+ if File.exist? "tmp/smartcloud/packed"
91
+ begin
92
+ pid = File.read('tmp/smartcloud/packed').to_i
93
+ Process.kill('QUIT', pid)
94
+ rescue Errno::ESRCH # No such process
95
+ end
96
+ exec "bundle", "exec", "puma", "--config", "config/puma.rb"
97
+ else
98
+ if initial_setup? && bundle_install? && precompile_assets? && db_migrate? && test_web_server?
99
+ logger.formatter = nil
100
+
101
+ exit 0
102
+ else
103
+ logger.error "Could not continue ... Launch Failed."
104
+ logger.formatter = nil
105
+
106
+ exit 1
107
+ end
108
+ end
109
+ end
110
+
111
+ private
112
+
113
+ # Perform initial_setup
114
+ def initial_setup?
115
+ logger.info "Performing initial setup ..."
116
+
117
+ exit_status = nil
118
+
119
+ # Fix for mysql2 gem to support sha256_password, until it is fixed in main mysql2 gem.
120
+ # https://github.com/brianmario/mysql2/issues/1023
121
+ exit_status = system("mkdir ./lib/mariadb && ln -s /usr/lib/mariadb/plugin ./lib/mariadb/plugin")
122
+
123
+ if exit_status
124
+ return true
125
+ else
126
+ logger.error "Could not complete initial setup."
127
+ return false
128
+ end
129
+ end
130
+
131
+ # Perform bundle install
132
+ def bundle_install?
133
+ logger.info "Performing bundle install ..."
134
+
135
+ set_logger_formatter_tabs
136
+ exit_status = nil
137
+ Open3.popen2e("bundle", "install", "--deployment", "--clean") do |stdin, stdout_and_stderr, wait_thr|
138
+ stdout_and_stderr.each { |line| logger.info "#{line}" }
139
+ exit_status = wait_thr.value.success?
140
+ end
141
+ set_logger_formatter_arrow
142
+
143
+ if exit_status
144
+ return true
145
+ else
146
+ logger.error "Could not complete bundle install."
147
+ return false
148
+ end
149
+ end
150
+
151
+ # Perform pre-compiling of assets
152
+ def precompile_assets?
153
+ logger.info "Installing Javascript dependencies & pre-compiling assets ..."
154
+
155
+ set_logger_formatter_tabs
156
+ exit_status = nil
157
+ Open3.popen2e("bundle", "exec", "rails", "assets:precompile") do |stdin, stdout_and_stderr, wait_thr|
158
+ stdout_and_stderr.each { |line| logger.info "#{line}" }
159
+ exit_status = wait_thr.value.success?
160
+ end
161
+ set_logger_formatter_arrow
162
+
163
+ if exit_status
164
+ return true
165
+ else
166
+ logger.error "Could not install Javascript dependencies or pre-compile assets."
167
+ return false
168
+ end
169
+ end
170
+
171
+ # Perform db_migrate
172
+ def db_migrate?
173
+ return true # remove this line when you want to start using db_migrate?
174
+
175
+ logger.info "Performing database migrations ..."
176
+
177
+ set_logger_formatter_tabs
178
+ exit_status = nil
179
+ Open3.popen2e("bundle", "exec", "rails", "db:migrate") do |stdin, stdout_and_stderr, wait_thr|
180
+ stdout_and_stderr.each { |line| logger.info "#{line}" }
181
+ exit_status = wait_thr.value.success?
182
+ end
183
+ set_logger_formatter_arrow
184
+
185
+ if exit_status
186
+ return true
187
+ else
188
+ logger.error "Could not complete database migrations."
189
+ return false
190
+ end
191
+ end
192
+
193
+ # Perform testing of web server
194
+ def test_web_server?
195
+ logger.info "Setting up Web Server ..."
196
+
197
+ # tmp folders
198
+ FileUtils.mkdir_p("tmp/pids")
199
+ FileUtils.mkdir_p("tmp/smartcloud")
200
+ FileUtils.rm_f("tmp/smartcloud/packed")
201
+
202
+ # Spawn Process
203
+ pid = Process.spawn("bundle", "exec", "puma", "--config", "config/puma.rb", out: File::NULL)
204
+ Process.detach(pid)
205
+
206
+ # Sleep
207
+ sleep 5
208
+
209
+ # Check PID running
210
+ status = nil
211
+ begin
212
+ Process.kill(0, pid)
213
+ system("echo '#{pid}' > tmp/smartcloud/packed")
214
+ status = true
215
+ rescue Errno::ESRCH # No such process
216
+ logger.info "Web Server could not start"
217
+ status = false
218
+ end
219
+
220
+ # Return status
221
+ return status
222
+ end
223
+
224
+ def set_logger_formatter_arrow
225
+ logger.formatter = proc do |severity, datetime, progname, message|
226
+ severity_text = { "DEBUG" => "\u{1f527} #{severity}:", "INFO" => " \u{276f}", "WARN" => "\u{2757} #{severity}:",
227
+ "ERROR" => "\u{274c} #{severity}:", "FATAL" => "\u{2b55} #{severity}:", "UNKNOWN" => "\u{2753} #{severity}:"
228
+ }
229
+ "\t\t\t\t#{severity_text[severity]} #{message}\n"
230
+ end
231
+ end
232
+
233
+ def set_logger_formatter_tabs
234
+ logger.formatter = proc do |severity, datetime, progname, message|
235
+ "\t\t\t\t #{message}"
236
+ end
237
+ end
238
+ end
239
+ end
240
+ end