dockerize-stack 0.0.4 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 75c7dfcf30a81b58af0f35b38c627a7d7f8e608c
4
- data.tar.gz: 1ad53c9dd8c325b7dfc24d5ed409b888cdffb59f
3
+ metadata.gz: 6b53f448f2fabd4d3ad3ede66b61238759c451ca
4
+ data.tar.gz: 168e2b581af9dda10ddf43363278c3716f0d7324
5
5
  SHA512:
6
- metadata.gz: 5a08c42dacd0d0a78676a31d7e65089e56204875a73edff237991648de05ae7f00db4a41c3f4a6192f09bd174bdfaea103cbbdb18fd334d93b36c8e8a2755533
7
- data.tar.gz: bd0baca3a0f157b38d52fd666de426b10abb7337d48ca85eb1cad2aab350cfd82d46a81d41fed22a0574d1977cba8c87478839226aeff539807391d3c1e9b395
6
+ metadata.gz: f55ae60e397d0e6cb75a6ae72e39d3b33bff951f0130465b3586ad335b3f905189f625c79e639ba47e87795f18449563b1d1f2c47c3c4d765be1b947a5ee9afc
7
+ data.tar.gz: 8c3dd9409b7a85a409c96a283aa3266b56b7c54314a192c5828e5e695f1c8e6c2b3e0c8b7efd496c029a7f5a2e5bcc4f09b1ae5ffd758b76c406240553f2286d
data/README.md CHANGED
@@ -11,6 +11,10 @@ This generator help you to have a basic template for your stack; focusing on dev
11
11
  ```
12
12
  gem install dockerize-stack
13
13
  ```
14
+ or
15
+ ```
16
+ docker pull devmasx/dockerize-stack
17
+ ```
14
18
 
15
19
  ## Stacks available
16
20
 
@@ -24,6 +28,10 @@ gem install dockerize-stack
24
28
  ```sh
25
29
  dockerize-stack rails
26
30
  ```
31
+ or use docker image
32
+ ```
33
+ docker run --user $(id -u) -it -v $(pwd):/usr/src devmasx/dockerize-stack rails
34
+ ```
27
35
 
28
36
  This script ask you:
29
37
  - Ruby version
@@ -1,8 +1,9 @@
1
1
  require 'thor'
2
-
2
+ # Ask variables and render templates
3
3
  class DockerizeRails < Thor
4
4
  include Thor::Actions
5
- attr_accessor :ruby_version, :database
5
+ attr_accessor :ruby_version, :database, :id_rsa
6
+
6
7
 
7
8
  def self.source_root
8
9
  File.dirname(__FILE__)
@@ -10,29 +11,36 @@ class DockerizeRails < Thor
10
11
 
11
12
  desc 'generate_files', 'generate docker files for rails application'
12
13
  def generate_files
13
- @ruby_version = ask("Ruby Version (default 2.4.3):")
14
- @ruby_version = "2.4.3" if @ruby_version == ""
15
- @database = ask("What is your Database?", limited_to: ["mysql", "postgresql"])
16
- @id_rsa = ask("Would you need your id_rsa file to connect with GitHub? Type yes or no (default no):")
17
- @id_rsa = "no" if @id_rsa == ""
14
+ ruby_version = ask('Ruby Version (default 2.5.1):')
15
+ ruby_version = '2.5.1-slim' if ruby_version == ''
16
+ database = ask('What is your Database?', limited_to: ['postgresql', 'mysql'])
17
+ id_rsa = ask('Would you need your id_rsa file to connect with GitHub? Type yes or no (default no):')
18
+ id_rsa = 'no' if id_rsa == ''
19
+ render_templates(ruby_version: ruby_version, database: database, id_rsa: id_rsa)
20
+ end
18
21
 
19
- template "templates/Dockerfile.erb", "docker/development/Dockerfile"
20
- template "templates/entrypoint.sh.erb", "docker/development/entrypoint.sh"
21
- template "templates/docker-compose.yml.erb", "docker-compose.yml"
22
- template "templates/database-docker.yml.erb", "config/database-docker.yml"
23
- template "templates/dockerignore.erb", ".dockerignore"
22
+ no_commands do
23
+ def render_templates(ruby_version: '2.5.1-slim', database: 'postgresql', id_rsa: 'no')
24
+ @ruby_version = ruby_version
25
+ @database = database
26
+ @id_rsa = id_rsa
24
27
 
25
- append_to_file '.gitignore', "
26
- volumes"
27
- if @id_rsa == 'yes'
28
- template "templates/id_rsa.sample", "docker/development/id_rsa.sample"
29
- append_to_file '.gitignore', "
30
- docker/development/id_rsa"
31
- append_to_file '.gitignore', "
32
- docker/development/id_rsa.sample"
28
+ template 'templates/docker/development/Dockerfile.erb', 'docker/development/Dockerfile'
29
+ template 'templates/docker/development/entrypoint.sh.erb', 'docker/development/entrypoint.sh'
30
+ template 'templates/docker-compose.yml.erb', 'docker-compose.yml'
31
+ template 'templates/config/database-docker.yml.erb', 'config/database-docker.yml'
32
+ template 'templates/dockerignore.erb', '.dockerignore'
33
+
34
+ append_to_file '.gitignore', '
35
+ volumes'
36
+ if @id_rsa == 'yes'
37
+ template 'templates/id_rsa.sample', 'id_rsa.sample'
38
+ append_to_file '.gitignore', '
39
+ id_rsa'
40
+ append_to_file '.gitignore', '
41
+ id_rsa.sample'
42
+ end
43
+ puts 'Update your database.yml based in database-docker.yml'
33
44
  end
34
-
35
- puts "Update your database.yml based in database-docker.yml"
36
45
  end
37
-
38
46
  end
@@ -1,3 +1,4 @@
1
+ # Update your database.yml based in database-docker.yml
1
2
 
2
3
  <% if database == "postgresql" %>
3
4
  # Install the pg driver:
@@ -4,7 +4,7 @@ FROM ruby:<%= ruby_version %>
4
4
  RUN apt-get update -qq && apt-get install -y \
5
5
  build-essential \
6
6
  libpq-dev \
7
- git-all
7
+ git
8
8
 
9
9
  # install editors
10
10
  RUN apt-get install -y \
@@ -38,7 +38,7 @@ RUN apt-get update && apt-get install yarn
38
38
 
39
39
  RUN mkdir /app
40
40
  WORKDIR /app
41
- ADD . /app
41
+ COPY . /app
42
42
 
43
43
  <% if @id_rsa == 'yes' %>
44
44
  RUN mkdir /root/.ssh
@@ -47,4 +47,4 @@ RUN cp id_rsa /root/.ssh/id_rsa
47
47
  RUN touch /root/.ssh/known_hosts
48
48
  RUN eval "$(ssh-agent -s)" && ssh-add ~/.ssh/id_rsa && ssh-add -l && ssh-add -L && echo "Host github.com\n\tIdentityFile ~/.ssh/id_rsa" >> /root/.ssh/config
49
49
  RUN ssh-keyscan -t rsa github.com > ~/.ssh/known_hosts
50
- <% end %>
50
+ <% end %>
@@ -0,0 +1,7 @@
1
+ bundle check || bundle install
2
+ yarn install --pure-lockfile
3
+
4
+ rake db:create db:migrate
5
+ rm -f tmp/pids/server.pid
6
+ # rm -rf public/packs/* || true && bin/webpack-dev-server &
7
+ bundle exec rails server -p 3000 -b 0.0.0.0
@@ -1,7 +1,9 @@
1
1
  version: '3'
2
2
  services:
3
3
  web:
4
- build: ./docker/development
4
+ build:
5
+ dockerfile: ./docker/development/Dockerfile
6
+ context: ./
5
7
  container_name: web
6
8
  stdin_open: true
7
9
  tty: true
@@ -32,20 +34,20 @@ services:
32
34
  volumes:
33
35
  - ./volumes/postgresql:/var/lib/postgresql/data
34
36
  <% end %>
35
- redis:
36
- image: redis
37
- # ports:
38
- # - "6379:6379"
39
- mailcatcher:
40
- image: schickling/mailcatcher
41
- ports:
42
- - 1025:1025
43
- - 1080:1080
37
+ # redis:
38
+ # image: redis
39
+ # ports:
40
+ # - "6379:6379"
41
+ # mailcatcher:
42
+ # image: schickling/mailcatcher
43
+ # ports:
44
+ # - 1025:1025
45
+ # - 1080:1080
44
46
 
45
47
  # USAGE
46
48
 
47
49
  # execute a container for run rails console or rake tasks
48
- # docker-compose run web bash
50
+ # docker-compose run --rm web bash
49
51
 
50
52
  # attach the container when use binding.pry
51
53
  # docker attach web
@@ -1 +1,17 @@
1
- volumes
1
+ # Ignore all logfiles and tempfiles.
2
+ /log/*
3
+ /tmp/*
4
+
5
+ .byebug_history
6
+
7
+ volumes
8
+ .git
9
+
10
+ public/packs
11
+ public/packs-test
12
+ public/uploads
13
+
14
+ node_modules
15
+ coverage
16
+ yarn-error.log
17
+ .DS_Store
@@ -1 +1 @@
1
- Replace this file with your id_rsa file
1
+ Replace this file with your id_rsa.pub file
data/lib/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module DockerizeStack
2
- VERSION = "0.0.4"
2
+ VERSION = "0.1.0"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dockerize-stack
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Miguel Savignano
@@ -36,11 +36,11 @@ files:
36
36
  - bin/dockerize-stack
37
37
  - lib/dockerize_stack.rb
38
38
  - lib/rails/dockerize_rails.rb
39
- - lib/rails/templates/Dockerfile.erb
40
- - lib/rails/templates/database-docker.yml.erb
39
+ - lib/rails/templates/config/database-docker.yml.erb
41
40
  - lib/rails/templates/docker-compose.yml.erb
41
+ - lib/rails/templates/docker/development/Dockerfile.erb
42
+ - lib/rails/templates/docker/development/entrypoint.sh.erb
42
43
  - lib/rails/templates/dockerignore.erb
43
- - lib/rails/templates/entrypoint.sh.erb
44
44
  - lib/rails/templates/id_rsa.sample
45
45
  - lib/version.rb
46
46
  homepage: https://github.com/MiguelSavignano/dockerize-stack
@@ -63,7 +63,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
63
63
  version: '0'
64
64
  requirements: []
65
65
  rubyforge_project:
66
- rubygems_version: 2.6.13
66
+ rubygems_version: 2.6.14
67
67
  signing_key:
68
68
  specification_version: 4
69
69
  summary: DockerizeStack
@@ -1,8 +0,0 @@
1
- gem install bundler
2
-
3
- bundle install
4
- yarn install
5
-
6
- rake db:create db:migrate
7
- rm -f tmp/pids/server.pid
8
- bundle exec rails server -p 3000 -b 0.0.0.0