error_agency-docker 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: c15090368cdb7f05997649fc30b8b5ba503e9074d0bd632668884d9aabd720d1
4
+ data.tar.gz: 07cdaf4a149e8a9cdbeb320bee00e50de20e9152eea1480835983553813916d7
5
+ SHA512:
6
+ metadata.gz: b5ab5420644d64d838d449935e329b0125fa2502d9a7089a7a276610177bc8b6527b8684e14ce1bbeda9a24e504f0fc561748b8dc8ee238e90bcd76d5127d332
7
+ data.tar.gz: da4f0c9722239ce029881475cfc2f4f6a4979c23ac6307418d75ef8ef8342362da3ccb81e31b48bed0552af3c99f44a9ece86e673936d2ed35b03ae9ed94e6b7
@@ -0,0 +1,9 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+ .idea
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "https://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in error_agency-docker.gemspec
4
+ gemspec
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2019 Error Ltd
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
@@ -0,0 +1,42 @@
1
+ # ErrorAgency::Docker
2
+
3
+ A Rails generator to add docker configurations to your application.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'error_agency-docker'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install error_agency-docker
20
+
21
+ ## Usage
22
+
23
+ ### Development Environment
24
+ Run `rails g error_agency:docker:development_environment` to set up docker configs for development.
25
+
26
+ The following optional switches add more containers or change behaviour:
27
+
28
+ `--elasticsearch` - add an elasticsearch container
29
+ `--elasticsearch-version` - defaults to 6.2.4
30
+ `--headless-chrome` - add a headless chrome container for selenium tests
31
+ `--mysql-version` - defaults to 5.6
32
+ `--ruby-version` - defaults to 6.2.5
33
+
34
+ Requires Rails 5 or 6.
35
+
36
+ ## Contributing
37
+
38
+ Bug reports and pull requests are welcome on GitHub at https://github.com/errorstudio/error_agency-docker.
39
+
40
+ ## License
41
+
42
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+ task :default => :spec
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "error_agency/docker"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start(__FILE__)
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,31 @@
1
+ lib = File.expand_path("lib", __dir__)
2
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
+ require "error_agency/docker/version"
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = "error_agency-docker"
7
+ spec.version = ErrorAgency::Docker::VERSION
8
+ spec.authors = ["Ed Jones", "Paul Hendrick", "Sean Hawkridge"]
9
+ spec.email = ["ed@error.agency", "paul@error.agency", "sean@error.agency"]
10
+
11
+ spec.summary = "A Rails generator for docker configurations"
12
+ spec.homepage = "https://github.com/errorstudio/error_agency-docker"
13
+ spec.license = "MIT"
14
+
15
+ spec.metadata["homepage_uri"] = spec.homepage
16
+ spec.metadata["source_code_uri"] = "https://github.com/errorstudio/error_agency-docker.git"
17
+
18
+ # Specify which files should be added to the gem when it is released.
19
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
20
+ spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
21
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
22
+ end
23
+ spec.bindir = "exe"
24
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
25
+ spec.require_paths = ["lib"]
26
+
27
+ spec.add_development_dependency "bundler", "~> 2.0"
28
+ spec.add_development_dependency "rake", "~> 10.0"
29
+
30
+ spec.add_dependency "rails", ">= 5", "<= 7"
31
+ end
@@ -0,0 +1,8 @@
1
+ require "error_agency/docker/version"
2
+
3
+ module ErrorAgency
4
+ module Docker
5
+ class Error < StandardError; end
6
+ # Your code goes here...
7
+ end
8
+ end
@@ -0,0 +1,5 @@
1
+ module ErrorAgency
2
+ module Docker
3
+ VERSION = "0.1.0"
4
+ end
5
+ end
@@ -0,0 +1,53 @@
1
+ module ErrorAgency
2
+ module Docker
3
+ class DevelopmentEnvironmentGenerator < Rails::Generators::Base
4
+
5
+ desc "Install files for running Rails in docker containers, in development."
6
+
7
+ source_root File.expand_path("../templates", __FILE__)
8
+
9
+ class_option :build, type: :boolean, desc: "Build the docker images after running the generator", default: false
10
+ class_option :mysql, type: :boolean, desc: "Generate docker configs for MySQL. Installs by default.", default: true
11
+ class_option :redis, type: :boolean, desc: "Generate docker configs for Redis. Installs by default.", default: true
12
+ class_option :mailhog, type: :boolean, desc: "Generate docker configs for Mailhog. Installed by default.", default: true
13
+ class_option :elasticsearch, type: :boolean, desc: "Generate docker configs for Elasticsearch. NOT installed by default.", default: false
14
+ class_option :headless_chrome, type: :boolean, desc: "Generate configs for headless Chrome. NOT installed by default."
15
+ class_option :ruby_version, type: :string, desc: "Define the Ruby version to use", default: "2.6.5"
16
+ class_option :elasticsearch_version, type: :string, desc: "Define the Elasticsearch version to use", default: "6.2.4"
17
+ class_option :mysql_version, type: :string, desc: "Define the MySQL version to use", default: "5.6"
18
+
19
+
20
+ def create_docker_compose
21
+ @mysql = options[:mysql]
22
+ @redis = options[:redis]
23
+ @elasticsearch = options[:elasticsearch]
24
+ @mailhog = options[:mailhog]
25
+ @mysql_version = options[:mysql_version]
26
+
27
+ template "docker_compose.yml.erb", "docker-compose.yml"
28
+ end
29
+
30
+ def create_rails_base
31
+ @ruby_version = options[:ruby_version]
32
+
33
+ template "rails_base/Dockerfile.erb", "config/docker/rails_base/Dockerfile"
34
+ template "rails_base/entrypoint.sh.erb", "config/docker/rails_base/entrypoint.sh"
35
+ end
36
+
37
+ def create_elasticsearch
38
+ if options[:elasticsearch]
39
+ @elasticsearch_version = options[:elasticsearch_version]
40
+ template "elasticsearch/Dockerfile.erb", "config/docker/elasticsearch/Dockerfile"
41
+ end
42
+ end
43
+
44
+ def build_images
45
+ if options[:build]
46
+ system "docker-compose build"
47
+ end
48
+ end
49
+
50
+
51
+ end
52
+ end
53
+ end
@@ -0,0 +1,122 @@
1
+ version: '3.5'
2
+
3
+ services:
4
+ rails_base: &rails_base
5
+ build:
6
+ context: .
7
+ dockerfile: ./config/docker/rails_base/Dockerfile
8
+ tmpfs:
9
+ - /tmp
10
+ volumes:
11
+ - .:/app:cached
12
+ - bundle:/bundle
13
+ - node_modules:/app/node_modules
14
+ - packs:/app/public/packs
15
+ - rails_cache:/app/tmp/cache
16
+ - ~/.ssh:/root/.ssh
17
+ - irb_history:/root/irb_history
18
+ - ./config/docker/web/.irbrc:/root/.irbrc
19
+ stdin_open: true
20
+ tty: true
21
+
22
+ web:
23
+ <<: *rails_base
24
+ ports:
25
+ - 3000:3000
26
+ command: rails s -b 0.0.0.0
27
+ environment:
28
+ - WEBPACKER_DEV_SERVER_HOST=webpacker
29
+
30
+ webpacker:
31
+ <<: *rails_base
32
+ ports:
33
+ - 3035:3035
34
+ command: ./bin/webpack-dev-server
35
+ environment:
36
+ - WEBPACKER_DEV_SERVER_HOST=0.0.0.0
37
+
38
+ shell:
39
+ <<: *rails_base
40
+ command: bash
41
+
42
+ <% if @mysql %>
43
+ mysql:
44
+ image: mysql:<%= @mysql_version %>
45
+ volumes:
46
+ - ./config/docker/mysql/my.cnf:/etc/mysql/conf.d/my.cnf
47
+ - db_data:/var/lib/mysql
48
+ - .:/app:cached
49
+ environment:
50
+ - MYSQL_ROOT_PASSWORD=root
51
+ labels:
52
+ - maintainer='paul@error.agency'
53
+ ports:
54
+ - 3306:3306
55
+ <% end %>
56
+
57
+ <% if @redis %>
58
+ redis:
59
+ image: redis:3.2
60
+ labels:
61
+ - maintainer='paul@error.agency'
62
+ ports:
63
+ - 6379:6379
64
+ <% end %>
65
+ <% if @mailhog %>
66
+ mailhog:
67
+ command: ["-smtp-bind-addr", "0.0.0.0:2525"]
68
+ user: root
69
+ image: mailhog/mailhog
70
+ ports:
71
+ - 2525:2525
72
+ - 8025:8025
73
+ <% end %>
74
+
75
+ <% if @elasticsearch %>
76
+ elasticsearch:
77
+ build:
78
+ context: .
79
+ dockerfile: ./config/docker/elasticsearch/Dockerfile
80
+ ports:
81
+ - "9200:9200"
82
+ - "8080:8080"
83
+ environment:
84
+ # LOGSPOUT: 'ignore'
85
+ # ES_JAVA_OPTS: '-Xms1024m -Xmx1024m'
86
+ # bootstrap.memory_lock: 'false'
87
+ discovery.type: 'single-node'
88
+ # ulimits:
89
+ # memlock:
90
+ # soft: -1
91
+ # hard: -1
92
+ # nofile:
93
+ # soft: 262144
94
+ # hard: 262144
95
+ volumes:
96
+ - es_data:/usr/share/elasticsearch/data
97
+ healthcheck:
98
+ test: ["CMD", "curl", "-SsfL", "127.0.0.1:9200/_cat/health?h=status"]
99
+ interval: 10s
100
+ timeout: 1s
101
+ retries: 10
102
+ <% end %>
103
+
104
+ <% if @headless_chrome %>
105
+ chrome:
106
+ logging:
107
+ driver: none
108
+ ports:
109
+ - 5900:5900
110
+ build:
111
+ context: .
112
+ shm_size: 2g
113
+ dockerfile: ./config/docker/chrome/Dockerfile
114
+ <% end %>
115
+ volumes:
116
+ bundle:
117
+ node_modules:
118
+ rails_cache:
119
+ packs:
120
+ db_data:
121
+ irb_history:
122
+ <% if @elasticsearch %>es_data:<% end %>
@@ -0,0 +1 @@
1
+ FROM docker.elastic.co/elasticsearch/elasticsearch:<%= @elasticsearch_version %>
@@ -0,0 +1,2 @@
1
+ FROM selenium/standalone-chrome
2
+ LABEL maintainer='ed@error.agency'
@@ -0,0 +1,31 @@
1
+ FROM ruby:<%= @ruby_version %>
2
+ LABEL maintainer="paul@error.agency"
3
+
4
+ # Install curl for fetching other apt repos
5
+ RUN apt-get update -yqq && apt-get install -yqq --no-install-recommends apt-transport-https nano gpg
6
+
7
+ # Add NodeJS repo
8
+ RUN curl -sL https://deb.nodesource.com/setup_8.x | bash -
9
+
10
+ # Add Yarn repo
11
+ RUN curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add -
12
+ RUN echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list
13
+
14
+ RUN apt-get update -yqq && apt-get install -yqq --no-install-recommends nodejs yarn
15
+
16
+ RUN gem update --system && gem install bundler -v '2'
17
+
18
+ # Configure bundler and PATH
19
+ ENV LANG=C.UTF-8 \
20
+ GEM_HOME=/bundle \
21
+ BUNDLE_JOBS=4 \
22
+ BUNDLE_RETRY=3
23
+ ENV BUNDLE_PATH $GEM_HOME
24
+ ENV BUNDLE_APP_CONFIG=$BUNDLE_PATH \
25
+ BUNDLE_BIN=$BUNDLE_PATH/bin
26
+ ENV PATH /app/bin:$BUNDLE_BIN:$PATH
27
+
28
+ RUN mkdir -p /app
29
+
30
+ ENTRYPOINT ["/app/config/docker/web/entrypoint.sh"]
31
+ WORKDIR /app
@@ -0,0 +1,5 @@
1
+ #!/bin/bash
2
+
3
+ set -e
4
+ rm -f /app/tmp/pids/server.pid
5
+ exec "$@"
metadata ADDED
@@ -0,0 +1,114 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: error_agency-docker
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Ed Jones
8
+ - Paul Hendrick
9
+ - Sean Hawkridge
10
+ autorequire:
11
+ bindir: exe
12
+ cert_chain: []
13
+ date: 2019-10-26 00:00:00.000000000 Z
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: bundler
17
+ requirement: !ruby/object:Gem::Requirement
18
+ requirements:
19
+ - - "~>"
20
+ - !ruby/object:Gem::Version
21
+ version: '2.0'
22
+ type: :development
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ requirements:
26
+ - - "~>"
27
+ - !ruby/object:Gem::Version
28
+ version: '2.0'
29
+ - !ruby/object:Gem::Dependency
30
+ name: rake
31
+ requirement: !ruby/object:Gem::Requirement
32
+ requirements:
33
+ - - "~>"
34
+ - !ruby/object:Gem::Version
35
+ version: '10.0'
36
+ type: :development
37
+ prerelease: false
38
+ version_requirements: !ruby/object:Gem::Requirement
39
+ requirements:
40
+ - - "~>"
41
+ - !ruby/object:Gem::Version
42
+ version: '10.0'
43
+ - !ruby/object:Gem::Dependency
44
+ name: rails
45
+ requirement: !ruby/object:Gem::Requirement
46
+ requirements:
47
+ - - ">="
48
+ - !ruby/object:Gem::Version
49
+ version: '5'
50
+ - - "<="
51
+ - !ruby/object:Gem::Version
52
+ version: '7'
53
+ type: :runtime
54
+ prerelease: false
55
+ version_requirements: !ruby/object:Gem::Requirement
56
+ requirements:
57
+ - - ">="
58
+ - !ruby/object:Gem::Version
59
+ version: '5'
60
+ - - "<="
61
+ - !ruby/object:Gem::Version
62
+ version: '7'
63
+ description:
64
+ email:
65
+ - ed@error.agency
66
+ - paul@error.agency
67
+ - sean@error.agency
68
+ executables: []
69
+ extensions: []
70
+ extra_rdoc_files: []
71
+ files:
72
+ - ".gitignore"
73
+ - Gemfile
74
+ - LICENSE.txt
75
+ - README.md
76
+ - Rakefile
77
+ - bin/console
78
+ - bin/setup
79
+ - error_agency-docker.gemspec
80
+ - lib/error_agency/docker.rb
81
+ - lib/error_agency/docker/version.rb
82
+ - lib/generators/error_agency/docker/development_environment_generator.rb
83
+ - lib/generators/error_agency/docker/templates/docker_compose.yml.erb
84
+ - lib/generators/error_agency/docker/templates/elasticsearch/Dockerfile.erb
85
+ - lib/generators/error_agency/docker/templates/headless_chrome/Dockerfile.erb
86
+ - lib/generators/error_agency/docker/templates/rails_base/Dockerfile.erb
87
+ - lib/generators/error_agency/docker/templates/rails_base/entrypoint.sh.erb
88
+ homepage: https://github.com/errorstudio/error_agency-docker
89
+ licenses:
90
+ - MIT
91
+ metadata:
92
+ homepage_uri: https://github.com/errorstudio/error_agency-docker
93
+ source_code_uri: https://github.com/errorstudio/error_agency-docker.git
94
+ post_install_message:
95
+ rdoc_options: []
96
+ require_paths:
97
+ - lib
98
+ required_ruby_version: !ruby/object:Gem::Requirement
99
+ requirements:
100
+ - - ">="
101
+ - !ruby/object:Gem::Version
102
+ version: '0'
103
+ required_rubygems_version: !ruby/object:Gem::Requirement
104
+ requirements:
105
+ - - ">="
106
+ - !ruby/object:Gem::Version
107
+ version: '0'
108
+ requirements: []
109
+ rubyforge_project:
110
+ rubygems_version: 2.7.7
111
+ signing_key:
112
+ specification_version: 4
113
+ summary: A Rails generator for docker configurations
114
+ test_files: []