smartmachine 0.6.0 → 0.7.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.rdoc +0 -0
- data/README.rdoc +87 -0
- data/bin/buildpacker +8 -0
- data/bin/prereceiver +8 -0
- data/bin/smartmachine +81 -0
- data/bin/smartrunner +28 -0
- data/lib/smart_machine.rb +24 -0
- data/lib/smart_machine/apps.rb +14 -0
- data/lib/smart_machine/apps/app.rb +182 -0
- data/lib/smart_machine/apps/rails.rb +250 -0
- data/lib/smart_machine/base.rb +11 -0
- data/lib/smart_machine/boot.rb +31 -0
- data/lib/smart_machine/buildpacker.rb +106 -0
- data/lib/smart_machine/credentials.rb +126 -0
- data/lib/smart_machine/docker.rb +144 -0
- data/lib/smart_machine/engine.rb +82 -0
- data/lib/smart_machine/engine/Dockerfile +27 -0
- data/lib/smart_machine/engine/buildpacks/rails/Dockerfile +21 -0
- data/lib/smart_machine/gem_version.rb +17 -0
- data/lib/smart_machine/grids.rb +15 -0
- data/lib/smart_machine/grids/elasticsearch.rb +97 -0
- data/lib/smart_machine/grids/elasticsearch/.keep +0 -0
- data/lib/smart_machine/grids/minio.rb +77 -0
- data/lib/smart_machine/grids/minio/.keep +0 -0
- data/lib/smart_machine/grids/mysql.rb +66 -0
- data/lib/smart_machine/grids/mysql/docker-entrypoint-initdb.d/.keep +0 -0
- data/lib/smart_machine/grids/nginx.rb +137 -0
- data/lib/smart_machine/grids/nginx/.keep +0 -0
- data/lib/smart_machine/grids/prereceiver.rb +170 -0
- data/lib/smart_machine/grids/prereceiver/Dockerfile +20 -0
- data/lib/smart_machine/grids/prereceiver/fcgiwrap/APKBUILD +49 -0
- data/lib/smart_machine/grids/prereceiver/fcgiwrap/fcgiwrap.confd +6 -0
- data/lib/smart_machine/grids/prereceiver/fcgiwrap/fcgiwrap.initd +43 -0
- data/lib/smart_machine/grids/prereceiver/fcgiwrap/fcgiwrap.pre-install +7 -0
- data/lib/smart_machine/grids/prereceiver/fcgiwrap/packages/main/x86_64/APKINDEX.tar.gz +0 -0
- data/lib/smart_machine/grids/prereceiver/fcgiwrap/packages/main/x86_64/fcgiwrap-1.1.1-r4.apk +0 -0
- data/lib/smart_machine/grids/prereceiver/fcgiwrap/packages/main/x86_64/fcgiwrap-doc-1.1.1-r4.apk +0 -0
- data/lib/smart_machine/grids/prereceiver/fcgiwrap/packages/main/x86_64/fcgiwrap-openrc-1.1.1-r4.apk +0 -0
- data/lib/smart_machine/grids/redis.rb +58 -0
- data/lib/smart_machine/grids/redis/.keep +0 -0
- data/lib/smart_machine/grids/solr.rb +99 -0
- data/lib/smart_machine/grids/solr/config/.keep +0 -0
- data/lib/smart_machine/grids/solr/config/README.txt +77 -0
- data/lib/smart_machine/grids/solr/config/configsets/_default/conf/lang/contractions_ca.txt +8 -0
- data/lib/smart_machine/grids/solr/config/configsets/_default/conf/lang/contractions_fr.txt +15 -0
- data/lib/smart_machine/grids/solr/config/configsets/_default/conf/lang/contractions_ga.txt +5 -0
- data/lib/smart_machine/grids/solr/config/configsets/_default/conf/lang/contractions_it.txt +23 -0
- data/lib/smart_machine/grids/solr/config/configsets/_default/conf/lang/hyphenations_ga.txt +5 -0
- data/lib/smart_machine/grids/solr/config/configsets/_default/conf/lang/stemdict_nl.txt +6 -0
- data/lib/smart_machine/grids/solr/config/configsets/_default/conf/lang/stoptags_ja.txt +420 -0
- data/lib/smart_machine/grids/solr/config/configsets/_default/conf/lang/stopwords_ar.txt +125 -0
- data/lib/smart_machine/grids/solr/config/configsets/_default/conf/lang/stopwords_bg.txt +193 -0
- data/lib/smart_machine/grids/solr/config/configsets/_default/conf/lang/stopwords_ca.txt +220 -0
- data/lib/smart_machine/grids/solr/config/configsets/_default/conf/lang/stopwords_cz.txt +172 -0
- data/lib/smart_machine/grids/solr/config/configsets/_default/conf/lang/stopwords_da.txt +110 -0
- data/lib/smart_machine/grids/solr/config/configsets/_default/conf/lang/stopwords_de.txt +294 -0
- data/lib/smart_machine/grids/solr/config/configsets/_default/conf/lang/stopwords_el.txt +78 -0
- data/lib/smart_machine/grids/solr/config/configsets/_default/conf/lang/stopwords_en.txt +54 -0
- data/lib/smart_machine/grids/solr/config/configsets/_default/conf/lang/stopwords_es.txt +356 -0
- data/lib/smart_machine/grids/solr/config/configsets/_default/conf/lang/stopwords_eu.txt +99 -0
- data/lib/smart_machine/grids/solr/config/configsets/_default/conf/lang/stopwords_fa.txt +313 -0
- data/lib/smart_machine/grids/solr/config/configsets/_default/conf/lang/stopwords_fi.txt +97 -0
- data/lib/smart_machine/grids/solr/config/configsets/_default/conf/lang/stopwords_fr.txt +186 -0
- data/lib/smart_machine/grids/solr/config/configsets/_default/conf/lang/stopwords_ga.txt +110 -0
- data/lib/smart_machine/grids/solr/config/configsets/_default/conf/lang/stopwords_gl.txt +161 -0
- data/lib/smart_machine/grids/solr/config/configsets/_default/conf/lang/stopwords_hi.txt +235 -0
- data/lib/smart_machine/grids/solr/config/configsets/_default/conf/lang/stopwords_hu.txt +211 -0
- data/lib/smart_machine/grids/solr/config/configsets/_default/conf/lang/stopwords_hy.txt +46 -0
- data/lib/smart_machine/grids/solr/config/configsets/_default/conf/lang/stopwords_id.txt +359 -0
- data/lib/smart_machine/grids/solr/config/configsets/_default/conf/lang/stopwords_it.txt +303 -0
- data/lib/smart_machine/grids/solr/config/configsets/_default/conf/lang/stopwords_ja.txt +127 -0
- data/lib/smart_machine/grids/solr/config/configsets/_default/conf/lang/stopwords_lv.txt +172 -0
- data/lib/smart_machine/grids/solr/config/configsets/_default/conf/lang/stopwords_nl.txt +119 -0
- data/lib/smart_machine/grids/solr/config/configsets/_default/conf/lang/stopwords_no.txt +194 -0
- data/lib/smart_machine/grids/solr/config/configsets/_default/conf/lang/stopwords_pt.txt +253 -0
- data/lib/smart_machine/grids/solr/config/configsets/_default/conf/lang/stopwords_ro.txt +233 -0
- data/lib/smart_machine/grids/solr/config/configsets/_default/conf/lang/stopwords_ru.txt +243 -0
- data/lib/smart_machine/grids/solr/config/configsets/_default/conf/lang/stopwords_sv.txt +133 -0
- data/lib/smart_machine/grids/solr/config/configsets/_default/conf/lang/stopwords_th.txt +119 -0
- data/lib/smart_machine/grids/solr/config/configsets/_default/conf/lang/stopwords_tr.txt +212 -0
- data/lib/smart_machine/grids/solr/config/configsets/_default/conf/lang/userdict_ja.txt +29 -0
- data/lib/smart_machine/grids/solr/config/configsets/_default/conf/managed-schema +1007 -0
- data/lib/smart_machine/grids/solr/config/configsets/_default/conf/params.json +20 -0
- data/lib/smart_machine/grids/solr/config/configsets/_default/conf/protwords.txt +21 -0
- data/lib/smart_machine/grids/solr/config/configsets/_default/conf/solrconfig.xml +1355 -0
- data/lib/smart_machine/grids/solr/config/configsets/_default/conf/stopwords.txt +14 -0
- data/lib/smart_machine/grids/solr/config/configsets/_default/conf/synonyms.txt +29 -0
- data/lib/smart_machine/grids/solr/config/configsets/sample_techproducts_configs/conf/_rest_managed.json +1 -0
- data/lib/smart_machine/grids/solr/config/configsets/sample_techproducts_configs/conf/_schema_analysis_stopwords_english.json +38 -0
- data/lib/smart_machine/grids/solr/config/configsets/sample_techproducts_configs/conf/_schema_analysis_synonyms_english.json +11 -0
- data/lib/smart_machine/grids/solr/config/configsets/sample_techproducts_configs/conf/clustering/carrot2/README.txt +11 -0
- data/lib/smart_machine/grids/solr/config/configsets/sample_techproducts_configs/conf/clustering/carrot2/kmeans-attributes.xml +19 -0
- data/lib/smart_machine/grids/solr/config/configsets/sample_techproducts_configs/conf/clustering/carrot2/lingo-attributes.xml +24 -0
- data/lib/smart_machine/grids/solr/config/configsets/sample_techproducts_configs/conf/clustering/carrot2/stc-attributes.xml +19 -0
- data/lib/smart_machine/grids/solr/config/configsets/sample_techproducts_configs/conf/currency.xml +67 -0
- data/lib/smart_machine/grids/solr/config/configsets/sample_techproducts_configs/conf/elevate.xml +42 -0
- data/lib/smart_machine/grids/solr/config/configsets/sample_techproducts_configs/conf/lang/contractions_ca.txt +8 -0
- data/lib/smart_machine/grids/solr/config/configsets/sample_techproducts_configs/conf/lang/contractions_fr.txt +15 -0
- data/lib/smart_machine/grids/solr/config/configsets/sample_techproducts_configs/conf/lang/contractions_ga.txt +5 -0
- data/lib/smart_machine/grids/solr/config/configsets/sample_techproducts_configs/conf/lang/contractions_it.txt +23 -0
- data/lib/smart_machine/grids/solr/config/configsets/sample_techproducts_configs/conf/lang/hyphenations_ga.txt +5 -0
- data/lib/smart_machine/grids/solr/config/configsets/sample_techproducts_configs/conf/lang/stemdict_nl.txt +6 -0
- data/lib/smart_machine/grids/solr/config/configsets/sample_techproducts_configs/conf/lang/stoptags_ja.txt +420 -0
- data/lib/smart_machine/grids/solr/config/configsets/sample_techproducts_configs/conf/lang/stopwords_ar.txt +125 -0
- data/lib/smart_machine/grids/solr/config/configsets/sample_techproducts_configs/conf/lang/stopwords_bg.txt +193 -0
- data/lib/smart_machine/grids/solr/config/configsets/sample_techproducts_configs/conf/lang/stopwords_ca.txt +220 -0
- data/lib/smart_machine/grids/solr/config/configsets/sample_techproducts_configs/conf/lang/stopwords_ckb.txt +136 -0
- data/lib/smart_machine/grids/solr/config/configsets/sample_techproducts_configs/conf/lang/stopwords_cz.txt +172 -0
- data/lib/smart_machine/grids/solr/config/configsets/sample_techproducts_configs/conf/lang/stopwords_da.txt +110 -0
- data/lib/smart_machine/grids/solr/config/configsets/sample_techproducts_configs/conf/lang/stopwords_de.txt +294 -0
- data/lib/smart_machine/grids/solr/config/configsets/sample_techproducts_configs/conf/lang/stopwords_el.txt +78 -0
- data/lib/smart_machine/grids/solr/config/configsets/sample_techproducts_configs/conf/lang/stopwords_en.txt +54 -0
- data/lib/smart_machine/grids/solr/config/configsets/sample_techproducts_configs/conf/lang/stopwords_es.txt +356 -0
- data/lib/smart_machine/grids/solr/config/configsets/sample_techproducts_configs/conf/lang/stopwords_eu.txt +99 -0
- data/lib/smart_machine/grids/solr/config/configsets/sample_techproducts_configs/conf/lang/stopwords_fa.txt +313 -0
- data/lib/smart_machine/grids/solr/config/configsets/sample_techproducts_configs/conf/lang/stopwords_fi.txt +97 -0
- data/lib/smart_machine/grids/solr/config/configsets/sample_techproducts_configs/conf/lang/stopwords_fr.txt +186 -0
- data/lib/smart_machine/grids/solr/config/configsets/sample_techproducts_configs/conf/lang/stopwords_ga.txt +110 -0
- data/lib/smart_machine/grids/solr/config/configsets/sample_techproducts_configs/conf/lang/stopwords_gl.txt +161 -0
- data/lib/smart_machine/grids/solr/config/configsets/sample_techproducts_configs/conf/lang/stopwords_hi.txt +235 -0
- data/lib/smart_machine/grids/solr/config/configsets/sample_techproducts_configs/conf/lang/stopwords_hu.txt +211 -0
- data/lib/smart_machine/grids/solr/config/configsets/sample_techproducts_configs/conf/lang/stopwords_hy.txt +46 -0
- data/lib/smart_machine/grids/solr/config/configsets/sample_techproducts_configs/conf/lang/stopwords_id.txt +359 -0
- data/lib/smart_machine/grids/solr/config/configsets/sample_techproducts_configs/conf/lang/stopwords_it.txt +303 -0
- data/lib/smart_machine/grids/solr/config/configsets/sample_techproducts_configs/conf/lang/stopwords_ja.txt +127 -0
- data/lib/smart_machine/grids/solr/config/configsets/sample_techproducts_configs/conf/lang/stopwords_lv.txt +172 -0
- data/lib/smart_machine/grids/solr/config/configsets/sample_techproducts_configs/conf/lang/stopwords_nl.txt +119 -0
- data/lib/smart_machine/grids/solr/config/configsets/sample_techproducts_configs/conf/lang/stopwords_no.txt +194 -0
- data/lib/smart_machine/grids/solr/config/configsets/sample_techproducts_configs/conf/lang/stopwords_pt.txt +253 -0
- data/lib/smart_machine/grids/solr/config/configsets/sample_techproducts_configs/conf/lang/stopwords_ro.txt +233 -0
- data/lib/smart_machine/grids/solr/config/configsets/sample_techproducts_configs/conf/lang/stopwords_ru.txt +243 -0
- data/lib/smart_machine/grids/solr/config/configsets/sample_techproducts_configs/conf/lang/stopwords_sv.txt +133 -0
- data/lib/smart_machine/grids/solr/config/configsets/sample_techproducts_configs/conf/lang/stopwords_th.txt +119 -0
- data/lib/smart_machine/grids/solr/config/configsets/sample_techproducts_configs/conf/lang/stopwords_tr.txt +212 -0
- data/lib/smart_machine/grids/solr/config/configsets/sample_techproducts_configs/conf/lang/userdict_ja.txt +29 -0
- data/lib/smart_machine/grids/solr/config/configsets/sample_techproducts_configs/conf/managed-schema +1187 -0
- data/lib/smart_machine/grids/solr/config/configsets/sample_techproducts_configs/conf/mapping-FoldToASCII.txt +3813 -0
- data/lib/smart_machine/grids/solr/config/configsets/sample_techproducts_configs/conf/mapping-ISOLatin1Accent.txt +246 -0
- data/lib/smart_machine/grids/solr/config/configsets/sample_techproducts_configs/conf/params.json +11 -0
- data/lib/smart_machine/grids/solr/config/configsets/sample_techproducts_configs/conf/protwords.txt +21 -0
- data/lib/smart_machine/grids/solr/config/configsets/sample_techproducts_configs/conf/solrconfig.xml +1616 -0
- data/lib/smart_machine/grids/solr/config/configsets/sample_techproducts_configs/conf/spellings.txt +2 -0
- data/lib/smart_machine/grids/solr/config/configsets/sample_techproducts_configs/conf/stopwords.txt +14 -0
- data/lib/smart_machine/grids/solr/config/configsets/sample_techproducts_configs/conf/synonyms.txt +29 -0
- data/lib/smart_machine/grids/solr/config/configsets/sample_techproducts_configs/conf/update-script.js +53 -0
- data/lib/smart_machine/grids/solr/config/configsets/sample_techproducts_configs/conf/velocity/README.txt +101 -0
- data/lib/smart_machine/grids/solr/config/configsets/sample_techproducts_configs/conf/velocity/VM_global_library.vm +186 -0
- data/lib/smart_machine/grids/solr/config/configsets/sample_techproducts_configs/conf/velocity/browse.vm +33 -0
- data/lib/smart_machine/grids/solr/config/configsets/sample_techproducts_configs/conf/velocity/cluster.vm +19 -0
- data/lib/smart_machine/grids/solr/config/configsets/sample_techproducts_configs/conf/velocity/cluster_results.vm +31 -0
- data/lib/smart_machine/grids/solr/config/configsets/sample_techproducts_configs/conf/velocity/debug.vm +28 -0
- data/lib/smart_machine/grids/solr/config/configsets/sample_techproducts_configs/conf/velocity/did_you_mean.vm +11 -0
- data/lib/smart_machine/grids/solr/config/configsets/sample_techproducts_configs/conf/velocity/error.vm +11 -0
- data/lib/smart_machine/grids/solr/config/configsets/sample_techproducts_configs/conf/velocity/facet_fields.vm +24 -0
- data/lib/smart_machine/grids/solr/config/configsets/sample_techproducts_configs/conf/velocity/facet_pivot.vm +12 -0
- data/lib/smart_machine/grids/solr/config/configsets/sample_techproducts_configs/conf/velocity/facet_queries.vm +12 -0
- data/lib/smart_machine/grids/solr/config/configsets/sample_techproducts_configs/conf/velocity/facet_ranges.vm +23 -0
- data/lib/smart_machine/grids/solr/config/configsets/sample_techproducts_configs/conf/velocity/facets.vm +10 -0
- data/lib/smart_machine/grids/solr/config/configsets/sample_techproducts_configs/conf/velocity/footer.vm +43 -0
- data/lib/smart_machine/grids/solr/config/configsets/sample_techproducts_configs/conf/velocity/head.vm +37 -0
- data/lib/smart_machine/grids/solr/config/configsets/sample_techproducts_configs/conf/velocity/header.vm +7 -0
- data/lib/smart_machine/grids/solr/config/configsets/sample_techproducts_configs/conf/velocity/hit.vm +25 -0
- data/lib/smart_machine/grids/solr/config/configsets/sample_techproducts_configs/conf/velocity/hit_grouped.vm +43 -0
- data/lib/smart_machine/grids/solr/config/configsets/sample_techproducts_configs/conf/velocity/hit_plain.vm +25 -0
- data/lib/smart_machine/grids/solr/config/configsets/sample_techproducts_configs/conf/velocity/join_doc.vm +20 -0
- data/lib/smart_machine/grids/solr/config/configsets/sample_techproducts_configs/conf/velocity/jquery.autocomplete.css +48 -0
- data/lib/smart_machine/grids/solr/config/configsets/sample_techproducts_configs/conf/velocity/jquery.autocomplete.js +763 -0
- data/lib/smart_machine/grids/solr/config/configsets/sample_techproducts_configs/conf/velocity/layout.vm +24 -0
- data/lib/smart_machine/grids/solr/config/configsets/sample_techproducts_configs/conf/velocity/main.css +231 -0
- data/lib/smart_machine/grids/solr/config/configsets/sample_techproducts_configs/conf/velocity/mime_type_lists.vm +68 -0
- data/lib/smart_machine/grids/solr/config/configsets/sample_techproducts_configs/conf/velocity/pagination_bottom.vm +22 -0
- data/lib/smart_machine/grids/solr/config/configsets/sample_techproducts_configs/conf/velocity/pagination_top.vm +29 -0
- data/lib/smart_machine/grids/solr/config/configsets/sample_techproducts_configs/conf/velocity/product_doc.vm +32 -0
- data/lib/smart_machine/grids/solr/config/configsets/sample_techproducts_configs/conf/velocity/query.vm +42 -0
- data/lib/smart_machine/grids/solr/config/configsets/sample_techproducts_configs/conf/velocity/query_form.vm +64 -0
- data/lib/smart_machine/grids/solr/config/configsets/sample_techproducts_configs/conf/velocity/query_group.vm +43 -0
- data/lib/smart_machine/grids/solr/config/configsets/sample_techproducts_configs/conf/velocity/query_spatial.vm +75 -0
- data/lib/smart_machine/grids/solr/config/configsets/sample_techproducts_configs/conf/velocity/results_list.vm +22 -0
- data/lib/smart_machine/grids/solr/config/configsets/sample_techproducts_configs/conf/velocity/richtext_doc.vm +153 -0
- data/lib/smart_machine/grids/solr/config/configsets/sample_techproducts_configs/conf/velocity/suggest.vm +8 -0
- data/lib/smart_machine/grids/solr/config/configsets/sample_techproducts_configs/conf/velocity/tabs.vm +50 -0
- data/lib/smart_machine/grids/solr/config/configsets/sample_techproducts_configs/conf/xslt/example.xsl +132 -0
- data/lib/smart_machine/grids/solr/config/configsets/sample_techproducts_configs/conf/xslt/example_atom.xsl +67 -0
- data/lib/smart_machine/grids/solr/config/configsets/sample_techproducts_configs/conf/xslt/example_rss.xsl +66 -0
- data/lib/smart_machine/grids/solr/config/configsets/sample_techproducts_configs/conf/xslt/luke.xsl +337 -0
- data/lib/smart_machine/grids/solr/config/configsets/sample_techproducts_configs/conf/xslt/updateXml.xsl +70 -0
- data/lib/smart_machine/grids/solr/config/configsets/sunspot/conf/_rest_managed.json +1 -0
- data/lib/smart_machine/grids/solr/config/configsets/sunspot/conf/admin-extra.html +31 -0
- data/lib/smart_machine/grids/solr/config/configsets/sunspot/conf/currency.xml +67 -0
- data/lib/smart_machine/grids/solr/config/configsets/sunspot/conf/elevate.xml +36 -0
- data/lib/smart_machine/grids/solr/config/configsets/sunspot/conf/lang/stopwords_en.txt +54 -0
- data/lib/smart_machine/grids/solr/config/configsets/sunspot/conf/mapping-ISOLatin1Accent.txt +246 -0
- data/lib/smart_machine/grids/solr/config/configsets/sunspot/conf/protwords.txt +21 -0
- data/lib/smart_machine/grids/solr/config/configsets/sunspot/conf/schema.xml +278 -0
- data/lib/smart_machine/grids/solr/config/configsets/sunspot/conf/scripts.conf +24 -0
- data/lib/smart_machine/grids/solr/config/configsets/sunspot/conf/solrconfig.xml +632 -0
- data/lib/smart_machine/grids/solr/config/configsets/sunspot/conf/spellings.txt +2 -0
- data/lib/smart_machine/grids/solr/config/configsets/sunspot/conf/synonyms.txt +29 -0
- data/lib/smart_machine/grids/solr/config/lib/.keep +0 -0
- data/lib/smart_machine/grids/solr/config/solr.xml +53 -0
- data/lib/smart_machine/grids/solr/config/zoo.cfg +31 -0
- data/lib/smart_machine/grids/solr/docker-entrypoint-initdb.d/.keep +0 -0
- data/lib/smart_machine/grids/solr/sunspot/conf/schema.xml +278 -0
- data/lib/smart_machine/grids/solr/sunspot/conf/solrconfig.xml +632 -0
- data/lib/smart_machine/logger.rb +35 -0
- data/lib/smart_machine/machine.rb +192 -0
- data/lib/smart_machine/ssh.rb +43 -0
- data/lib/smart_machine/sync.rb +108 -0
- data/lib/smart_machine/templates/dotsmartmachine/apps/containers/.keep +0 -0
- data/lib/smart_machine/templates/dotsmartmachine/apps/repositories/.keep +0 -0
- data/lib/smart_machine/templates/dotsmartmachine/config/environment.rb +18 -0
- data/lib/smart_machine/templates/dotsmartmachine/config/users.yml +4 -0
- data/lib/smart_machine/templates/dotsmartmachine/grids/elasticsearch/data/.keep +0 -0
- data/lib/smart_machine/templates/dotsmartmachine/grids/elasticsearch/logs/.keep +0 -0
- data/lib/smart_machine/templates/dotsmartmachine/grids/minio/data/.keep +0 -0
- data/lib/smart_machine/templates/dotsmartmachine/grids/mysql/data/.keep +0 -0
- data/lib/smart_machine/templates/dotsmartmachine/grids/nginx/certificates/.keep +0 -0
- data/lib/smart_machine/templates/dotsmartmachine/grids/nginx/fastcgi.conf +11 -0
- data/lib/smart_machine/templates/dotsmartmachine/grids/nginx/htpasswd/.keep +0 -0
- data/lib/smart_machine/templates/dotsmartmachine/grids/nginx/nginx.tmpl +373 -0
- data/lib/smart_machine/templates/dotsmartmachine/grids/prereceiver/pre-receive +17 -0
- data/lib/smart_machine/templates/dotsmartmachine/grids/redis/data/.keep +0 -0
- data/lib/smart_machine/templates/dotsmartmachine/grids/solr/solr/.keep +0 -0
- data/lib/smart_machine/templates/dotsmartmachine/tmp/.keep +0 -0
- data/lib/smart_machine/user.rb +38 -0
- data/lib/smart_machine/version.rb +10 -0
- metadata +297 -12
- data/README.md +0 -9
@@ -0,0 +1,250 @@
|
|
1
|
+
# The main SmartMachine Apps Rails driver
|
2
|
+
module SmartMachine
|
3
|
+
class Apps
|
4
|
+
class Rails < SmartMachine::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}/app/storage")
|
39
|
+
FileUtils.mkdir_p("#{container_path_with_version}/vendor/bundle")
|
40
|
+
FileUtils.mkdir_p("#{container_path_with_version}/public/assets")
|
41
|
+
FileUtils.mkdir_p("#{container_path_with_version}/public/packs")
|
42
|
+
FileUtils.mkdir_p("#{container_path_with_version}/node_modules")
|
43
|
+
FileUtils.mkdir_p("#{container_path_with_version}/storage")
|
44
|
+
|
45
|
+
# Creating & Starting container
|
46
|
+
container_id = `docker ps -a -q --filter='name=^#{appname}_1$' --filter='status=running'`.chomp
|
47
|
+
new_container = container_id.empty? ? "#{appname}_1" : "#{appname}_2"
|
48
|
+
old_container = container_id.empty? ? "#{appname}_2" : "#{appname}_1"
|
49
|
+
|
50
|
+
SmartMachine::Apps::App.stop("#{new_container}")
|
51
|
+
if system("docker create \
|
52
|
+
--name='#{new_container}' \
|
53
|
+
--env-file='#{container_path}/env' \
|
54
|
+
--user `id -u`:`id -g` \
|
55
|
+
--workdir /app \
|
56
|
+
--expose='3000' \
|
57
|
+
--volume='#{SmartMachine.config.user_home_path}/.smartmachine/config:#{SmartMachine.config.user_home_path}/.smartmachine/config' \
|
58
|
+
--volume='#{container_path_with_version}:/app' \
|
59
|
+
--volume='#{container_path}/app/vendor/bundle:/app/vendor/bundle' \
|
60
|
+
--volume='#{container_path}/app/public/assets:/app/public/assets' \
|
61
|
+
--volume='#{container_path}/app/public/packs:/app/public/packs' \
|
62
|
+
--volume='#{container_path}/app/node_modules:/app/node_modules' \
|
63
|
+
--volume='#{container_path}/app/storage:/app/storage' \
|
64
|
+
--restart='always' \
|
65
|
+
--init \
|
66
|
+
--network='nginx-network' \
|
67
|
+
smartmachine/buildpacks/rails:#{SmartMachine.version}", out: File::NULL)
|
68
|
+
|
69
|
+
system("docker network connect elasticsearch-network #{new_container}")
|
70
|
+
system("docker network connect minio-network #{new_container}")
|
71
|
+
system("docker network connect mysql-network #{new_container}")
|
72
|
+
|
73
|
+
if system("docker start --attach #{new_container}")
|
74
|
+
logger.debug "Starting Web Server ..."
|
75
|
+
if system("docker start #{new_container}", out: File::NULL)
|
76
|
+
sleep 7
|
77
|
+
logger.info "Web Server started successfully."
|
78
|
+
SmartMachine::Apps::App.stop(old_container)
|
79
|
+
SmartMachine::Apps::App.clean_up(container_path)
|
80
|
+
logger.info "Launched Application ... Success."
|
81
|
+
exit 10
|
82
|
+
end
|
83
|
+
else
|
84
|
+
SmartMachine::Apps::App.stop("#{new_container}")
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
logger.formatter = nil
|
89
|
+
end
|
90
|
+
|
91
|
+
def pack
|
92
|
+
set_logger_formatter_arrow
|
93
|
+
|
94
|
+
if File.exist? "tmp/smartmachine/packed"
|
95
|
+
begin
|
96
|
+
pid = File.read('tmp/smartmachine/packed').to_i
|
97
|
+
Process.kill('QUIT', pid)
|
98
|
+
rescue Errno::ESRCH # No such process
|
99
|
+
end
|
100
|
+
exec "bundle", "exec", "puma", "--config", "config/puma.rb"
|
101
|
+
else
|
102
|
+
if initial_setup? && bundle_install? && precompile_assets? && db_migrate? && test_web_server?
|
103
|
+
logger.formatter = nil
|
104
|
+
|
105
|
+
exit 0
|
106
|
+
else
|
107
|
+
logger.error "Could not continue ... Launch Failed."
|
108
|
+
logger.formatter = nil
|
109
|
+
|
110
|
+
exit 1
|
111
|
+
end
|
112
|
+
end
|
113
|
+
end
|
114
|
+
|
115
|
+
private
|
116
|
+
|
117
|
+
# Perform initial_setup
|
118
|
+
def initial_setup?
|
119
|
+
logger.info "Performing initial setup ..."
|
120
|
+
|
121
|
+
exit_status = nil
|
122
|
+
|
123
|
+
# Fix for mysql2 gem to support sha256_password, until it is fixed in main mysql2 gem.
|
124
|
+
# https://github.com/brianmario/mysql2/issues/1023
|
125
|
+
exit_status = system("mkdir -p ./lib/mariadb && ln -s /usr/lib/mariadb/plugin ./lib/mariadb/plugin")
|
126
|
+
|
127
|
+
if exit_status
|
128
|
+
return true
|
129
|
+
else
|
130
|
+
logger.error "Could not complete initial setup."
|
131
|
+
return false
|
132
|
+
end
|
133
|
+
end
|
134
|
+
|
135
|
+
# Perform bundle install
|
136
|
+
def bundle_install?
|
137
|
+
logger.info "Performing bundle install ..."
|
138
|
+
|
139
|
+
set_logger_formatter_tabs
|
140
|
+
|
141
|
+
unless system("bundle config set deployment 'true' && bundle config set clean 'true'")
|
142
|
+
logger.error "Could not complete bundle config setting."
|
143
|
+
return false
|
144
|
+
end
|
145
|
+
|
146
|
+
exit_status = nil
|
147
|
+
Open3.popen2e("bundle", "install") do |stdin, stdout_and_stderr, wait_thr|
|
148
|
+
stdout_and_stderr.each { |line| logger.info "#{line}" }
|
149
|
+
exit_status = wait_thr.value.success?
|
150
|
+
end
|
151
|
+
set_logger_formatter_arrow
|
152
|
+
|
153
|
+
if exit_status
|
154
|
+
return true
|
155
|
+
else
|
156
|
+
logger.error "Could not complete bundle install."
|
157
|
+
return false
|
158
|
+
end
|
159
|
+
end
|
160
|
+
|
161
|
+
# Perform pre-compiling of assets
|
162
|
+
def precompile_assets?
|
163
|
+
logger.info "Installing Javascript dependencies & pre-compiling assets ..."
|
164
|
+
|
165
|
+
set_logger_formatter_tabs
|
166
|
+
exit_status = nil
|
167
|
+
Open3.popen2e("bundle", "exec", "rails", "assets:precompile") do |stdin, stdout_and_stderr, wait_thr|
|
168
|
+
stdout_and_stderr.each { |line| logger.info "#{line}" }
|
169
|
+
exit_status = wait_thr.value.success?
|
170
|
+
end
|
171
|
+
set_logger_formatter_arrow
|
172
|
+
|
173
|
+
if exit_status
|
174
|
+
return true
|
175
|
+
else
|
176
|
+
logger.error "Could not install Javascript dependencies or pre-compile assets."
|
177
|
+
return false
|
178
|
+
end
|
179
|
+
end
|
180
|
+
|
181
|
+
# Perform db_migrate
|
182
|
+
def db_migrate?
|
183
|
+
return true # remove this line when you want to start using db_migrate?
|
184
|
+
|
185
|
+
logger.info "Performing database migrations ..."
|
186
|
+
|
187
|
+
set_logger_formatter_tabs
|
188
|
+
exit_status = nil
|
189
|
+
Open3.popen2e("bundle", "exec", "rails", "db:migrate") do |stdin, stdout_and_stderr, wait_thr|
|
190
|
+
stdout_and_stderr.each { |line| logger.info "#{line}" }
|
191
|
+
exit_status = wait_thr.value.success?
|
192
|
+
end
|
193
|
+
set_logger_formatter_arrow
|
194
|
+
|
195
|
+
if exit_status
|
196
|
+
return true
|
197
|
+
else
|
198
|
+
logger.error "Could not complete database migrations."
|
199
|
+
return false
|
200
|
+
end
|
201
|
+
end
|
202
|
+
|
203
|
+
# Perform testing of web server
|
204
|
+
def test_web_server?
|
205
|
+
logger.info "Setting up Web Server ..."
|
206
|
+
|
207
|
+
# tmp folders
|
208
|
+
FileUtils.mkdir_p("tmp/pids")
|
209
|
+
FileUtils.mkdir_p("tmp/smartmachine")
|
210
|
+
FileUtils.rm_f("tmp/smartmachine/packed")
|
211
|
+
|
212
|
+
# Spawn Process
|
213
|
+
pid = Process.spawn("bundle", "exec", "puma", "--config", "config/puma.rb", out: File::NULL)
|
214
|
+
Process.detach(pid)
|
215
|
+
|
216
|
+
# Sleep
|
217
|
+
sleep 5
|
218
|
+
|
219
|
+
# Check PID running
|
220
|
+
status = nil
|
221
|
+
begin
|
222
|
+
Process.kill(0, pid)
|
223
|
+
system("echo '#{pid}' > tmp/smartmachine/packed")
|
224
|
+
status = true
|
225
|
+
rescue Errno::ESRCH # No such process
|
226
|
+
logger.info "Web Server could not start"
|
227
|
+
status = false
|
228
|
+
end
|
229
|
+
|
230
|
+
# Return status
|
231
|
+
return status
|
232
|
+
end
|
233
|
+
|
234
|
+
def set_logger_formatter_arrow
|
235
|
+
logger.formatter = proc do |severity, datetime, progname, message|
|
236
|
+
severity_text = { "DEBUG" => "\u{1f527} #{severity}:", "INFO" => " \u{276f}", "WARN" => "\u{2757} #{severity}:",
|
237
|
+
"ERROR" => "\u{274c} #{severity}:", "FATAL" => "\u{2b55} #{severity}:", "UNKNOWN" => "\u{2753} #{severity}:"
|
238
|
+
}
|
239
|
+
"\t\t\t\t#{severity_text[severity]} #{message}\n"
|
240
|
+
end
|
241
|
+
end
|
242
|
+
|
243
|
+
def set_logger_formatter_tabs
|
244
|
+
logger.formatter = proc do |severity, datetime, progname, message|
|
245
|
+
"\t\t\t\t #{message}"
|
246
|
+
end
|
247
|
+
end
|
248
|
+
end
|
249
|
+
end
|
250
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
# The main SmartMachine Boot driver
|
2
|
+
module SmartMachine
|
3
|
+
class Boot < SmartMachine::Base
|
4
|
+
def initialize
|
5
|
+
end
|
6
|
+
end
|
7
|
+
end
|
8
|
+
|
9
|
+
require 'smart_machine/credentials'
|
10
|
+
|
11
|
+
require 'smart_machine/ssh'
|
12
|
+
require 'smart_machine/machine'
|
13
|
+
|
14
|
+
require 'smart_machine/docker'
|
15
|
+
require 'smart_machine/engine'
|
16
|
+
require 'smart_machine/buildpacker'
|
17
|
+
require 'smart_machine/sync'
|
18
|
+
|
19
|
+
require 'smart_machine/user'
|
20
|
+
|
21
|
+
require 'smart_machine/grids'
|
22
|
+
require 'smart_machine/grids/elasticsearch'
|
23
|
+
require 'smart_machine/grids/minio'
|
24
|
+
require 'smart_machine/grids/mysql'
|
25
|
+
require 'smart_machine/grids/nginx'
|
26
|
+
require 'smart_machine/grids/prereceiver'
|
27
|
+
require 'smart_machine/grids/solr'
|
28
|
+
|
29
|
+
require 'smart_machine/apps'
|
30
|
+
require 'smart_machine/apps/app'
|
31
|
+
require 'smart_machine/apps/rails'
|
@@ -0,0 +1,106 @@
|
|
1
|
+
require 'open3'
|
2
|
+
|
3
|
+
module SmartMachine
|
4
|
+
class Buildpacker < SmartMachine::Base
|
5
|
+
def initialize
|
6
|
+
end
|
7
|
+
|
8
|
+
def install
|
9
|
+
puts "-----> Installing Buildpacker"
|
10
|
+
|
11
|
+
ssh = SmartMachine::SSH.new
|
12
|
+
commands = ["smartmachine runner buildpacker create"]
|
13
|
+
ssh.run commands
|
14
|
+
|
15
|
+
puts "-----> Buildpacker Installation Complete"
|
16
|
+
end
|
17
|
+
|
18
|
+
def uninstall
|
19
|
+
puts "-----> Uninstalling Buildpacker"
|
20
|
+
|
21
|
+
ssh = SmartMachine::SSH.new
|
22
|
+
commands = ["smartmachine runner buildpacker destroy"]
|
23
|
+
ssh.run commands
|
24
|
+
|
25
|
+
puts "-----> Buildpacker Uninstallation Complete"
|
26
|
+
end
|
27
|
+
|
28
|
+
def update
|
29
|
+
self.uninstall
|
30
|
+
self.install
|
31
|
+
end
|
32
|
+
|
33
|
+
def create
|
34
|
+
self.destroy
|
35
|
+
|
36
|
+
unless system("docker image inspect #{buildpacker_image_name}", [:out, :err] => File::NULL)
|
37
|
+
print "-----> Creating image #{buildpacker_image_name} ... "
|
38
|
+
if system("docker image build -t #{buildpacker_image_name} \
|
39
|
+
--build-arg SMARTMACHINE_VERSION=#{SmartMachine.version} \
|
40
|
+
--build-arg USER_UID=`id -u` \
|
41
|
+
--build-arg USER_NAME=`id -un` \
|
42
|
+
#{SmartMachine.config.root_path}/lib/smart_machine/engine/buildpacks/rails", out: File::NULL)
|
43
|
+
puts "done"
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
def destroy
|
49
|
+
if system("docker image inspect #{buildpacker_image_name}", [:out, :err] => File::NULL)
|
50
|
+
print "-----> Removing image #{buildpacker_image_name} ... "
|
51
|
+
if system("docker image rm #{buildpacker_image_name}", out: File::NULL)
|
52
|
+
puts "done"
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
def pack
|
58
|
+
if File.exist? "bin/rails"
|
59
|
+
rails = SmartMachine::Apps::Rails.new
|
60
|
+
rails.pack
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
# These swapfile methods can be used (after required modification), when you need to make swapfile for more memory.
|
65
|
+
# def self.create_swapfile
|
66
|
+
# # Creating swapfile for bundler to work properly
|
67
|
+
# unless system("sudo swapon -s | grep -ci '/swapfile'", out: File::NULL)
|
68
|
+
# print "-----> Creating swap swapfile ... "
|
69
|
+
# system("sudo install -o root -g root -m 0600 /dev/null /swapfile", out: File::NULL)
|
70
|
+
# system("sudo dd if=/dev/zero of=/swapfile bs=1k count=2048k", [:out, :err] => File::NULL)
|
71
|
+
# system("sudo mkswap /swapfile", out: File::NULL)
|
72
|
+
# system("sudo sh -c 'echo \"/swapfile none swap sw 0 0\" >> /etc/fstab'", out: File::NULL)
|
73
|
+
# system("echo 10 | sudo tee /proc/sys/vm/swappiness", out: File::NULL)
|
74
|
+
# system("sudo sed -i '/^vm.swappiness = /d' /etc/sysctl.conf", out: File::NULL)
|
75
|
+
# system("echo vm.swappiness = 10 | sudo tee -a /etc/sysctl.conf", out: File::NULL)
|
76
|
+
# puts "done"
|
77
|
+
#
|
78
|
+
# print "-----> Starting swap swapfile ... "
|
79
|
+
# if system("sudo swapon /swapfile", out: File::NULL)
|
80
|
+
# puts "done"
|
81
|
+
# end
|
82
|
+
# end
|
83
|
+
# end
|
84
|
+
#
|
85
|
+
# def self.destroy_swapfile
|
86
|
+
# if system("sudo swapon -s | grep -ci '/swapfile'", out: File::NULL)
|
87
|
+
# print "-----> Stopping swap swapfile ... "
|
88
|
+
# if system("sudo swapoff /swapfile", out: File::NULL)
|
89
|
+
# system("sudo sed -i '/^vm.swappiness = /d' /etc/sysctl.conf", out: File::NULL)
|
90
|
+
# system("echo 60 | sudo tee /proc/sys/vm/swappiness", out: File::NULL)
|
91
|
+
# puts "done"
|
92
|
+
#
|
93
|
+
# print "-----> Removing swap swapfile ... "
|
94
|
+
# system("sudo sed -i '/^\\/swapfile/d' /etc/fstab", out: File::NULL)
|
95
|
+
# if system("sudo rm /swapfile", out: File::NULL)
|
96
|
+
# puts "done"
|
97
|
+
# end
|
98
|
+
# end
|
99
|
+
# end
|
100
|
+
# end
|
101
|
+
|
102
|
+
def buildpacker_image_name
|
103
|
+
"smartmachine/buildpacks/rails:#{SmartMachine.version}"
|
104
|
+
end
|
105
|
+
end
|
106
|
+
end
|
@@ -0,0 +1,126 @@
|
|
1
|
+
require "pathname"
|
2
|
+
require "tmpdir"
|
3
|
+
require "active_support/message_encryptor"
|
4
|
+
require "active_support/core_ext/hash/keys"
|
5
|
+
|
6
|
+
# The main SmartMachine Credentials driver
|
7
|
+
module SmartMachine
|
8
|
+
class Credentials < SmartMachine::Base
|
9
|
+
|
10
|
+
CIPHER = "aes-256-gcm"
|
11
|
+
|
12
|
+
def initialize
|
13
|
+
end
|
14
|
+
|
15
|
+
def create
|
16
|
+
write_key
|
17
|
+
write credentials_template
|
18
|
+
end
|
19
|
+
|
20
|
+
def edit
|
21
|
+
content_path = Pathname.new "config/credentials.yml.enc"
|
22
|
+
tmp_file = "#{Process.pid}.#{content_path.basename.to_s.chomp('.enc')}"
|
23
|
+
tmp_path = Pathname.new File.join(Dir.tmpdir, tmp_file)
|
24
|
+
contents = read
|
25
|
+
tmp_path.binwrite contents
|
26
|
+
|
27
|
+
system("#{ENV['EDITOR']} #{tmp_path}")
|
28
|
+
|
29
|
+
updated_contents = tmp_path.binread
|
30
|
+
|
31
|
+
if updated_contents != contents
|
32
|
+
write(updated_contents)
|
33
|
+
puts "File encrypted and saved."
|
34
|
+
else
|
35
|
+
puts "File contents were not changed."
|
36
|
+
end
|
37
|
+
ensure
|
38
|
+
FileUtils.rm(tmp_path) if tmp_path&.exist?
|
39
|
+
end
|
40
|
+
|
41
|
+
def read_key
|
42
|
+
read_env_key || read_key_file || handle_missing_key
|
43
|
+
end
|
44
|
+
|
45
|
+
def config
|
46
|
+
@config ||= deserialize(read).deep_symbolize_keys
|
47
|
+
end
|
48
|
+
|
49
|
+
private
|
50
|
+
|
51
|
+
def credentials_template
|
52
|
+
<<~YAML
|
53
|
+
machine:
|
54
|
+
name: #{SecureRandom.hex(8)}
|
55
|
+
address: 122.122.122.122
|
56
|
+
port: 22
|
57
|
+
root_password: #{SecureRandom.hex(16)}
|
58
|
+
username: #{SecureRandom.hex(8)}
|
59
|
+
password: #{SecureRandom.hex(16)}
|
60
|
+
|
61
|
+
minio:
|
62
|
+
name: #{SecureRandom.hex(8)}
|
63
|
+
access_key: #{SecureRandom.hex(8)}
|
64
|
+
secret_key: #{SecureRandom.hex(16)}
|
65
|
+
browser: on
|
66
|
+
worm: off
|
67
|
+
|
68
|
+
mysql:
|
69
|
+
port: 3306
|
70
|
+
root_password: #{SecureRandom.hex(16)}
|
71
|
+
username: #{SecureRandom.hex(8)}
|
72
|
+
password: #{SecureRandom.hex(16)}
|
73
|
+
database_name: #{SecureRandom.hex(8)}
|
74
|
+
|
75
|
+
elasticsearch:
|
76
|
+
port: 9200
|
77
|
+
YAML
|
78
|
+
end
|
79
|
+
|
80
|
+
def read
|
81
|
+
decrypt IO.binread "config/credentials.yml.enc"
|
82
|
+
end
|
83
|
+
|
84
|
+
def write(contents)
|
85
|
+
IO.binwrite "config/credentials.yml.enc.tmp", encrypt(contents)
|
86
|
+
FileUtils.mv "config/credentials.yml.enc.tmp", "config/credentials.yml.enc"
|
87
|
+
end
|
88
|
+
|
89
|
+
def encrypt(contents)
|
90
|
+
encryptor.encrypt_and_sign contents
|
91
|
+
end
|
92
|
+
|
93
|
+
def decrypt(contents)
|
94
|
+
encryptor.decrypt_and_verify contents
|
95
|
+
end
|
96
|
+
|
97
|
+
def encryptor
|
98
|
+
@encryptor ||= ActiveSupport::MessageEncryptor.new([ read_key ].pack("H*"), cipher: CIPHER)
|
99
|
+
end
|
100
|
+
|
101
|
+
def create_key
|
102
|
+
SecureRandom.hex(ActiveSupport::MessageEncryptor.key_len(CIPHER))
|
103
|
+
end
|
104
|
+
|
105
|
+
def write_key
|
106
|
+
IO.binwrite "config/master.key.tmp", create_key
|
107
|
+
FileUtils.mv "config/master.key.tmp", "config/master.key"
|
108
|
+
end
|
109
|
+
|
110
|
+
def read_env_key
|
111
|
+
ENV['SMARTMACHINE_MASTER_KEY']
|
112
|
+
end
|
113
|
+
|
114
|
+
def read_key_file
|
115
|
+
IO.binread("config/master.key").strip if File.file?("config/master.key")
|
116
|
+
end
|
117
|
+
|
118
|
+
def handle_missing_key
|
119
|
+
raise "Missing SMARTMACHINE_MASTER_KEY. Please add SMARTMACHINE_MASTER_KEY to your environment."
|
120
|
+
end
|
121
|
+
|
122
|
+
def deserialize(config)
|
123
|
+
YAML.load(config).presence || {}
|
124
|
+
end
|
125
|
+
end
|
126
|
+
end
|