From a381a0cf8fa7d5c196798205f524d076953a8a19 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81lax=20de=20Carvalho=20Alves?= Date: Tue, 5 May 2020 12:07:12 -0300 Subject: [PATCH] Get Mapknitter running into the Google Cloud v2 (#1273) * Shortening docker image in ~30% * Caching bundle, gathering env variables and using newer sintax * Creating startup script and env file * Improving travis CI configuration * Loading assets in production env * Allow uglifier to interpret ES6 * Fix start command * Fix travis script * Tweak travis script * Add delay * Revert assets changes * Return to Mysql5.7 * Tweak travis script * Fix make redeploy-container command * Add db migrate and precompile step. * Add bower install to Makefile * Clean after docker run. Avoid one bower run. * Changes to be able to build container in Google Cloud * Remove spurious symlink * Copy config examples when making build * Export env variable name * Tag cloud image * Add timeout * Push to cloud registry * Fix jenkins build error with docker-compose tty * Add app to container and .dockerignore all else * Copy configuration files when deploying to GCE * Allow copy config to container * Time extended (for cloud build & push) * Delete redundant index.html.erb file (#427) * Setupcoveralls (#438) * Add coveralls * Fix gemfile * Fix env variable * Add coveralls token * Update README.md * Remove legacy image controller code #404 (#417) Deleted the lines from the selection indicated in the issue. * Change comment count on comment creation via AJAX #441 (#443) This closes issue #441 "Change comment count on comment creation via AJAX #441" by incrementing comments-number each time a new comment is added. This would ensure that the counter indicating the number of comments is increased without needing to refresh the page. * update syntax of active record query(license method) (#439) Fixes #437 * Docker improve rebased (#450) * Shortening docker image in ~30% * Caching bundle, gathering env variables and using newer sintax * Creating startup script and env file * Improving travis CI configuration * Loading assets in production env * Allow uglifier to interpret ES6 * Don't dettach when building container in travis * Fix start command * Fix travis script * Try to resolve travis tests invocation * Tweak travis script * Add delay * Bundle install before db setup * Shortening docker image in ~30% * Caching bundle, gathering env variables and using newer sintax * Creating startup script and env file * Improving travis CI configuration * Loading assets in production env * Allow uglifier to interpret ES6 * Fix start command * Fix travis script * Tweak travis script * Add delay * Revert assets changes * Return to Mysql5.7 * Tweak travis script * Fix make redeploy-container command * Add db migrate and precompile step. * Add bower install to Makefile * Clean after docker run. Avoid one bower run. * updte pr template (#448) * Bump recaptcha from 4.13.1 to 4.13.2 (#452) Bumps [recaptcha](https://github.com/ambethia/recaptcha) from 4.13.1 to 4.13.2. - [Release notes](https://github.com/ambethia/recaptcha/releases) - [Changelog](https://github.com/ambethia/recaptcha/blob/master/CHANGELOG.md) - [Commits](https://github.com/ambethia/recaptcha/compare/v4.13.1...v4.13.2) Signed-off-by: dependabot[bot] * Restructure rake test task runner (#380) * add a mysql setup file * Squash commits * Update README.md (#456) * Change run to exec (#457) * Bump paperclip from 4.2.4 to 4.3.7 (#285) Bumps [paperclip](https://github.com/thoughtbot/paperclip) from 4.2.4 to 4.3.7. - [Release notes](https://github.com/thoughtbot/paperclip/releases) - [Changelog](https://github.com/thoughtbot/paperclip/blob/v4.3.7/NEWS) - [Commits](https://github.com/thoughtbot/paperclip/compare/v4.2.4...v4.3.7) Signed-off-by: dependabot[bot] * Bump test-unit from 3.3.0 to 3.3.1 (#458) Bumps [test-unit](https://github.com/test-unit/test-unit) from 3.3.0 to 3.3.1. - [Release notes](https://github.com/test-unit/test-unit/releases) - [Commits](https://github.com/test-unit/test-unit/compare/3.3.0...3.3.1) Signed-off-by: dependabot[bot] * Bump coveralls from 0.7.1 to 0.8.22 (#453) Bumps [coveralls](https://coveralls.io) from 0.7.1 to 0.8.22. Signed-off-by: dependabot[bot] * gridview aligned (#464) * Alert improvement and adding byebug gem (#383) * byebug gem added and alerts in separate file * adding byebug history to gitignore * adding timestamp to redirect * added z-index to render login dropdown above leaflet icon * fixed image partial rendering when no images (#423) * fixed image partial rendering when no images. * toggle no images

om upload * fixed image partial rendering when no images. * Bump recaptcha from 4.13.2 to 4.14.0 (#471) Bumps [recaptcha](https://github.com/ambethia/recaptcha) from 4.13.2 to 4.14.0. - [Release notes](https://github.com/ambethia/recaptcha/releases) - [Changelog](https://github.com/ambethia/recaptcha/blob/master/CHANGELOG.md) - [Commits](https://github.com/ambethia/recaptcha/compare/v4.13.2...v4.14.0) Signed-off-by: dependabot[bot] * add a flash error when adding tags and not logged in (#473) * Upgrade app to Bootstrap 4 (#480) * Bootstrap 4 small button fixes (#488) * Add tests for comments and maps (#467) * Updated query style (#436) (#469) * Dynamic ports (#462) * Dynamic port in compose file * Omit setting container name * Add initial sql dump entry * Avoid resetting database on build * Shortening docker image in ~30% * Caching bundle, gathering env variables and using newer sintax * Creating startup script and env file * Improving travis CI configuration * Loading assets in production env * Tweak travis script * Roll back to using Debian 9 with custom built GDAL (#489) * Switch back to Debian 9 Stretch * Simplify docker image * Bump Ruby to 2.4.6 * Re-add dependency * Add dependency (zip) * Try pip install gdal * Install libgdal-dev * Revert attept to use pip * Bump ruby * Avoid naming containers in compose file * Avoid overwriting database on redeploy-container * Allow to load mysql dump * Include own GDAL packages * Disable ipv6 to prevent error * Add missing Amazon S3 yml to Makefile * Document unstable instance * Changes to be able to build container in Google Cloud * Copy config examples when making build * Add app to container and .dockerignore all else * Fixed missed merge * Add db configurability by env vars for containers * Fix db config * Copy configs * Switch keyserver * Add env vars, tweak make * Substitute env vars parameters * Env var control * Show env vars * env not ENV * add DB_SOCKET * Add recomended parameters * Not deploy app engine, show cloudsql dir * Omit list cloudsql dir * Added correct image tag * Add database parameters as env vars * Support $PORT env var * Using Node 12 and Yarn for Dockerfile.txt as well * Changing Passenger's port on production env * Setting local db for travis * set .env PORT to $PORT * Remove .env * Compose environment variableZ fallback * Revert all files under /app to versions in main * Revert to main * Delete unneeded files * Remove extra files from rebase * Add bundle install as build step * Deleted not needed Dockerfile * Missed RUN in Dockerfile * Add precompile step * Hardcode environment at build time * Adding missing yaml and update bootsnap version * Omit /app/tmp from volume * Revert try to get precompile to work * Clean up patch for merging * List variables in app.yaml * Tweak for jenkins * Add .env for jenkins * Fix PORT for jenkins/docker-compose * Address PORT properly * New form ports * Enclose docker-compose ports in quotes * ports yaml should be object not array * Try different format for ports * Try docker-compose format * Redirect script for AppEngine * Try to revertt to working condition for appengine * Point PORT in Procfile * Revert to known good config in appengine * Tweak assets precompilation * Restore PORT setting * Add redirect to map /warps directory to legacy archive * Add .env for jenkins/docker-compose * Add hardcoded route to legacy warps * Remove .env for appengine * Satisfy appengine docker-compose * Ignore app.yaml * Ignore app.yaml secrets * Satisfy Jenkins wihout hurting appengine hopefully Co-authored-by: Sebastian Silva Co-authored-by: rarrunategu1 Co-authored-by: Jeffrey Warren Co-authored-by: Milo MacPhail <40954168+milomacphail@users.noreply.github.com> Co-authored-by: Sonali Agrawal Co-authored-by: Ananya Agrawal <33188930+ananya@users.noreply.github.com> Co-authored-by: dependabot[bot] Co-authored-by: Sasha Boginsky <41092741+sashadev-sky@users.noreply.github.com> Co-authored-by: Kaustubh Nair Co-authored-by: Divya Baid <32747809+divyabaid16@users.noreply.github.com> Co-authored-by: Gaurav Sachdeva Co-authored-by: Govind Jeevan Co-authored-by: Cess Co-authored-by: Stefanni Co-authored-by: hc-barker --- .env | 1 - .gcloudignore | 43 ++++ .gitignore | 3 + .travis.yml | 4 + Dockerfile | 2 + Gemfile | 2 +- Gemfile.lock | 193 +++++++++--------- Makefile | 4 + Procfile | 2 +- app.yaml | 25 +++ cloudbuild.yaml | 14 ++ config/database.yml.example | 10 +- config/routes.rb | 1 + ...214062147_add_index_for_warpable_map_id.rb | 2 +- docker-compose.yml | 3 +- script/redirect.py | 15 ++ start.sh | 8 +- yarn.lock | 8 - 18 files changed, 225 insertions(+), 115 deletions(-) delete mode 100644 .env create mode 100644 .gcloudignore create mode 100644 app.yaml create mode 100644 cloudbuild.yaml create mode 100644 script/redirect.py diff --git a/.env b/.env deleted file mode 100644 index 2fc80e3a4..000000000 --- a/.env +++ /dev/null @@ -1 +0,0 @@ -PORT=3000 diff --git a/.gcloudignore b/.gcloudignore new file mode 100644 index 000000000..1ee4d0dca --- /dev/null +++ b/.gcloudignore @@ -0,0 +1,43 @@ +# See http://help.github.com/ignore-files/ for more about ignoring files. +# +# If you find yourself ignoring temporary files generated by your text editor +# or operating system, you probably want to add a global ignore instead: +# git config --global core.excludesfile ~/.gitignore_global + +# Ignore bundler config +/.bundle + +# Ignore the default SQLite database. +/db/*.sqlite3 + +# Ignore all logfiles and tempfiles. +/tmp +*.swp +*.swo +*~ +.ruby-version +.DS_Store +log/ +tmp/* +tmp/**/* +coverage* +public/warpables/* +public/system/* +public/warps/* +public/tms/* +db/schema.rb +*.db +config/database.yml +config/amazon_s3.yml +config/initializers/recaptcha.rb +config/config.yml +config/initializers/site_keys.rb +vendor/bundle +app/assets/bower_components +app/assets/node_modules +public/assets +public/lib +node_modules +todo.txt +.sass-cache +.git/ diff --git a/.gitignore b/.gitignore index 5c03ac56c..5866d40c4 100644 --- a/.gitignore +++ b/.gitignore @@ -7,6 +7,9 @@ # Ignore bundler config /.bundle +# avoid committing your secrets inadvertly +./app.yaml + # Ignore the default SQLite database. /db/*.sqlite3 diff --git a/.travis.yml b/.travis.yml index cee7cba88..adbcc79a3 100755 --- a/.travis.yml +++ b/.travis.yml @@ -43,6 +43,10 @@ env: - RAILS_ENV=test - CI=true - TRAVIS=true + - DB_HOST='127.0.0.1' + - DB_USER='mapknitter' + - DB_PASS='mapknitter' + - DB_NAME='mapknitter' jobs: include: diff --git a/Dockerfile b/Dockerfile index 3af3f9a22..b047667b2 100644 --- a/Dockerfile +++ b/Dockerfile @@ -51,4 +51,6 @@ RUN git config --global url."https://".insteadOf git:// COPY . /app/ WORKDIR /app +RUN bundle install + CMD [ "sh", "/app/start.sh" ] diff --git a/Gemfile b/Gemfile index cda9fb459..639ea8b18 100644 --- a/Gemfile +++ b/Gemfile @@ -24,7 +24,7 @@ group :dependencies do gem 'open_id_authentication' gem 'RubyInline', '~> 3.12.5' gem 'paperclip', '~> 6.1.0' - gem 'bootsnap', '~> 1.4.5' + gem 'bootsnap', '~> 1.4.6' gem 'turbolinks', '~> 5' gem 'mini_magick', '~> 4.8' gem 'puma', '~> 4.3.3' diff --git a/Gemfile.lock b/Gemfile.lock index f240f273c..7497cfb0f 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -4,45 +4,45 @@ GEM RubyInline (3.12.5) ZenTest (~> 4.3) ZenTest (4.12.0) - action-cable-testing (0.6.0) + action-cable-testing (0.6.1) actioncable (>= 5.0) - actioncable (5.2.4) - actionpack (= 5.2.4) + actioncable (5.2.4.2) + actionpack (= 5.2.4.2) nio4r (~> 2.0) websocket-driver (>= 0.6.1) - actionmailer (5.2.4) - actionpack (= 5.2.4) - actionview (= 5.2.4) - activejob (= 5.2.4) + actionmailer (5.2.4.2) + actionpack (= 5.2.4.2) + actionview (= 5.2.4.2) + activejob (= 5.2.4.2) mail (~> 2.5, >= 2.5.4) rails-dom-testing (~> 2.0) - actionpack (5.2.4) - actionview (= 5.2.4) - activesupport (= 5.2.4) - rack (~> 2.0) + actionpack (5.2.4.2) + actionview (= 5.2.4.2) + activesupport (= 5.2.4.2) + rack (~> 2.0, >= 2.0.8) rack-test (>= 0.6.3) rails-dom-testing (~> 2.0) rails-html-sanitizer (~> 1.0, >= 1.0.2) - actionview (5.2.4) - activesupport (= 5.2.4) + actionview (5.2.4.2) + activesupport (= 5.2.4.2) builder (~> 3.1) erubi (~> 1.4) rails-dom-testing (~> 2.0) rails-html-sanitizer (~> 1.0, >= 1.0.3) - activejob (5.2.4) - activesupport (= 5.2.4) + activejob (5.2.4.2) + activesupport (= 5.2.4.2) globalid (>= 0.3.6) - activemodel (5.2.4) - activesupport (= 5.2.4) - activerecord (5.2.4) - activemodel (= 5.2.4) - activesupport (= 5.2.4) + activemodel (5.2.4.2) + activesupport (= 5.2.4.2) + activerecord (5.2.4.2) + activemodel (= 5.2.4.2) + activesupport (= 5.2.4.2) arel (>= 9.0) - activestorage (5.2.4) - actionpack (= 5.2.4) - activerecord (= 5.2.4) + activestorage (5.2.4.2) + actionpack (= 5.2.4.2) + activerecord (= 5.2.4.2) marcel (~> 0.3.1) - activesupport (5.2.4) + activesupport (5.2.4.2) concurrent-ruby (~> 1.0, >= 1.0.2) i18n (>= 0.7, < 2) minitest (~> 5.1) @@ -52,33 +52,33 @@ GEM ansi (1.5.0) arel (9.0.0) ast (2.4.0) - autoprefixer-rails (9.7.3) + autoprefixer-rails (9.7.6) execjs - aws-eventstream (1.0.3) - aws-partitions (1.258.0) - aws-sdk-core (3.86.0) - aws-eventstream (~> 1.0, >= 1.0.2) + aws-eventstream (1.1.0) + aws-partitions (1.303.0) + aws-sdk-core (3.94.0) + aws-eventstream (~> 1, >= 1.0.2) aws-partitions (~> 1, >= 1.239.0) aws-sigv4 (~> 1.1) jmespath (~> 1.0) - aws-sdk-kms (1.27.0) + aws-sdk-kms (1.30.0) aws-sdk-core (~> 3, >= 3.71.0) aws-sigv4 (~> 1.1) - aws-sdk-s3 (1.60.1) + aws-sdk-s3 (1.63.0) aws-sdk-core (~> 3, >= 3.83.0) aws-sdk-kms (~> 1) aws-sigv4 (~> 1.1) - aws-sigv4 (1.1.0) + aws-sigv4 (1.1.2) aws-eventstream (~> 1.0, >= 1.0.2) bindex (0.8.1) - bootsnap (1.4.5) + bootsnap (1.4.6) msgpack (~> 1.0) bootstrap-sass (3.4.1) autoprefixer-rails (>= 5.2.1) sassc (>= 2.0.0) builder (3.2.4) byebug (11.0.1) - capybara (3.29.0) + capybara (3.32.1) addressable mini_mime (>= 0.1.3) nokogiri (~> 1.8) @@ -93,16 +93,16 @@ GEM simplecov url coderay (1.1.2) - concurrent-ruby (1.1.5) - crass (1.0.5) + concurrent-ruby (1.1.6) + crass (1.0.6) docile (1.3.2) erubi (1.9.0) execjs (2.7.0) faker (2.6.0) i18n (>= 1.6, < 1.8) - faraday (0.15.4) + faraday (1.0.1) multipart-post (>= 1.2, < 3) - ffi (1.11.3) + ffi (1.12.2) friendly_id (5.3.0) activerecord (>= 4.0.0) geokit (1.13.1) @@ -110,14 +110,14 @@ GEM geokit (>= 1.5.0) globalid (0.4.2) activesupport (>= 4.2.0) - httparty (0.17.3) + httparty (0.18.0) mime-types (~> 3.0) multi_xml (>= 0.5.2) - i18n (1.7.0) + i18n (1.7.1) concurrent-ruby (~> 1.0) image_science (1.3.0) RubyInline (~> 3.9) - jaro_winkler (1.5.3) + jaro_winkler (1.5.4) jmespath (1.4.0) jquery-rails (4.3.5) rails-dom-testing (>= 1, < 3) @@ -127,43 +127,43 @@ GEM execjs multi_json (>= 1.3) rake - json (2.2.0) + json (2.3.0) libv8 (7.3.492.27.1) libxml-ruby (3.1.0) listen (3.2.1) rb-fsevent (~> 0.10, >= 0.10.3) rb-inotify (~> 0.9, >= 0.9.10) - loofah (2.4.0) + loofah (2.5.0) crass (~> 1.0.2) nokogiri (>= 1.5.9) mail (2.7.1) mini_mime (>= 0.1.1) marcel (0.3.3) mimemagic (~> 0.3.2) - method_source (0.9.2) - mime-types (3.3) + method_source (1.0.0) + mime-types (3.3.1) mime-types-data (~> 3.2015) mime-types-data (3.2019.1009) - mimemagic (0.3.3) - mini_magick (4.9.5) + mimemagic (0.3.4) + mini_magick (4.10.1) mini_mime (1.0.2) mini_portile2 (2.4.0) - mini_racer (0.2.8) - libv8 (>= 6.9.411) + mini_racer (0.2.10) + libv8 (> 7.3) minitest (5.14.0) minitest-reporters (1.4.2) ansi builder minitest (>= 5.0) ruby-progressbar - msgpack (1.3.1) - multi_json (1.13.1) + msgpack (1.3.3) + multi_json (1.14.1) multi_xml (0.6.0) multipart-post (2.1.1) mysql2 (0.5.3) net-http-persistent (2.9.4) nio4r (2.5.2) - nokogiri (1.10.7) + nokogiri (1.10.9) mini_portile2 (~> 2.4.0) oa-core (0.3.2) oa-openid (0.3.2) @@ -181,22 +181,22 @@ GEM mime-types mimemagic (~> 0.3.0) terrapin (~> 0.6.0) - parallel (1.17.0) - parser (2.6.4.0) + parallel (1.19.1) + parser (2.7.1.1) ast (~> 2.4.0) passenger (6.0.4) rack rake (>= 0.8.1) - popper_js (1.14.5) - pry (0.12.2) - coderay (~> 1.1.0) - method_source (~> 0.9.0) + popper_js (1.16.0) + pry (0.13.1) + coderay (~> 1.1) + method_source (~> 1.0) pry-rails (0.3.9) pry (>= 0.10.4) - public_suffix (4.0.1) + public_suffix (4.0.4) puma (4.3.3) nio4r (~> 2.0) - rack (2.1.1) + rack (2.2.2) rack-openid (1.3.1) rack (>= 1.1.0) ruby-openid (>= 2.1.8) @@ -205,18 +205,18 @@ GEM rack_session_access (0.2.0) builder (>= 2.0.0) rack (>= 1.0.0) - rails (5.2.4) - actioncable (= 5.2.4) - actionmailer (= 5.2.4) - actionpack (= 5.2.4) - actionview (= 5.2.4) - activejob (= 5.2.4) - activemodel (= 5.2.4) - activerecord (= 5.2.4) - activestorage (= 5.2.4) - activesupport (= 5.2.4) + rails (5.2.4.2) + actioncable (= 5.2.4.2) + actionmailer (= 5.2.4.2) + actionpack (= 5.2.4.2) + actionview (= 5.2.4.2) + activejob (= 5.2.4.2) + activemodel (= 5.2.4.2) + activerecord (= 5.2.4.2) + activestorage (= 5.2.4.2) + activesupport (= 5.2.4.2) bundler (>= 1.3.0) - railties (= 5.2.4) + railties (= 5.2.4.2) sprockets-rails (>= 2.0.0) rails-controller-testing (1.0.4) actionpack (>= 5.0.1.x) @@ -228,23 +228,23 @@ GEM rails-html-sanitizer (1.3.0) loofah (~> 2.3) rails-perftest (0.0.7) - railties (5.2.4) - actionpack (= 5.2.4) - activesupport (= 5.2.4) + railties (5.2.4.2) + actionpack (= 5.2.4.2) + activesupport (= 5.2.4.2) method_source rake (>= 0.8.7) thor (>= 0.19.0, < 2.0) rainbow (3.0.0) rake (12.3.3) rb-fsevent (0.10.3) - rb-inotify (0.10.0) + rb-inotify (0.10.1) ffi (~> 1.0) rdiscount (2.2.0.1) recaptcha (5.0.0) json redcarpet (3.5.0) - regexp_parser (1.6.0) - request_store (1.4.1) + regexp_parser (1.7.0) + request_store (1.5.0) rack (>= 1.4) right_aws_api (0.3.5) right_cloud_api_base (>= 0.2.6) @@ -264,18 +264,18 @@ GEM rubocop-performance (1.3.0) rubocop (>= 0.68.0) ruby-hmac (0.4.0) - ruby-openid (2.9.1) + ruby-openid (2.9.2) ruby-openid-apps-discovery (1.2.0) ruby-openid (>= 2.1.7) - ruby-prof (1.2.0) + ruby-prof (1.3.2) ruby-progressbar (1.10.1) - rubyzip (2.0.0) + rubyzip (2.3.0) sass (3.7.4) sass-listen (~> 4.0.0) sass-listen (4.0.0) rb-fsevent (~> 0.9, >= 0.9.4) rb-inotify (~> 0.9, >= 0.9.7) - sassc (2.2.0) + sassc (2.3.0) ffi (~> 1.9) sassc-rails (2.1.2) railties (>= 4.0.0) @@ -283,19 +283,18 @@ GEM sprockets (> 3.0) sprockets-rails tilt - selenium-webdriver (3.142.6) + selenium-webdriver (3.142.7) childprocess (>= 0.5, < 4.0) rubyzip (>= 1.2.2) - sentry-raven (2.11.1) - faraday (>= 0.7.6, < 1.0) - simplecov (0.17.1) + sentry-raven (3.0.0) + faraday (>= 1.0) + simplecov (0.18.5) docile (~> 1.1) - json (>= 1.8, < 3) - simplecov-html (~> 0.10.0) - simplecov-html (0.10.2) - skylight (4.2.0) - skylight-core (= 4.2.0) - skylight-core (4.2.0) + simplecov-html (~> 0.11) + simplecov-html (0.12.2) + skylight (4.3.0) + skylight-core (= 4.3.0) + skylight-core (4.3.0) activesupport (>= 4.2.0) spring (2.1.0) spring-watcher-listen (2.0.1) @@ -311,19 +310,19 @@ GEM sqlite3 (1.4.2) terrapin (0.6.0) climate_control (>= 0.0.3, < 1.0) - thor (0.20.3) + thor (1.0.1) thread_safe (0.3.6) - tilt (2.0.9) + tilt (2.0.10) turbolinks (5.2.1) turbolinks-source (~> 5.2) turbolinks-source (5.2.0) - tzinfo (1.2.5) + tzinfo (1.2.7) thread_safe (~> 0.1) - tzinfo-data (1.2019.2) + tzinfo-data (1.2020.1) tzinfo (>= 1.0.0) uglifier (4.1.20) execjs (>= 0.3.0, < 3) - unicode-display_width (1.6.0) + unicode-display_width (1.6.1) url (0.3.2) web-console (3.7.0) actionview (>= 5.0) @@ -347,7 +346,7 @@ DEPENDENCIES action-cable-testing autoprefixer-rails (~> 9.7.3) aws-sdk-s3 (~> 1) - bootsnap (~> 1.4.5) + bootsnap (~> 1.4.6) bootstrap-sass byebug (~> 11.0.1) capybara diff --git a/Makefile b/Makefile index 6425efa7d..785044a78 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,6 @@ export COMPOSE_HTTP_TIMEOUT=360 +export COMPOSE_PROJECT_NAME +export PORT define wait_for_container @while ! docker-compose logs web | grep "web server started"; do\ @@ -10,7 +12,9 @@ endef build: cp config/database.yml.example config/database.yml cp config/config.yml.example config/config.yml + cp config/initializers/recaptcha.rb.example config/initializers/recaptcha.rb cp db/schema.rb.example db/schema.rb + docker-compose down --remove-orphans docker-compose build deploy-container: diff --git a/Procfile b/Procfile index 841da4133..b015561fd 100644 --- a/Procfile +++ b/Procfile @@ -1,2 +1,2 @@ -passenger: passenger start +passenger: passenger start --port $PORT puma: puma -C config/puma.rb diff --git a/app.yaml b/app.yaml new file mode 100644 index 000000000..76a354b38 --- /dev/null +++ b/app.yaml @@ -0,0 +1,25 @@ +env: flex +runtime: custom + +manual_scaling: + instances: 1 + +resources: + cpu: 1 + memory_gb: 4 +env_variables: + AWS_ACCESS_KEY_ID: + AWS_SECRET_ACCESS_KEY: + DB_USER: mapknitter + DB_PASS: mapknitter + DB_NAME: mapknitter + DB_HOST: localhost + DB_SOCKET: + RAILS_ENV: production + RECAPTCHA_KEY: + RECAPTCHA_SITE_KEY: + SECRET_KEY_BASE: + SENTRY_DSN: + +beta_settings: + cloud_sql_instances: diff --git a/cloudbuild.yaml b/cloudbuild.yaml new file mode 100644 index 000000000..a3bd75ed7 --- /dev/null +++ b/cloudbuild.yaml @@ -0,0 +1,14 @@ +steps: +- name: 'docker/compose:1.19.0' + args: ['up', '-d'] +- name: 'gcr.io/cloud-builders/docker' + args: ['tag', 'mapknitter-dev:latest', 'gcr.io/public-lab/mapknitter-dev'] +# Push it to GCR. +- name: 'gcr.io/cloud-builders/docker' + args: ['push', 'gcr.io/$PROJECT_ID/mapknitter-dev'] +# Deploy your Flex app from the image in GCR. +#- name: 'gcr.io/cloud-builders/gcloud' +# args: ['app', 'deploy', 'app.yaml', '--image-url=gcr.io/$PROJECT_ID/mapknitter-dev'] +# Note that this build pushes this image. +images: ['gcr.io/$PROJECT_ID/mapknitter-dev'] +timeout: 2200s diff --git a/config/database.yml.example b/config/database.yml.example index 6f196c70d..17eb65c53 100644 --- a/config/database.yml.example +++ b/config/database.yml.example @@ -14,10 +14,12 @@ production: adapter: mysql2 encoding: utf8 pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %> - host: <%= ENV.fetch("MYSQL_HOST") { '127.0.0.1' } %> - username: mapknitter - password: mapknitter - database: mapknitter + host: <%= ENV['DB_HOST'] || 'db' %> + username: <%= ENV['DB_USER'] || 'mapknitter' %> + password: <%= ENV['DB_PASS'] || 'mapknitter' %> + database: <%= ENV['DB_NAME'] || 'mapknitter' %> + socket: <%= ENV['DB_SOCKET'] %> + timeout: 5000 test: <<: *default diff --git a/config/routes.rb b/config/routes.rb index 5d7240e9b..dc8370d06 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -120,4 +120,5 @@ # See how all your routes lay out with 'rails routes' + get '/warps/:map/:file(.:format)', to: redirect('https://archive.publiclab.org/warps/%{map}/%{file}.%{format}') end diff --git a/db/migrate/20191214062147_add_index_for_warpable_map_id.rb b/db/migrate/20191214062147_add_index_for_warpable_map_id.rb index 2e0c62688..4eb1d67a4 100644 --- a/db/migrate/20191214062147_add_index_for_warpable_map_id.rb +++ b/db/migrate/20191214062147_add_index_for_warpable_map_id.rb @@ -1,4 +1,4 @@ -class AddIndexForWarpableMapId < ActiveRecord::Migration +class AddIndexForWarpableMapId < ActiveRecord::Migration[5.2] def up add_index "warpables", ["map_id"], :name => "index_warpables_on_map_id" end diff --git a/docker-compose.yml b/docker-compose.yml index 39445612c..e12aff86f 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -11,6 +11,7 @@ services: build: . ulimits: core: 0 + image: mapknitter-dev env_file: - mapknitter.env volumes: @@ -18,7 +19,7 @@ services: - bundle_cache:/usr/local/bundle - yarn_cache:/app/node_modules/ ports: - - $PORT:3000 + - ${PORT:-3000}:${PORT:-3000} depends_on: - db diff --git a/script/redirect.py b/script/redirect.py new file mode 100644 index 000000000..a221f4762 --- /dev/null +++ b/script/redirect.py @@ -0,0 +1,15 @@ +from google.appengine.ext import webapp +from google.appengine.ext.webapp.util import run_wsgi_app + +class AllHandler(webapp.RequestHandler): + def get(self): + self.redirect("https://tycho.media.mit.edu/warps", True) + +application = webapp.WSGIApplication([('/.*', AllHandler)]) + +def main(): + run_wsgi_app(application) + +if __name__ == "__main__": + main() + diff --git a/start.sh b/start.sh index 8bae2f5a7..d5f24df31 100755 --- a/start.sh +++ b/start.sh @@ -2,6 +2,12 @@ pidfile=/app/tmp/pids/server.pid +cp config/database.yml.example config/database.yml +cp config/config.yml.example config/config.yml +cp db/schema.rb.example db/schema.rb +mkdir -p tmp/pids +rm -rf tmp/cache/bootsnap* + if [ ! -f "./config/initializers/recaptcha.rb" ]; then echo -e "\e[33mWARNING\e[0m: You haven't configured recaptcha!" echo -e "\e[94mRead More\e[0m: https://github.com/publiclab/mapknitter#installation-steps" @@ -22,7 +28,7 @@ else bump_database fi -bundle exec rails assets:precompile +rake assets:precompile if [ -f $pidfile ] ; then >&2 echo 'Server PID file already exists. Removing it...'; diff --git a/yarn.lock b/yarn.lock index 2f3ee7c78..da0a906cd 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1036,14 +1036,6 @@ lazy-cache@^1.0.3: jquery "^3.2.1" leaflet "^1.3.3" -"leaflet-blurred-location@git://github.com/publiclab/leaflet-blurred-location.git#main": - version "1.6.0" - resolved "git://github.com/publiclab/leaflet-blurred-location.git#ef66dcb768094680e92d4f972b68f18cd4db6ccc" - dependencies: - haversine-distance "^1.1.4" - jquery "^3.2.1" - leaflet "^1.3.3" - leaflet-dist@vperron/leaflet-dist#0.7.x: version "0.0.0" resolved "https://codeload.github.com/vperron/leaflet-dist/tar.gz/2ec7a0846eaecdce1321d92b3c45c74f4fd08dd3"