wellcar 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +24 -2
- data/README.markdown +18 -0
- data/bin/wellcar +1 -1
- data/lib/wellcar/templates/env_development_database.erb +1 -1
- data/lib/wellcar/templates/env_development_database.rb +3 -1
- data/lib/wellcar/templates/env_production_database.erb +1 -1
- data/lib/wellcar/templates/env_production_database.rb +3 -1
- data/lib/wellcar/templates/{reverse_proxy.conf.erb → reverse-proxy.conf.erb} +0 -0
- data/lib/wellcar/templates/reverse_proxy_conf.rb +2 -2
- data/lib/wellcar/version.rb +1 -1
- data/spec/wellcar/templates/env_development_database_spec.rb +9 -3
- data/spec/wellcar/templates/env_production_database_spec.rb +9 -3
- data/spec/wellcar/templates/reverse_proxy_conf_spec.rb +0 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d9629130bcd16fffcc9864daedb27e5f5795c660a33f92816a33851dac2bb98c
|
4
|
+
data.tar.gz: d59cc9b695eeaff5af97a498c589b053ab454f6f99583e1a54e913bf19172d7c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e6da3f0f58f3c7ee6788ed5fd30bd767a8ac3c778a59e797bf174f5762db7eef75f742bdb9cd149e8327f66999f2291fefbfc8ddee139a94bc8849d218d2ce04
|
7
|
+
data.tar.gz: f14698f09a94e51c8072f9812b7eef731fb19be0752d03895679b185e6e54a17715acbb1280651fff8273742deb02299495ba80b387999803e4cbf6e4345dde4
|
data/.gitignore
CHANGED
@@ -1,5 +1,27 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
# Swap
|
2
|
+
[._]*.s[a-v][a-z]
|
3
|
+
!*.svg # comment out if you don't need vector files
|
4
|
+
[._]*.sw[a-p]
|
5
|
+
[._]s[a-rt-v][a-z]
|
6
|
+
[._]ss[a-gi-z]
|
7
|
+
[._]sw[a-p]
|
8
|
+
|
9
|
+
# Session
|
10
|
+
Session.vim
|
11
|
+
Sessionx.vim
|
12
|
+
|
13
|
+
# Temporary
|
14
|
+
.netrwhist
|
15
|
+
*~
|
16
|
+
# Auto-generated tag files
|
17
|
+
tags
|
18
|
+
# Persistent undo
|
19
|
+
[._]*.un~
|
20
|
+
# git mergefiles
|
21
|
+
*.orig
|
22
|
+
|
23
|
+
# macos metadata
|
3
24
|
.DS_Store
|
25
|
+
|
4
26
|
pkg
|
5
27
|
tmp
|
data/README.markdown
CHANGED
@@ -15,3 +15,21 @@ I have published the gem to Rubygems.org, purely to make sure that the name `wel
|
|
15
15
|
As such, please mess around or whatever but do not expect any polish, or even anything to work.
|
16
16
|
|
17
17
|
[The DIP gem by @bidendi](https://github.com/bibendi/dip) is an inspiration for my tinkering here. Check it out if you're serious about developing and deploying Rails apps in Docker containers!
|
18
|
+
[Kuby](https://github.com/getkuby/kuby-core) is a tool that automates Docker and Kubernetes for a Rails app. I discovered this via Ruby Weekly literally as I was going through publishing `wellcar`.
|
19
|
+
|
20
|
+
## Approach
|
21
|
+
I've taken a pragmatic, quick-and-dirty approach to building `wellcar`.
|
22
|
+
|
23
|
+
### Templating files for Dockerising
|
24
|
+
Docker files generation rather crudely relies on ERB templating.
|
25
|
+
There are pairs of `.erb` and `.rb` files within `lib/wellcar/templates/` for each of the files that gets generated by `wellcar new` and `wellcar dock`.
|
26
|
+
|
27
|
+
I would prefer to have some sort of AST for the different file types to make the system more flexible.
|
28
|
+
However, I don't know enough about Docker, the files I might need to manage or ASTs to try to tackle that right now.
|
29
|
+
It would be a long-term goal to do this.
|
30
|
+
|
31
|
+
### Running commands
|
32
|
+
Commands are also crudely executed with `system()` calls.
|
33
|
+
This is a clunky approach but has helped me deep-dive into Docker and understand the command hierarchy, particularly between `docker` and `docker-compose`, and the workflow for deploying apps.
|
34
|
+
|
35
|
+
At some stage, it might be possible to interact with the Docker Daemon directly although it's debatable whether this is advantageous or not.
|
data/bin/wellcar
CHANGED
@@ -132,7 +132,7 @@ class NewCommand < CommandBase
|
|
132
132
|
# remove dockerfile.init and docker-compose.yml with initialisation services
|
133
133
|
%w(Dockerfile.init docker-compose.yml config/database.yml).each {|f| File.delete(f) if File.file?(f) }
|
134
134
|
# Create docker-compose.yml file
|
135
|
-
Wellcar::Templates::DockerCompose.new(app_name).write
|
135
|
+
Wellcar::Templates::DockerCompose.new(app_name, github_account).write
|
136
136
|
Wellcar::Templates::DatabaseYaml.new(app_name).write
|
137
137
|
end
|
138
138
|
|
@@ -1,3 +1,4 @@
|
|
1
|
+
require "securerandom"
|
1
2
|
require File.join(File.dirname(__FILE__), "base")
|
2
3
|
|
3
4
|
module Wellcar
|
@@ -5,7 +6,8 @@ module Wellcar
|
|
5
6
|
class EnvDevelopmentDatabase < Base
|
6
7
|
def initialize(app_name)
|
7
8
|
super ".env/development/database"
|
8
|
-
with_attributes app_name: app_name
|
9
|
+
with_attributes app_name: app_name,
|
10
|
+
password: SecureRandom.base64(20)
|
9
11
|
with_template "env_development_database.erb"
|
10
12
|
end
|
11
13
|
end
|
@@ -1,11 +1,13 @@
|
|
1
1
|
require File.join(File.dirname(__FILE__), "base")
|
2
|
+
require "securerandom"
|
2
3
|
|
3
4
|
module Wellcar
|
4
5
|
module Templates
|
5
6
|
class EnvProductionDatabase < Base
|
6
7
|
def initialize(app_name)
|
7
8
|
super ".env/production/database"
|
8
|
-
with_attributes app_name: app_name
|
9
|
+
with_attributes app_name: app_name,
|
10
|
+
password: SecureRandom.base64(20)
|
9
11
|
with_template "env_production_database.erb"
|
10
12
|
end
|
11
13
|
end
|
File without changes
|
@@ -4,9 +4,9 @@ module Wellcar
|
|
4
4
|
module Templates
|
5
5
|
class ReverseProxyConf < Base
|
6
6
|
def initialize(domain_name)
|
7
|
-
super "
|
7
|
+
super "reverse-proxy.conf"
|
8
8
|
with_attributes domain_name: domain_name
|
9
|
-
with_template "
|
9
|
+
with_template "reverse-proxy.conf.erb"
|
10
10
|
within "config/nginx"
|
11
11
|
end
|
12
12
|
end
|
data/lib/wellcar/version.rb
CHANGED
@@ -1,17 +1,23 @@
|
|
1
1
|
require File.join(File.dirname(__FILE__), "..", "..", "spec_helper.rb")
|
2
|
-
require "yaml"
|
3
2
|
require "wellcar/templates/env_development_database"
|
4
3
|
|
5
4
|
RSpec.describe Wellcar::Templates::EnvDevelopmentDatabase do
|
6
5
|
describe "#render" do
|
7
6
|
subject { template.render }
|
7
|
+
|
8
|
+
let(:password) { class_double "SecureRandom" }
|
9
|
+
|
10
|
+
before do
|
11
|
+
stub_const "SecureRandom", password
|
12
|
+
expect(password).to receive(:base64).with(20).and_return "a-password"
|
13
|
+
end
|
8
14
|
|
9
15
|
context "with a first set of inputs" do
|
10
16
|
let(:template) { described_class.new("test_app") }
|
11
17
|
|
12
18
|
it { is_expected.to include("POSTGRES_DB=test_app_development") }
|
13
19
|
it { is_expected.to include("POSTGRES_USER=postgres") }
|
14
|
-
it { is_expected.to include("POSTGRES_PASSWORD=a-
|
20
|
+
it { is_expected.to include("POSTGRES_PASSWORD=a-password") }
|
15
21
|
end
|
16
22
|
|
17
23
|
context "with another set of inputs" do
|
@@ -19,7 +25,7 @@ RSpec.describe Wellcar::Templates::EnvDevelopmentDatabase do
|
|
19
25
|
|
20
26
|
it { is_expected.to include("POSTGRES_DB=old_app_development") }
|
21
27
|
it { is_expected.to include("POSTGRES_USER=postgres") }
|
22
|
-
it { is_expected.to include("POSTGRES_PASSWORD=a-
|
28
|
+
it { is_expected.to include("POSTGRES_PASSWORD=a-password") }
|
23
29
|
end
|
24
30
|
end
|
25
31
|
end
|
@@ -1,17 +1,23 @@
|
|
1
1
|
require File.join(File.dirname(__FILE__), "..", "..", "spec_helper.rb")
|
2
|
-
require "yaml"
|
3
2
|
require "wellcar/templates/env_production_database"
|
4
3
|
|
5
4
|
RSpec.describe Wellcar::Templates::EnvProductionDatabase do
|
6
5
|
describe "#render" do
|
7
6
|
subject { template.render }
|
8
7
|
|
8
|
+
let(:password) { class_double "SecureRandom" }
|
9
|
+
|
10
|
+
before do
|
11
|
+
stub_const "SecureRandom", password
|
12
|
+
expect(password).to receive(:base64).with(20).and_return "prod-password"
|
13
|
+
end
|
14
|
+
|
9
15
|
context "with a first set of inputs" do
|
10
16
|
let(:template) { described_class.new("test_app") }
|
11
17
|
|
12
18
|
it { is_expected.to include("POSTGRES_DB=test_app_production") }
|
13
19
|
it { is_expected.to include("POSTGRES_USER=postgres") }
|
14
|
-
it { is_expected.to include("POSTGRES_PASSWORD=
|
20
|
+
it { is_expected.to include("POSTGRES_PASSWORD=prod-password") }
|
15
21
|
end
|
16
22
|
|
17
23
|
context "with another set of inputs" do
|
@@ -19,7 +25,7 @@ RSpec.describe Wellcar::Templates::EnvProductionDatabase do
|
|
19
25
|
|
20
26
|
it { is_expected.to include("POSTGRES_DB=old_app_production") }
|
21
27
|
it { is_expected.to include("POSTGRES_USER=postgres") }
|
22
|
-
it { is_expected.to include("POSTGRES_PASSWORD=
|
28
|
+
it { is_expected.to include("POSTGRES_PASSWORD=prod-password") }
|
23
29
|
end
|
24
30
|
end
|
25
31
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: wellcar
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- NJ Pearman
|
@@ -111,7 +111,7 @@ files:
|
|
111
111
|
- lib/wellcar/templates/env_production_database.rb
|
112
112
|
- lib/wellcar/templates/env_production_web.erb
|
113
113
|
- lib/wellcar/templates/env_production_web.rb
|
114
|
-
- lib/wellcar/templates/
|
114
|
+
- lib/wellcar/templates/reverse-proxy.conf.erb
|
115
115
|
- lib/wellcar/templates/reverse_proxy_conf.rb
|
116
116
|
- lib/wellcar/version.rb
|
117
117
|
- spec/.keep
|