Skip to content

Commit

Permalink
Merge pull request #897 from pulibrary/890-lando
Browse files Browse the repository at this point in the history
Add lando and remove solr_wrapper
  • Loading branch information
christinach committed Oct 1, 2020
2 parents 2007f33 + c1be889 commit a2db088
Show file tree
Hide file tree
Showing 14 changed files with 119 additions and 96 deletions.
16 changes: 13 additions & 3 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@ jobs:
RAILS_ENV: test
PULMAP_DB_HOST: localhost
PULMAP_DB_USERNAME: geoblacklight
- image: postgres:10.6-alpine
environment:
POSTGRES_USER: geoblacklight
POSTGRES_DB: pulmap_test
POSTGRES_HOST_AUTH_METHOD: trust
steps:
- checkout
# Restore Cached Dependencies
Expand Down Expand Up @@ -65,8 +70,13 @@ jobs:
RAILS_ENV: test
PULMAP_DB_HOST: localhost
PULMAP_DB_USERNAME: geoblacklight
- image: postgres:10.6-alpine
environment:
POSTGRES_USER: geoblacklight
POSTGRES_DB: pulmap_test
POSTGRES_HOST_AUTH_METHOD: trust
- image: solr:7.7-alpine
command: bin/solr -cloud -noprompt -f -p 8985
command: bin/solr -cloud -noprompt -f -p 8984
steps: &test_steps
- attach_workspace:
at: '~/pulmap'
Expand All @@ -93,8 +103,8 @@ jobs:
command: |
cd solr/conf
zip -1 -r solr_config.zip ./*
curl -H "Content-type:application/octet-stream" --data-binary @solr_config.zip "http://localhost:8985/solr/admin/configs?action=UPLOAD&name=pulmap"
curl -H 'Content-type: application/json' http://localhost:8985/api/collections/ -d '{create: {name: pulmap-core-test, config: pulmap, numShards: 1}}'
curl -H "Content-type:application/octet-stream" --data-binary @solr_config.zip "http://localhost:8984/solr/admin/configs?action=UPLOAD&name=pulmap"
curl -H 'Content-type: application/json' http://localhost:8984/api/collections/ -d '{create: {name: pulmap-core-test, config: pulmap, numShards: 1}}'
- run: bundle exec rake db:migrate
- run: bundle exec rake geoblacklight:solr:seed
- run: bundle exec rspec spec/
Expand Down
22 changes: 22 additions & 0 deletions .lando.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: pulmap
services:
pulmap_test_solr:
type: solr:8.4
portforward: true
core: pulmap-core-test
config:
dir: "solr/conf"
pulmap_development_solr:
type: solr:8.4
portforward: true
core: pulmap-core-dev
config:
dir: "solr/conf"
pulmap_database:
type: postgres:10
portforward: true
proxy:
pulmap_test_solr:
- pulmap.test.solr.lndo.site:8983
pulmap_development_solr:
- pulmap.dev.solr.lndo.site:8983
1 change: 0 additions & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ gem 'sidekiq'
gem 'simple_form'
gem 'sitemap_generator', '~> 6.0'
gem 'sneakers'
gem 'solr_wrapper'
gem 'twitter-typeahead-rails'
gem 'webpacker'
gem 'whenever'
6 changes: 0 additions & 6 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -510,11 +510,6 @@ GEM
rake (~> 12.3)
serverengine (~> 2.1.0)
thor
solr_wrapper (2.2.0)
faraday
retriable
ruby-progressbar
rubyzip
spring (2.1.1)
sprockets (3.7.2)
concurrent-ruby (~> 1.0)
Expand Down Expand Up @@ -624,7 +619,6 @@ DEPENDENCIES
simple_form
sitemap_generator (~> 6.0)
sneakers
solr_wrapper
spring
sqlite3
turbolinks
Expand Down
23 changes: 12 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,24 @@ GeoBlacklight for Princeton University Library
[![CircleCI](https://circleci.com/gh/pulibrary/pulmap.svg?style=svg)](https://circleci.com/gh/pulibrary/pulmap)
[![Coverage Status](https://coveralls.io/repos/pulibrary/pulmap/badge.svg?branch=master&service=github)](https://coveralls.io/github/pulibrary/pulmap?branch=master)

### Installation
```
bundle
rake db:migrate
npm install --global yarn
yarn
### Initial Setup
```sh
git clone https://github.com/pulibrary/pulmap.git
cd pulmap
bundle install
yarn install
```

### Setup server

1. Install Lando DMG from https://github.com/lando/lando/releases
1. To start: `rake pulmap:server:start`
1. For test:
- `rake pulmap:test`
- In a separate terminal: `bundle exec rspec`
2. For development:
- `rake pulmap:development`
- In a separate terminal: `rails s`
- `bundle exec rspec`
1. For development:
- `rails s`
- Access Pulmap at http://localhost:3000/
1. To stop: `rake pulmap:server:stop` or `lando stop`

### Auto-update from external services

Expand Down
2 changes: 0 additions & 2 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ require "rubocop/rake_task" if Rails.env.development? || Rails.env.test?

Rails.application.load_tasks

require 'solr_wrapper/rake_task' if Rails.env.development? || Rails.env.test?

if defined? RuboCop
desc "Run RuboCop style checker"
RuboCop::RakeTask.new(:rubocop) do |task|
Expand Down
1 change: 1 addition & 0 deletions config/application.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
require File.expand_path('../boot', __FILE__)

require 'rails/all'
require_relative 'lando_env'

# Require the gems listed in Gemfile, including any gems
# you've limited to :test, :development, or :production.
Expand Down
4 changes: 2 additions & 2 deletions config/blacklight.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
development:
adapter: solr
url: <%= ENV['SOLR_URL'] || "http://127.0.0.1:8983/solr/pulmap-core-dev" %>
url: <%= ENV['SOLR_URL'] || "http://#{ENV["lando_pulmap_development_solr_conn_host"] || "127.0.0.1"}:#{ENV["lando_pulmap_development_solr_conn_port"] || 8983}/solr/pulmap-core-dev" %>
test: &test
adapter: solr
url: <%= ENV['SOLR_URL'] || "http://127.0.0.1:#{ENV['TEST_JETTY_PORT'] || 8985}/solr/pulmap-core-test" %>
url: <%= ENV['SOLR_URL'] || "http://#{ENV["lando_pulmap_test_solr_conn_host"] || "127.0.0.1"}:#{ENV['SOLR_TEST_PORT'] || ENV["lando_pulmap_test_solr_conn_port"] || 8984}/solr/pulmap-core-test" %>
production:
adapter: solr
url: <%= ENV['PULMAP_SOLR_URL'] %>
Expand Down
23 changes: 12 additions & 11 deletions config/database.yml
Original file line number Diff line number Diff line change
@@ -1,25 +1,26 @@
default: &default
adapter: sqlite3
adapter: postgresql
encoding: unicode
host: <%= ENV["lando_pulmap_database_conn_host"] || ENV["PULMAP_DB_HOST"] || "localhost" %>
port: <%= ENV["lando_pulmap_database_conn_port"] || 5432 %>
username: <%= ENV["lando_pulmap_database_creds_user"] || ENV["PULMAP_DB_USERNAME"] %>
password: <%= ENV["lando_pulmap_database_creds_password"] || ENV["PULMAP_DB_PASSWORD"] %>
database: <%= ENV['PULMAP_DB'] %>
pool: 5
timeout: 5000

development:
<<: *default
database: db/development.sqlite3
database: pulmap_development

# Warning: The database defined as "test" will be erased and
# re-generated from your development database when you run "rake".
# Do not set this db to the same as development or production.
test:
<<: *default
database: db/test.sqlite3
database: pulmap_test

production: &deploy
production:
<<: *default
adapter: postgresql
database: <%= ENV["PULMAP_DB"] %>
host: <%= ENV["PULMAP_DB_HOST"] %>
username: <%= ENV["PULMAP_DB_USERNAME"] %>
password: <%= ENV["PULMAP_DB_PASSWORD"] %>

staging: *deploy
staging:
<<: *default
17 changes: 17 additions & 0 deletions config/lando_env.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# frozen_string_literal: true
if Rails.env.development? || Rails.env.test?
begin
lando_services = JSON.parse(`lando info --format json`, symbolize_names: true)
lando_services.each do |service|
service[:external_connection]&.each do |key, value|
ENV["lando_#{service[:service]}_conn_#{key}"] = value
end
next unless service[:creds]
service[:creds].each do |key, value|
ENV["lando_#{service[:service]}_creds_#{key}"] = value
end
end
rescue StandardError
nil
end
end
17 changes: 11 additions & 6 deletions db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,14 @@

ActiveRecord::Schema.define(version: 2020_03_04_234118) do

# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"

create_table "active_storage_attachments", force: :cascade do |t|
t.string "name", null: false
t.string "record_type", null: false
t.integer "record_id", null: false
t.integer "blob_id", null: false
t.bigint "record_id", null: false
t.bigint "blob_id", null: false
t.datetime "created_at", null: false
t.index ["blob_id"], name: "index_active_storage_attachments_on_blob_id"
t.index ["record_type", "record_id", "name", "blob_id"], name: "index_active_storage_attachments_uniqueness", unique: true
Expand All @@ -33,7 +36,7 @@
t.index ["key"], name: "index_active_storage_blobs_on_key", unique: true
end

create_table "bookmarks", force: :cascade do |t|
create_table "bookmarks", id: :serial, force: :cascade do |t|
t.integer "user_id", null: false
t.string "user_type"
t.string "document_id"
Expand All @@ -44,7 +47,7 @@
t.index ["user_id"], name: "index_bookmarks_on_user_id"
end

create_table "searches", force: :cascade do |t|
create_table "searches", id: :serial, force: :cascade do |t|
t.text "query_params"
t.integer "user_id"
t.string "user_type"
Expand All @@ -69,13 +72,13 @@
t.string "document_id"
t.string "document_type"
t.string "image"
t.integer "version", limit: 8
t.bigint "version"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.index ["document_type", "document_id"], name: "sidecars_solr_document"
end

create_table "users", force: :cascade do |t|
create_table "users", id: :serial, force: :cascade do |t|
t.string "email", default: "", null: false
t.string "encrypted_password", default: "", null: false
t.string "reset_password_token"
Expand All @@ -97,4 +100,6 @@
t.index ["username"], name: "index_users_on_username"
end

add_foreign_key "active_storage_attachments", "active_storage_blobs", column: "blob_id"
add_foreign_key "sidecar_image_transitions", "solr_document_sidecars"
end
46 changes: 14 additions & 32 deletions lib/tasks/pulmap.rake
Original file line number Diff line number Diff line change
Expand Up @@ -29,41 +29,23 @@ namespace :pulmap do
end
end

desc "Start solr server for testing."
task :test do
if Rails.env.test?
shared_solr_opts = { managed: true, verbose: true, persist: false, download_dir: 'tmp' }
shared_solr_opts[:version] = ENV['SOLR_VERSION'] if ENV['SOLR_VERSION']
namespace :server do
desc "Start solr and postgres servers using lando."
task :start do
system('lando start')
system('rake pulmap:server:seed')
system('rake pulmap:server:seed RAILS_ENV=test')
end

SolrWrapper.wrap(shared_solr_opts.merge(port: 8985, instance_dir: 'tmp/pulmap-core-test')) do |solr|
solr.with_collection(name: "pulmap-core-test", dir: Rails.root.join("solr", "conf").to_s) do
puts "Solr running at http://localhost:8985/solr/pulmap-core-test/, ^C to exit"
begin
Rake::Task['geoblacklight:solr:seed'].invoke
sleep
rescue Interrupt
puts "\nShutting down..."
end
end
end
else
system('rake pulmap:test RAILS_ENV=test')
task :seed do
Rake::Task['db:create'].invoke
Rake::Task['db:migrate'].invoke
Rake::Task['geoblacklight:solr:seed'].invoke
end
end

desc "Start solr server for development."
task :development do
SolrWrapper.wrap(managed: true, verbose: true, port: 8983, instance_dir: 'tmp/pulmap-core-dev', persist: false, download_dir: 'tmp') do |solr|
solr.with_collection(name: "pulmap-core-dev", dir: Rails.root.join("solr", "conf").to_s) do
puts "Setup solr"
puts "Solr running at http://localhost:8983/solr/pulmap-core-dev/, ^C to exit"
begin
Rake::Task['geoblacklight:solr:seed'].invoke
sleep
rescue Interrupt
puts "\nShutting down..."
end
end
desc "Stop lando solr and postgres servers."
task :stop do
system('lando stop')
end
end

Expand Down
Loading

0 comments on commit a2db088

Please sign in to comment.