docker_dir_env 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: bcbc31c4bcc5eab6ea54edbb29d980063c53d8dcb8152d21ebd0e39b3e3527f0
4
+ data.tar.gz: d083b3d418396a5c9e5d403360e7d30de00b63f7ba27e7b218099d61c6008b5b
5
+ SHA512:
6
+ metadata.gz: 4b5dc38c2a1a8b2cb46251de251f3efa6958a1e28524caacef7dcb3586cd448b016dcbdd464f36c87acc3e8573208ab94ef73e5b6333fe21ab3d7df1dd21f7cc
7
+ data.tar.gz: 1ab1b97d1091347ecfc8165ee7888096d12b4204aa43ebf6d8bb05ab9a923b7ebc2089ed63a843f4cf7c0fd6a3d519f11598b3dc9b6ce21a8c7a312d87f940dc
data/.gitignore ADDED
@@ -0,0 +1,11 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+
10
+ # rspec failure tracking
11
+ .rspec_status
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ ruby-2.7.2
data/.travis.yml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ sudo: false
3
+ language: ruby
4
+ cache: bundler
5
+ rvm:
6
+ - 2.6.5
7
+ before_install: gem install bundler -v 1.17.3
data/CHANGELOG.md ADDED
File without changes
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ source "https://rubygems.org"
2
+
3
+ git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
4
+
5
+ # Specify your gem's dependencies in docker_dir_env.gemspec
6
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,161 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ docker_dir_env (0.1.0)
5
+
6
+ GEM
7
+ remote: https://rubygems.org/
8
+ specs:
9
+ actioncable (6.1.3)
10
+ actionpack (= 6.1.3)
11
+ activesupport (= 6.1.3)
12
+ nio4r (~> 2.0)
13
+ websocket-driver (>= 0.6.1)
14
+ actionmailbox (6.1.3)
15
+ actionpack (= 6.1.3)
16
+ activejob (= 6.1.3)
17
+ activerecord (= 6.1.3)
18
+ activestorage (= 6.1.3)
19
+ activesupport (= 6.1.3)
20
+ mail (>= 2.7.1)
21
+ actionmailer (6.1.3)
22
+ actionpack (= 6.1.3)
23
+ actionview (= 6.1.3)
24
+ activejob (= 6.1.3)
25
+ activesupport (= 6.1.3)
26
+ mail (~> 2.5, >= 2.5.4)
27
+ rails-dom-testing (~> 2.0)
28
+ actionpack (6.1.3)
29
+ actionview (= 6.1.3)
30
+ activesupport (= 6.1.3)
31
+ rack (~> 2.0, >= 2.0.9)
32
+ rack-test (>= 0.6.3)
33
+ rails-dom-testing (~> 2.0)
34
+ rails-html-sanitizer (~> 1.0, >= 1.2.0)
35
+ actiontext (6.1.3)
36
+ actionpack (= 6.1.3)
37
+ activerecord (= 6.1.3)
38
+ activestorage (= 6.1.3)
39
+ activesupport (= 6.1.3)
40
+ nokogiri (>= 1.8.5)
41
+ actionview (6.1.3)
42
+ activesupport (= 6.1.3)
43
+ builder (~> 3.1)
44
+ erubi (~> 1.4)
45
+ rails-dom-testing (~> 2.0)
46
+ rails-html-sanitizer (~> 1.1, >= 1.2.0)
47
+ activejob (6.1.3)
48
+ activesupport (= 6.1.3)
49
+ globalid (>= 0.3.6)
50
+ activemodel (6.1.3)
51
+ activesupport (= 6.1.3)
52
+ activerecord (6.1.3)
53
+ activemodel (= 6.1.3)
54
+ activesupport (= 6.1.3)
55
+ activestorage (6.1.3)
56
+ actionpack (= 6.1.3)
57
+ activejob (= 6.1.3)
58
+ activerecord (= 6.1.3)
59
+ activesupport (= 6.1.3)
60
+ marcel (~> 0.3.1)
61
+ mimemagic (~> 0.3.2)
62
+ activesupport (6.1.3)
63
+ concurrent-ruby (~> 1.0, >= 1.0.2)
64
+ i18n (>= 1.6, < 2)
65
+ minitest (>= 5.1)
66
+ tzinfo (~> 2.0)
67
+ zeitwerk (~> 2.3)
68
+ builder (3.2.4)
69
+ concurrent-ruby (1.1.8)
70
+ crass (1.0.6)
71
+ diff-lcs (1.4.4)
72
+ erubi (1.10.0)
73
+ globalid (0.4.2)
74
+ activesupport (>= 4.2.0)
75
+ i18n (1.8.9)
76
+ concurrent-ruby (~> 1.0)
77
+ loofah (2.9.0)
78
+ crass (~> 1.0.2)
79
+ nokogiri (>= 1.5.9)
80
+ mail (2.7.1)
81
+ mini_mime (>= 0.1.1)
82
+ marcel (0.3.3)
83
+ mimemagic (~> 0.3.2)
84
+ method_source (1.0.0)
85
+ mimemagic (0.3.5)
86
+ mini_mime (1.0.2)
87
+ minitest (5.14.4)
88
+ nio4r (2.5.7)
89
+ nokogiri (1.11.2-x86_64-darwin)
90
+ racc (~> 1.4)
91
+ racc (1.5.2)
92
+ rack (2.2.3)
93
+ rack-test (1.1.0)
94
+ rack (>= 1.0, < 3)
95
+ rails (6.1.3)
96
+ actioncable (= 6.1.3)
97
+ actionmailbox (= 6.1.3)
98
+ actionmailer (= 6.1.3)
99
+ actionpack (= 6.1.3)
100
+ actiontext (= 6.1.3)
101
+ actionview (= 6.1.3)
102
+ activejob (= 6.1.3)
103
+ activemodel (= 6.1.3)
104
+ activerecord (= 6.1.3)
105
+ activestorage (= 6.1.3)
106
+ activesupport (= 6.1.3)
107
+ bundler (>= 1.15.0)
108
+ railties (= 6.1.3)
109
+ sprockets-rails (>= 2.0.0)
110
+ rails-dom-testing (2.0.3)
111
+ activesupport (>= 4.2.0)
112
+ nokogiri (>= 1.6)
113
+ rails-html-sanitizer (1.3.0)
114
+ loofah (~> 2.3)
115
+ railties (6.1.3)
116
+ actionpack (= 6.1.3)
117
+ activesupport (= 6.1.3)
118
+ method_source
119
+ rake (>= 0.8.7)
120
+ thor (~> 1.0)
121
+ rake (10.5.0)
122
+ rspec (3.10.0)
123
+ rspec-core (~> 3.10.0)
124
+ rspec-expectations (~> 3.10.0)
125
+ rspec-mocks (~> 3.10.0)
126
+ rspec-core (3.10.1)
127
+ rspec-support (~> 3.10.0)
128
+ rspec-expectations (3.10.1)
129
+ diff-lcs (>= 1.2.0, < 2.0)
130
+ rspec-support (~> 3.10.0)
131
+ rspec-mocks (3.10.2)
132
+ diff-lcs (>= 1.2.0, < 2.0)
133
+ rspec-support (~> 3.10.0)
134
+ rspec-support (3.10.2)
135
+ sprockets (4.0.2)
136
+ concurrent-ruby (~> 1.0)
137
+ rack (> 1, < 3)
138
+ sprockets-rails (3.2.2)
139
+ actionpack (>= 4.0)
140
+ activesupport (>= 4.0)
141
+ sprockets (>= 3.0.0)
142
+ thor (1.1.0)
143
+ tzinfo (2.0.4)
144
+ concurrent-ruby (~> 1.0)
145
+ websocket-driver (0.7.3)
146
+ websocket-extensions (>= 0.1.0)
147
+ websocket-extensions (0.1.5)
148
+ zeitwerk (2.4.2)
149
+
150
+ PLATFORMS
151
+ x86_64-darwin-19
152
+
153
+ DEPENDENCIES
154
+ bundler (~> 2.2)
155
+ docker_dir_env!
156
+ rails (~> 6.0)
157
+ rake (~> 10.0)
158
+ rspec (~> 3.0)
159
+
160
+ BUNDLED WITH
161
+ 2.2.1
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2021 Benjamin Deutscher
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.
data/README.md ADDED
@@ -0,0 +1,47 @@
1
+ # DockerDirEnv
2
+
3
+ Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/docker_dir_env`. To experiment with that code, run `bin/console` for an interactive prompt.
4
+
5
+ TODO: Delete this and the text above, and describe your gem
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ ```ruby
12
+ gem 'docker_dir_env'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install docker_dir_env
22
+
23
+ ## Usage
24
+
25
+ Run the installer:
26
+ ```
27
+ rails g docker_dir_env:install
28
+ ```
29
+
30
+ Provide credentials (`EDITOR=vim rails credentials:edit`) with the following structure:
31
+ ```
32
+ database:
33
+ username: YOUR_USERNAME
34
+ password: YOUR_PASSWORD
35
+ ```
36
+
37
+ ## Development
38
+
39
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
40
+
41
+ ## Contributing
42
+
43
+ Bug reports and pull requests are welcome on GitHub at https://github.com/BedeDD/docker_dir_env.
44
+
45
+ ## License
46
+
47
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
data/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "docker_dir_env"
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__)
data/bin/setup ADDED
@@ -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,41 @@
1
+
2
+ lib = File.expand_path("../lib", __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require "docker_dir_env/version"
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "docker_dir_env"
8
+ spec.version = DockerDirEnv::VERSION
9
+ spec.authors = ["Benjamin Deutscher"]
10
+ spec.email = ["ben@bdeutscher.org"]
11
+
12
+ spec.summary = %q{This gem brings a setup of docker management script, a database.yml and .envrc file.}
13
+ spec.description = %q{I am using docker containers for development of a rails app as well as the environmental credentials. I figured that I'm adding the same three files to all of my projects. Since I have a bunch of existing projects a custom template is not an option. So I went with a gem and a generator instead. }
14
+ spec.homepage = "https://github.com/BedeDD/DockerDirEnv.git"
15
+ spec.license = "MIT"
16
+
17
+ # Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
18
+ # to allow pushing to a single host or delete this section to allow pushing to any host.
19
+ if spec.respond_to?(:metadata)
20
+ spec.metadata["homepage_uri"] = spec.homepage
21
+ spec.metadata["source_code_uri"] = "https://github.com/BedeDD/DockerDirEnv.git"
22
+ spec.metadata["changelog_uri"] = "https://github.com/BedeDD/DockerDirEnv/blob/main/CHANGELOG.md"
23
+ else
24
+ raise "RubyGems 2.0 or newer is required to protect against " \
25
+ "public gem pushes."
26
+ end
27
+
28
+ # Specify which files should be added to the gem when it is released.
29
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
30
+ spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
31
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
32
+ end
33
+ spec.bindir = "exe"
34
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
35
+ spec.require_paths = ["lib"]
36
+
37
+ spec.add_development_dependency "bundler", "~> 2.2"
38
+ spec.add_development_dependency "rake", "~> 10.0"
39
+ spec.add_development_dependency "rspec", "~> 3.0"
40
+ spec.add_development_dependency "rails", "~> 6.0"
41
+ end
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'docker_dir_env'
@@ -0,0 +1,6 @@
1
+ require "docker_dir_env/version"
2
+
3
+ module DockerDirEnv
4
+ class Error < StandardError; end
5
+ # Your code goes here...
6
+ end
@@ -0,0 +1,3 @@
1
+ module DockerDirEnv
2
+ VERSION = "0.1.0"
3
+ end
@@ -0,0 +1,57 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'rails/generators/base'
4
+ require 'erb'
5
+
6
+ module DockerDirEnv
7
+ module Generators
8
+ class InstallGenerator < Rails::Generators::Base
9
+ source_root File.expand_path('templates', __dir__)
10
+
11
+ desc 'Copies .envrc, docker-db-setup.sh and a new database.yml to the project'
12
+ public_task :install
13
+
14
+ # Installs the required files in the application
15
+ def install
16
+ copy_envrc
17
+ copy_database_yml
18
+ copy_docker_db_setup_sh
19
+ system(`direnv allow`)
20
+ print("#{readme}\n")
21
+ end
22
+
23
+ private
24
+
25
+ def copy_envrc
26
+ @app_name = Rails.application.class.name&.deconstantize&.underscore
27
+ template('.envrc', '.envrc')
28
+ end
29
+
30
+ def copy_database_yml
31
+ template('config/database.yml', 'config/database.yml')
32
+ end
33
+
34
+ def copy_docker_db_setup_sh
35
+ FileUtils.mkdir_p('lib/scripts')
36
+ copy_file('lib/scripts/docker-db-setup.sh', 'lib/scripts/docker-db-setup.sh')
37
+ system(`chmod +x lib/scripts/docker-db-setup.sh`)
38
+ end
39
+
40
+ def readme
41
+ <<~README
42
+ Thanks for using docker_dir_env!
43
+ Make sure to provide the databases credentials by configuring them with
44
+ `EDITOR=vim rails credentials:edit` OR
45
+ `EDITOR=vim rails credentials:edit -e development` (and the other envs)
46
+
47
+ Your can use your favourite editor instead of vim.
48
+
49
+ Provide the following structure inside the credentials:
50
+ database:
51
+ username: YOUR_USERNAME
52
+ password: YOUR_PASSWORD
53
+ README
54
+ end
55
+ end
56
+ end
57
+ end
@@ -0,0 +1,9 @@
1
+ # .envrc
2
+
3
+ # install https://direnv.net/ first!
4
+
5
+ export APP_NAME=<%= @app_name %>
6
+ export DOCKER_DB_HOST='127.0.0.1'
7
+ export develop_container_name="${APP_NAME}-dev-db"
8
+ export test_container_name="${APP_NAME}-test-db"
9
+ export PORT=80
@@ -0,0 +1,33 @@
1
+ # config/database.yml
2
+ ---
3
+ default: &default
4
+ adapter: mysql2
5
+ encoding: utf8mb4
6
+ pool: 5
7
+ username: <%%= Rails.application.credentials.database[:username] %>
8
+ password: <%%= Rails.application.credentials.database[:password] %>
9
+ host: <%%= ENV.fetch('DOCKER_DB_HOST', 'localhost') %>
10
+ port: <%%= ENV.fetch('DOCKER_DEV_DB_PORT', 3306) %>
11
+
12
+ development:
13
+ <<: *default
14
+ database: <%= @app_name %>_development
15
+ port: <%%= ENV.fetch('DOCKER_DEV_DB_PORT', 3306) %>
16
+
17
+ # Warning: The database defined as "test" will be erased and
18
+ # re-generated from your development database when you run "rake".
19
+ # Do not set this db to the same as development or production.
20
+ test:
21
+ <<: *default
22
+ database: <%= @app_name %>_test
23
+ port: <%%= ENV.fetch('DOCKER_TEST_DB_PORT', 3306) %>
24
+
25
+ production:
26
+ adapter: mysql2
27
+ encoding: utf8
28
+ pool: 5
29
+ database: <%= @app_name %>_production
30
+ username: <%%= Rails.application.credentials.database[:username] %>
31
+ password: <%%= Rails.application.credentials.database[:password] %>
32
+ host: localhost
33
+ port: 3306
@@ -0,0 +1,105 @@
1
+ #!/bin/bash -l
2
+
3
+ # lib/scripts/docker-db-setup.sh
4
+
5
+ # use from Rails.root with: ./lib/scripts/docker-db-setup.sh
6
+
7
+ set -e
8
+
9
+ # colors for output
10
+ txRed='\033[0;31m'
11
+ txRedBold='\033[1;31m'
12
+ txGreen='\033[0;32m'
13
+ txGreenBold='\033[1;32m'
14
+ txYellow='\33[0;33m'
15
+ txYellowBold='\33[1;33m'
16
+ txBlue='\33[0;34m'
17
+ txBlueBold='\33[1;34m'
18
+ txReset='\033[0m'
19
+
20
+ function info() {
21
+ local msg="$*"
22
+ printf "${txBlueBold}[INFO]${txBlue} ${msg}${txReset} \n"
23
+ }
24
+ function success() {
25
+ local msg="$*"
26
+ printf "${txGreenBold}[SUCCESS]${txGreen} ${msg}${txReset} \n"
27
+ }
28
+ function error() {
29
+ local msg="$*"
30
+ printf "${txRedBold}[ERROR]${txRed} ${msg}${txReset} \n"
31
+ }
32
+
33
+ # general env vars are loaded via direnv: https://github.com/direnv/direnv
34
+
35
+ dev_db_name="${APP_NAME}_development"
36
+ dev_user="${APP_NAME}_development"
37
+ dev_pass=$(rails runner -e development "puts Rails.application.credentials.database[:password]")
38
+ test_db_name="${APP_NAME}_test"
39
+ test_user="${APP_NAME}_test"
40
+ test_pass=$(rails runner -e test "puts Rails.application.credentials.database[:password]")
41
+
42
+ info "checking for existing containers"
43
+ if [[ "$(docker container ls -a | grep -c "$develop_container_name")" == "1" ]];
44
+ then
45
+ info "removing old container: $develop_container_name"
46
+ docker container rm -f $develop_container_name
47
+ fi
48
+
49
+ if [[ "$(docker container ls -a | grep -c "$test_container_name")" == "1" ]];
50
+ then
51
+ info "removing old container: $test_container_name"
52
+ docker container rm -f $test_container_name
53
+ fi
54
+
55
+ info "cleaning volumes"
56
+ docker volume prune -f
57
+
58
+ info "starting new container $develop_container_name with database $dev_db_name"
59
+ docker container run -d -e MYSQL_ROOT_PASSWORD="$dev_pass" \
60
+ -e MYSQL_USER="$dev_user" -e MYSQL_PASSWORD="$dev_pass" -e MYSQL_DATABASE=${dev_db_name} \
61
+ --restart unless-stopped \
62
+ --name $develop_container_name -P mariadb:10.4 --character-set-server=utf8mb4 --collation-server=utf8mb4_unicode_ci
63
+
64
+ DOCKER_DEV_DB_PORT=$(docker inspect --format="{{(index (index .NetworkSettings.Ports \"3306/tcp\") 0).HostPort}}" ${develop_container_name})
65
+
66
+ info "starting new container $test_container_name with database $test_db_name"
67
+ docker container run -d -e MYSQL_ROOT_PASSWORD="$test_pass" \
68
+ -e MYSQL_USER="$test_user" -e MYSQL_PASSWORD="$test_pass" -e MYSQL_DATABASE=${test_db_name} \
69
+ --restart unless-stopped \
70
+ --name $test_container_name -P mariadb:10.4 --character-set-server=utf8mb4 --collation-server=utf8mb4_unicode_ci
71
+
72
+ DOCKER_TEST_DB_PORT=$(docker inspect --format="{{(index (index .NetworkSettings.Ports \"3306/tcp\") 0).HostPort}}" ${test_container_name})
73
+
74
+ info "dev port > $DOCKER_DEV_DB_PORT"
75
+ info "test port > $DOCKER_TEST_DB_PORT"
76
+ info "waiting 60s for containers to start"
77
+ sleep 60
78
+
79
+
80
+ rm -f db/schema.rb
81
+
82
+ # we need to hand in both ports since the env vars are not exported and loaded yet
83
+ DOCKER_DEV_DB_PORT=$DOCKER_DEV_DB_PORT DOCKER_TEST_DB_PORT=$DOCKER_TEST_DB_PORT rails db:migrate
84
+ DOCKER_DEV_DB_PORT=$DOCKER_DEV_DB_PORT DOCKER_TEST_DB_PORT=$DOCKER_TEST_DB_PORT RAILS_ENV=test rails db:migrate
85
+ DOCKER_DEV_DB_PORT=$DOCKER_DEV_DB_PORT DOCKER_TEST_DB_PORT=$DOCKER_TEST_DB_PORT rails db:seed
86
+
87
+ # remove old port definitions from .envrc based on the OS
88
+ if [[ "$OSTYPE" == "linux-gnu"* ]]; then
89
+ # Linux
90
+ sed -i '/DOCKER_DEV_DB_PORT/d' .envrc
91
+ sed -i '/DOCKER_TEST_DB_PORT/d' .envrc
92
+ elif [[ "$OSTYPE" == "darwin"* ]]; then
93
+ # Mac OSX
94
+ sed -i '' '/DOCKER_DEV_DB_PORT/d' .envrc
95
+ sed -i '' '/DOCKER_TEST_DB_PORT/d' .envrc
96
+ else
97
+ error "cannot run sed - cannot determine OSTYPE"
98
+ fi
99
+
100
+ # setting port numbers and allow the changed .envrc to be loaded
101
+ echo "export DOCKER_DEV_DB_PORT=${DOCKER_DEV_DB_PORT}" >> .envrc
102
+ echo "export DOCKER_TEST_DB_PORT=${DOCKER_TEST_DB_PORT}" >> .envrc
103
+ direnv allow
104
+
105
+ success "DONE! Happy coding!"
metadata ADDED
@@ -0,0 +1,127 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: docker_dir_env
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Benjamin Deutscher
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2021-03-27 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '2.2'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '2.2'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '3.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '3.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rails
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '6.0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '6.0'
69
+ description: 'I am using docker containers for development of a rails app as well
70
+ as the environmental credentials. I figured that I''m adding the same three files
71
+ to all of my projects. Since I have a bunch of existing projects a custom template
72
+ is not an option. So I went with a gem and a generator instead. '
73
+ email:
74
+ - ben@bdeutscher.org
75
+ executables:
76
+ - docker_dir_env.rb
77
+ extensions: []
78
+ extra_rdoc_files: []
79
+ files:
80
+ - ".gitignore"
81
+ - ".rspec"
82
+ - ".ruby-version"
83
+ - ".travis.yml"
84
+ - CHANGELOG.md
85
+ - Gemfile
86
+ - Gemfile.lock
87
+ - LICENSE.txt
88
+ - README.md
89
+ - Rakefile
90
+ - bin/console
91
+ - bin/setup
92
+ - docker_dir_env.gemspec
93
+ - exe/docker_dir_env.rb
94
+ - lib/docker_dir_env.rb
95
+ - lib/docker_dir_env/version.rb
96
+ - lib/generators/docker_dir_env/install_generator.rb
97
+ - lib/generators/docker_dir_env/templates/.envrc
98
+ - lib/generators/docker_dir_env/templates/config/database.yml
99
+ - lib/generators/docker_dir_env/templates/lib/scripts/docker-db-setup.sh
100
+ homepage: https://github.com/BedeDD/DockerDirEnv.git
101
+ licenses:
102
+ - MIT
103
+ metadata:
104
+ homepage_uri: https://github.com/BedeDD/DockerDirEnv.git
105
+ source_code_uri: https://github.com/BedeDD/DockerDirEnv.git
106
+ changelog_uri: https://github.com/BedeDD/DockerDirEnv/blob/main/CHANGELOG.md
107
+ post_install_message:
108
+ rdoc_options: []
109
+ require_paths:
110
+ - lib
111
+ required_ruby_version: !ruby/object:Gem::Requirement
112
+ requirements:
113
+ - - ">="
114
+ - !ruby/object:Gem::Version
115
+ version: '0'
116
+ required_rubygems_version: !ruby/object:Gem::Requirement
117
+ requirements:
118
+ - - ">="
119
+ - !ruby/object:Gem::Version
120
+ version: '0'
121
+ requirements: []
122
+ rubygems_version: 3.1.4
123
+ signing_key:
124
+ specification_version: 4
125
+ summary: This gem brings a setup of docker management script, a database.yml and .envrc
126
+ file.
127
+ test_files: []