docker-stack 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +14 -0
- data/.rspec +4 -0
- data/.rubocop.yml +25 -0
- data/.rubocop_todo.yml +23 -0
- data/.travis.yml +12 -0
- data/Gemfile +44 -0
- data/LICENSE.txt +13 -0
- data/README.md +117 -0
- data/Rakefile +12 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/docker-stack.gemspec +36 -0
- data/lib/docker/stack.rb +8 -0
- data/lib/docker/stack/container.rb +45 -0
- data/lib/docker/stack/controller.rb +115 -0
- data/lib/docker/stack/rake_task.rb +63 -0
- data/lib/docker/stack/version.rb +5 -0
- data/lib/generators/docker/stack/install_generator.rb +48 -0
- data/lib/generators/docker/stack/service.rb +49 -0
- data/lib/generators/docker/stack/service/fedora_generator.rb +20 -0
- data/lib/generators/docker/stack/service/postgres_generator.rb +22 -0
- data/lib/generators/docker/stack/service/redis_generator.rb +20 -0
- data/lib/generators/docker/stack/service/solr_generator.rb +22 -0
- data/lib/generators/docker/stack/templates/config/database.yml +23 -0
- data/lib/generators/docker/stack/templates/config/fedora.yml +15 -0
- data/lib/generators/docker/stack/templates/config/redis.yml +9 -0
- data/lib/generators/docker/stack/templates/config/solr.yml +7 -0
- data/lib/generators/docker/stack/templates/docker.rake +25 -0
- data/lib/generators/docker/stack/templates/services/fedora.yml.erb +9 -0
- data/lib/generators/docker/stack/templates/services/postgres.yml.erb +13 -0
- data/lib/generators/docker/stack/templates/services/redis.yml.erb +10 -0
- data/lib/generators/docker/stack/templates/services/solr.yml.erb +20 -0
- data/lib/generators/docker/stack/templates/solr/conf/_rest_managed.json +3 -0
- data/lib/generators/docker/stack/templates/solr/conf/admin-extra.html +31 -0
- data/lib/generators/docker/stack/templates/solr/conf/elevate.xml +36 -0
- data/lib/generators/docker/stack/templates/solr/conf/mapping-ISOLatin1Accent.txt +246 -0
- data/lib/generators/docker/stack/templates/solr/conf/protwords.txt +21 -0
- data/lib/generators/docker/stack/templates/solr/conf/schema.xml +366 -0
- data/lib/generators/docker/stack/templates/solr/conf/scripts.conf +24 -0
- data/lib/generators/docker/stack/templates/solr/conf/solrconfig.xml +322 -0
- data/lib/generators/docker/stack/templates/solr/conf/spellings.txt +2 -0
- data/lib/generators/docker/stack/templates/solr/conf/stopwords.txt +58 -0
- data/lib/generators/docker/stack/templates/solr/conf/stopwords_en.txt +58 -0
- data/lib/generators/docker/stack/templates/solr/conf/synonyms.txt +31 -0
- data/lib/generators/docker/stack/templates/solr/conf/xslt/example.xsl +132 -0
- data/lib/generators/docker/stack/templates/solr/conf/xslt/example_atom.xsl +67 -0
- data/lib/generators/docker/stack/templates/solr/conf/xslt/example_rss.xsl +66 -0
- data/lib/generators/docker/stack/templates/solr/conf/xslt/luke.xsl +337 -0
- data/lib/generators/docker/stack/util.rb +38 -0
- metadata +261 -0
@@ -0,0 +1,63 @@
|
|
1
|
+
require 'docker/stack'
|
2
|
+
|
3
|
+
# rubocop:disable all
|
4
|
+
module Docker
|
5
|
+
module Stack
|
6
|
+
module RakeTask
|
7
|
+
class << self
|
8
|
+
include ::Rake::DSL if defined?(::Rake::DSL)
|
9
|
+
|
10
|
+
def load_tasks(force_env: nil, cleanup: false)
|
11
|
+
desc 'Clean up the development stack'
|
12
|
+
task :clean do
|
13
|
+
Controller.new(env: force_env, cleanup: true).down
|
14
|
+
end
|
15
|
+
|
16
|
+
desc 'Run the stack in the background'
|
17
|
+
task :daemon do
|
18
|
+
Controller.new(env: force_env, daemon: true).start
|
19
|
+
end
|
20
|
+
|
21
|
+
desc 'Bring down the stack'
|
22
|
+
task :down do
|
23
|
+
Controller.new(env: force_env, cleanup: cleanup).down
|
24
|
+
end
|
25
|
+
|
26
|
+
desc 'Show the server logs'
|
27
|
+
task :logs do
|
28
|
+
services = ENV['SERVICES'].to_s.split(/[\s,;]+/)
|
29
|
+
Controller.new(env: force_env).logs(*services)
|
30
|
+
end
|
31
|
+
|
32
|
+
desc 'Remove containers, volumes, and images'
|
33
|
+
task :reset do
|
34
|
+
Controller.new(env: force_env).reset! do |result|
|
35
|
+
results = JSON.parse(result)
|
36
|
+
results.each do |result_hash|
|
37
|
+
result_hash.each_pair do |action, target|
|
38
|
+
puts "#{action} #{target}"
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
desc 'Show server status'
|
45
|
+
task :status do
|
46
|
+
status = Controller.new(env: force_env).status
|
47
|
+
puts '%-20s %-16s %-20s' % ['SERVICE', 'STATUS', 'UPTIME']
|
48
|
+
puts '-' * 56
|
49
|
+
status.each do |s|
|
50
|
+
puts '%-20s %-16s %-20s' % s.values_at(:service, :status, :running)
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
desc 'Run the stack in the foreground'
|
55
|
+
task :up do
|
56
|
+
Controller.new(env: force_env, cleanup: cleanup).start
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
# rubocop:enable all
|
@@ -0,0 +1,48 @@
|
|
1
|
+
require 'generators/docker/stack/util'
|
2
|
+
require 'active_support/core_ext/hash/keys'
|
3
|
+
|
4
|
+
module Docker
|
5
|
+
module Stack
|
6
|
+
class InstallGenerator < Rails::Generators::Base
|
7
|
+
include Util
|
8
|
+
|
9
|
+
class_option :env, type: :string, default: nil
|
10
|
+
class_option :services, type: :string, default: ''
|
11
|
+
|
12
|
+
source_root File.expand_path('templates', __dir__)
|
13
|
+
desc %(This generator makes the following changes to your application:
|
14
|
+
1. Creates skeleton docker-compose.yml files for development and test mode
|
15
|
+
with fedora, and solr containers.
|
16
|
+
2. Creates lib/tasks/docker.rake.
|
17
|
+
)
|
18
|
+
|
19
|
+
def create_service_configs
|
20
|
+
environments.each do |env|
|
21
|
+
create_file compose_file_path(env), empty_service_config.to_yaml, force: false, skip: true
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
def create_services
|
26
|
+
env_param = "--env #{options[:env]}" unless options[:env].nil?
|
27
|
+
services.each do |service|
|
28
|
+
generate "docker:stack:service:#{service}", env_param
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
def add_rake_tasks
|
33
|
+
copy_file 'docker.rake', 'lib/tasks/docker.rake'
|
34
|
+
end
|
35
|
+
|
36
|
+
no_tasks do
|
37
|
+
def environments
|
38
|
+
return %w[development test] if options[:env].nil?
|
39
|
+
options[:env].split(/,/)
|
40
|
+
end
|
41
|
+
|
42
|
+
def services
|
43
|
+
options[:services].split(/,/)
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
@@ -0,0 +1,49 @@
|
|
1
|
+
require 'generators/docker/stack/util'
|
2
|
+
require 'active_support/core_ext/hash/deep_merge'
|
3
|
+
require 'ostruct'
|
4
|
+
|
5
|
+
module Docker
|
6
|
+
module Stack
|
7
|
+
module Service
|
8
|
+
def self.included(base)
|
9
|
+
base.include Util
|
10
|
+
|
11
|
+
base.class_option :env, type: :string, default: 'development,test'
|
12
|
+
|
13
|
+
base.define_method :add_service do
|
14
|
+
options[:env].split(/,/).each do |env|
|
15
|
+
@env = env
|
16
|
+
add_service_for_environment
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
base.no_tasks do
|
21
|
+
def service
|
22
|
+
self.class.generator_name
|
23
|
+
end
|
24
|
+
|
25
|
+
def add_service_for_environment
|
26
|
+
new_service_config = current_service_config.deep_merge(service_from_template(service))
|
27
|
+
say_status :update, "#{relative_to_original_destination_root(compose_file_full_path)} [#{service}]", true
|
28
|
+
File.open(compose_file_full_path, 'w') do |f|
|
29
|
+
YAML.dump(new_service_config, f)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
def service_from_template(service)
|
34
|
+
source = File.expand_path(find_in_source_paths("services/#{service}.yml.erb"))
|
35
|
+
context = OpenStruct.new(env: @env, port_offset: port_offset).instance_eval { binding }
|
36
|
+
yaml = Thor::Actions::CapturableERB.new(::File.binread(source), nil, '-', '@output_buffer').tap do |erb|
|
37
|
+
erb.filename = source
|
38
|
+
end.result(context)
|
39
|
+
YAML.safe_load(yaml)
|
40
|
+
end
|
41
|
+
|
42
|
+
def port_offset
|
43
|
+
{ 'development' => 0, 'test' => 2 }[@env] || 0
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require 'generators/docker/stack/service'
|
2
|
+
|
3
|
+
module Docker
|
4
|
+
module Stack
|
5
|
+
module Service
|
6
|
+
class FedoraGenerator < Rails::Generators::Base
|
7
|
+
include Docker::Stack::Service
|
8
|
+
|
9
|
+
desc %(This generator makes the following changes to your application:
|
10
|
+
1. Adds a fedora service configuration to the docker-compose.yml files.
|
11
|
+
2. Creates a config/fedora.yml file pointing to the new service.
|
12
|
+
)
|
13
|
+
|
14
|
+
def install_service
|
15
|
+
copy_file 'config/fedora.yml', 'config/fedora.yml'
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require 'generators/docker/stack/service'
|
2
|
+
|
3
|
+
module Docker
|
4
|
+
module Stack
|
5
|
+
module Service
|
6
|
+
class PostgresGenerator < Rails::Generators::Base
|
7
|
+
include Docker::Stack::Service
|
8
|
+
|
9
|
+
desc %(This generator makes the following changes to your application:
|
10
|
+
1. Adds a db service configuration to the docker-compose.yml files.
|
11
|
+
2. Creates a config/database.yml file pointing to the new service.
|
12
|
+
3. Adds the 'pg' gem to the Gemfile.
|
13
|
+
)
|
14
|
+
|
15
|
+
def install_service
|
16
|
+
copy_file 'config/database.yml', 'config/database.yml'
|
17
|
+
gem 'pg'
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require 'generators/docker/stack/service'
|
2
|
+
|
3
|
+
module Docker
|
4
|
+
module Stack
|
5
|
+
module Service
|
6
|
+
class RedisGenerator < Rails::Generators::Base
|
7
|
+
include Docker::Stack::Service
|
8
|
+
|
9
|
+
desc %(This generator makes the following changes to your application:
|
10
|
+
1. Adds a redis service configuration to the docker-compose.yml files.
|
11
|
+
2. Creates a config/redis.yml file pointing to the new service.
|
12
|
+
)
|
13
|
+
|
14
|
+
def install_service
|
15
|
+
copy_file 'config/redis.yml', 'config/redis.yml'
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require 'generators/docker/stack/service'
|
2
|
+
|
3
|
+
module Docker
|
4
|
+
module Stack
|
5
|
+
module Service
|
6
|
+
class SolrGenerator < Rails::Generators::Base
|
7
|
+
include Docker::Stack::Service
|
8
|
+
|
9
|
+
desc %(This generator makes the following changes to your application:
|
10
|
+
1. Adds a solr service configuration to the docker-compose.yml files.
|
11
|
+
2. Creates a config/solr.yml file pointing to the new service.
|
12
|
+
3. Adds a solr directory to the root containing solr config files for the solr service.
|
13
|
+
)
|
14
|
+
|
15
|
+
def install_service
|
16
|
+
copy_file 'config/solr.yml', 'config/solr.yml'
|
17
|
+
directory 'solr'
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
default: &default
|
2
|
+
adapter: postgresql
|
3
|
+
host: localhost
|
4
|
+
encoding: unicode
|
5
|
+
pool: 5
|
6
|
+
username: docker
|
7
|
+
password: d0ck3r
|
8
|
+
|
9
|
+
development:
|
10
|
+
<<: *default
|
11
|
+
port: 5433
|
12
|
+
database: docker_dev
|
13
|
+
|
14
|
+
test:
|
15
|
+
<<: *default
|
16
|
+
port: <%= Rails.env.development? ? 5433 : 5435 %>
|
17
|
+
database: docker_test
|
18
|
+
|
19
|
+
production:
|
20
|
+
adapter: sqlite3
|
21
|
+
pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
|
22
|
+
timeout: 5000
|
23
|
+
database: db/production.sqlite3
|
@@ -0,0 +1,15 @@
|
|
1
|
+
development:
|
2
|
+
user: fedoraAdmin
|
3
|
+
password: fedoraAdmin
|
4
|
+
url: http://127.0.0.1:<%= ENV['FCREPO_DEVELOPMENT_PORT'] || 8984 %>/rest
|
5
|
+
base_path: /dev
|
6
|
+
test:
|
7
|
+
user: fedoraAdmin
|
8
|
+
password: fedoraAdmin
|
9
|
+
url: http://127.0.0.1:<%= ENV['FCREPO_TEST_PORT'] || 8986 %>/rest
|
10
|
+
base_path: /test
|
11
|
+
production:
|
12
|
+
user: fedoraAdmin
|
13
|
+
password: fedoraAdmin
|
14
|
+
url: http://127.0.0.1:8983/fedora/rest
|
15
|
+
base_path: /prod
|
@@ -0,0 +1,7 @@
|
|
1
|
+
# This is a sample config file that points to a solr server for each environment
|
2
|
+
development:
|
3
|
+
url: http://127.0.0.1:<%= ENV['SOLR_TEST_PORT'] || 8983 %>/solr/development-core
|
4
|
+
test:
|
5
|
+
url: http://127.0.0.1:<%= ENV['SOLR_TEST_PORT'] || 8985 %>/solr/test-core
|
6
|
+
production:
|
7
|
+
url: http://127.0.0.1:8983/solr/donut
|
@@ -0,0 +1,25 @@
|
|
1
|
+
require 'docker/stack/rake_task'
|
2
|
+
|
3
|
+
def get_named_task(task_name)
|
4
|
+
Rake::Task[task_name]
|
5
|
+
rescue RuntimeError
|
6
|
+
nil
|
7
|
+
end
|
8
|
+
|
9
|
+
namespace :docker do
|
10
|
+
namespace(:dev) { Docker::Stack::RakeTask.load_tasks }
|
11
|
+
namespace(:test) { Docker::Stack::RakeTask.load_tasks(force_env: 'test', cleanup: true) }
|
12
|
+
|
13
|
+
desc 'Spin up test stack and run specs'
|
14
|
+
task :spec do
|
15
|
+
Rails.env = 'test'
|
16
|
+
Docker::Stack::Controller.new(cleanup: true).with_containers do
|
17
|
+
Rake::Task['db:setup'].invoke
|
18
|
+
|
19
|
+
task = get_named_task(ENV['SPEC_TASK']) ||
|
20
|
+
get_named_task('spec') ||
|
21
|
+
get_named_task('rspec')
|
22
|
+
task.invoke unless task.nil?
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
volumes:
|
2
|
+
solr:
|
3
|
+
services:
|
4
|
+
solr:
|
5
|
+
image: solr:7.2-alpine
|
6
|
+
ports:
|
7
|
+
- "<%= 8983 + port_offset %>:8983"
|
8
|
+
volumes:
|
9
|
+
- solr:/opt/solr/server/solr/mycores
|
10
|
+
- ../../solr:/solr_config
|
11
|
+
entrypoint:
|
12
|
+
- docker-entrypoint.sh
|
13
|
+
- solr-precreate
|
14
|
+
- <%= env %>-core
|
15
|
+
- /solr_config/conf
|
16
|
+
healthcheck:
|
17
|
+
test: ["CMD", "wget", "-O", "/dev/null", "http://localhost:8983/solr/"]
|
18
|
+
interval: 30s
|
19
|
+
timeout: 5s
|
20
|
+
retries: 3
|
@@ -0,0 +1,31 @@
|
|
1
|
+
<!--
|
2
|
+
Licensed to the Apache Software Foundation (ASF) under one or more
|
3
|
+
contributor license agreements. See the NOTICE file distributed with
|
4
|
+
this work for additional information regarding copyright ownership.
|
5
|
+
The ASF licenses this file to You under the Apache License, Version 2.0
|
6
|
+
(the "License"); you may not use this file except in compliance with
|
7
|
+
the License. You may obtain a copy of the License at
|
8
|
+
|
9
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
10
|
+
|
11
|
+
Unless required by applicable law or agreed to in writing, software
|
12
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
13
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
14
|
+
See the License for the specific language governing permissions and
|
15
|
+
limitations under the License.
|
16
|
+
-->
|
17
|
+
|
18
|
+
<!-- The content of this page will be statically included into the top
|
19
|
+
of the admin page. Uncomment this as an example to see there the content
|
20
|
+
will show up.
|
21
|
+
|
22
|
+
<hr>
|
23
|
+
<i>This line will appear before the first table</i>
|
24
|
+
<tr>
|
25
|
+
<td colspan="2">
|
26
|
+
This row will be appended to the end of the first table
|
27
|
+
</td>
|
28
|
+
</tr>
|
29
|
+
<hr>
|
30
|
+
|
31
|
+
-->
|
@@ -0,0 +1,36 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8" ?>
|
2
|
+
<!--
|
3
|
+
Licensed to the Apache Software Foundation (ASF) under one or more
|
4
|
+
contributor license agreements. See the NOTICE file distributed with
|
5
|
+
this work for additional information regarding copyright ownership.
|
6
|
+
The ASF licenses this file to You under the Apache License, Version 2.0
|
7
|
+
(the "License"); you may not use this file except in compliance with
|
8
|
+
the License. You may obtain a copy of the License at
|
9
|
+
|
10
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
11
|
+
|
12
|
+
Unless required by applicable law or agreed to in writing, software
|
13
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
14
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
15
|
+
See the License for the specific language governing permissions and
|
16
|
+
limitations under the License.
|
17
|
+
-->
|
18
|
+
|
19
|
+
<!-- If this file is found in the config directory, it will only be
|
20
|
+
loaded once at startup. If it is found in Solr's data
|
21
|
+
directory, it will be re-loaded every commit.
|
22
|
+
-->
|
23
|
+
|
24
|
+
<elevate>
|
25
|
+
<query text="foo bar">
|
26
|
+
<doc id="1" />
|
27
|
+
<doc id="2" />
|
28
|
+
<doc id="3" />
|
29
|
+
</query>
|
30
|
+
|
31
|
+
<query text="ipod">
|
32
|
+
<doc id="MA147LL/A" /> <!-- put the actual ipod at the top -->
|
33
|
+
<doc id="IW-02" exclude="true" /> <!-- exclude this cable -->
|
34
|
+
</query>
|
35
|
+
|
36
|
+
</elevate>
|