dockerize-stack 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 6fe3c267866bf6ef154ed068f13122eac6c8d1a3
4
+ data.tar.gz: 49a3e2a970cfb3536e8d5753f7a60d29aaf1b742
5
+ SHA512:
6
+ metadata.gz: d9161a682f081a93f3c83506952aead0fd1db2104ccb599659c1796b188cec223ea451ab2c65a0db32a60a7ee454917d4791772df21b5ddb93501aa022a6c312
7
+ data.tar.gz: 46e895bbb3787b1ce50d227e6668feecb9b31252361f49bc2e64f9f9c3fbe1c921211991e88f0a6f83d56bc49578b6c1689def235f955b40f323aa5e5822e607
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2018 Miguel Savignano
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 all
13
+ 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 THE
21
+ SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,47 @@
1
+ # Dockerize Stack for development
2
+
3
+ This it's a generator for generate Dockerfile and docker-compose for your application in development
4
+
5
+ ## Why?
6
+ For build a quick stack for your development enviroment docker is the best tool you can use, but you need to configure the Dockerfile docker-compose, persisted database data, set the entrypoint...
7
+
8
+ This generator help you to have a basic template for your stack; focusing on develepment enviroment.
9
+
10
+ ## Install
11
+ ```
12
+ gem install dockerize-stack
13
+ ```
14
+
15
+ ## Stacks available
16
+
17
+ - [x] Rails 5.1 (Ruby)
18
+ - [ ] Symfony (PHP)
19
+ - [ ] Phoenixframework (Elixir)
20
+ - [ ] Django (Python)
21
+ - [ ] Express (Node)
22
+
23
+ ## Usage
24
+ ```sh
25
+ dockerize_stack rails
26
+ ```
27
+
28
+ This script ask you:
29
+ - Ruby version
30
+ - Database type
31
+
32
+ example files generate:
33
+ ```
34
+ /docker
35
+ --development
36
+ ----Dockerfile
37
+ ----entrypoint.sh
38
+ /.dockerignore
39
+ /docker-compose.yml
40
+ /config/database_docker.yml
41
+ ```
42
+
43
+ ## TODO
44
+ - [ ] Add phoenix generator
45
+ - [ ] Solve use rails generator in container
46
+ - [ ] Add integrations with all database types rails new supported ([mysql/postgresql/sqlite3/oracle/frontbase/ibm_db/sqlserver/jdbcmysql/jdbcsqlite3/jdbcpostgresql/jdbc])
47
+ - [ ] Integrate Build with private repository in the generator
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env ruby
2
+ require 'dockerize-stack'
3
+
4
+ DockerizeStack::Command.start
@@ -0,0 +1,13 @@
1
+ require 'thor'
2
+ require 'rails/dockerize_rails'
3
+
4
+ module DockerizeStack
5
+ class Command < Thor
6
+ include Thor::Actions
7
+
8
+ desc 'rails', 'generate docker files for rails application'
9
+ def rails
10
+ DockerizeRails.new.generate_files
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,26 @@
1
+ require 'thor'
2
+
3
+ class DockerizeRails < Thor
4
+ include Thor::Actions
5
+ attr_accessor :ruby_version, :database
6
+
7
+ def self.source_root
8
+ File.dirname(__FILE__)
9
+ end
10
+
11
+ desc 'generate_files', 'generate docker files for rails application'
12
+ 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
+
17
+ template "templates/Dockerfile.erb", "docker/development/Dockerfile"
18
+ template "templates/entrypoint.sh", "docker/development/entrypoint.sh"
19
+ template "templates/docker-compose.yml.erb", "docker-compose.yml"
20
+ template "templates/database-docker.yml.erb", "config/database-docker.yml"
21
+ template "templates/dockerignore", ".dockerignore"
22
+ append_to_file '.gitignore', "
23
+ volumes"
24
+ end
25
+
26
+ end
@@ -0,0 +1,41 @@
1
+ FROM ruby:<%= ruby_version %>
2
+
3
+ # install common dev libs
4
+ RUN apt-get update -qq && apt-get install -y \
5
+ build-essential \
6
+ libpq-dev \
7
+ git-all
8
+
9
+ # install editors
10
+ RUN apt-get install -y \
11
+ nano \
12
+ vim
13
+
14
+ # http libs for download
15
+ RUN apt-get install -y \
16
+ curl \
17
+ ca-certificates \
18
+ openssl \
19
+ apt-transport-https \
20
+ gnupg2
21
+
22
+ <% if database == "mysql" %>
23
+ # install mysql
24
+ RUN apt-get install -y mysql-client libmysqlclient-dev
25
+ <% elsif database == "postgresql" %>
26
+ # install postgresql
27
+ RUN apt-get install -y postgresql-client
28
+ <% end %>
29
+
30
+ # install node 8.9.1 LTS
31
+ RUN curl -sL https://deb.nodesource.com/setup_8.x | bin/bash -
32
+ RUN apt-get update && apt-get install -y nodejs
33
+
34
+ # install yarn
35
+ RUN curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add -
36
+ RUN echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list
37
+ RUN apt-get update && apt-get install yarn
38
+
39
+ RUN mkdir /app
40
+ WORKDIR /app
41
+ ADD . /app
@@ -0,0 +1,37 @@
1
+
2
+ <% if database == "postgresql" %>
3
+ # Install the pg driver:
4
+ # gem install pg
5
+
6
+ default: &default
7
+ adapter: postgresql
8
+ pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
9
+ encoding: utf8
10
+ host: db
11
+ username: postgres
12
+ password:
13
+
14
+ <% elsif database == "mysql" %>
15
+ # Install the MySQL driver
16
+ # gem install mysql2
17
+
18
+ default: &default
19
+ adapter: mysql2
20
+ encoding: utf8
21
+ pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
22
+ host: db
23
+ username: root
24
+ password: password
25
+
26
+ <% end %>
27
+ development:
28
+ <<: *default
29
+ database: myapp_development
30
+
31
+ test:
32
+ <<: *default
33
+ database: myapp_test
34
+
35
+ production:
36
+ <<: *default
37
+ database: myapp_production
@@ -0,0 +1,54 @@
1
+ version: '3'
2
+ services:
3
+ web:
4
+ build: ./docker/development
5
+ container_name: web
6
+ stdin_open: true
7
+ tty: true
8
+ command: "bash ./docker/development/entrypoint.sh"
9
+ volumes:
10
+ - .:/app
11
+ - ./volumes/bundle:/usr/local/bundle
12
+ ports:
13
+ - "3000:3000"
14
+ depends_on:
15
+ - db
16
+ # env_file:
17
+ # - web.env
18
+ <% if database == "mysql" %>
19
+ db:
20
+ image: 'mysql:5.7'
21
+ # ports:
22
+ # - "3306:3306"
23
+ environment:
24
+ MYSQL_ROOT_PASSWORD: password
25
+ volumes:
26
+ - ./volumes/mysql:/var/lib/mysql
27
+ <% elsif database == "postgresql" %>
28
+ db:
29
+ image: postgres:9.5.9
30
+ # ports:
31
+ # - "5432:5432"
32
+ volumes:
33
+ - ./volumes/postgresql:/var/lib/postgresql/data
34
+ <% 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
44
+
45
+ # USAGE
46
+
47
+ # execute a container for run rails console or rake tasks
48
+ # docker-compose run web bash
49
+
50
+ # attach the container when use binding.pry
51
+ # docker attach web
52
+
53
+ # when run rails generator you need to run
54
+ # sudo chown -R $USER:$USER $(ls | grep -v volumes)
@@ -0,0 +1 @@
1
+ volumes
@@ -0,0 +1,5 @@
1
+ bundle install
2
+ yarn install
3
+ rake db:create db:migrate
4
+ rm -f tmp/pids/server.pid
5
+ bundle exec rails server -p 3000 -b 0.0.0.0
data/lib/version.rb ADDED
@@ -0,0 +1,3 @@
1
+ module DockerizeStack
2
+ VERSION = "0.0.1"
3
+ end
metadata ADDED
@@ -0,0 +1,69 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: dockerize-stack
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Miguel Savignano
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2018-02-03 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: thor
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ description: Generate Dockerfile and docker-compose for your application
28
+ email: migue.masx@gmail.com
29
+ executables:
30
+ - dockerize-stack
31
+ extensions: []
32
+ extra_rdoc_files: []
33
+ files:
34
+ - LICENSE
35
+ - README.md
36
+ - bin/dockerize-stack
37
+ - lib/dockerize_stack.rb
38
+ - lib/rails/dockerize_rails.rb
39
+ - lib/rails/templates/Dockerfile.erb
40
+ - lib/rails/templates/database-docker.yml.erb
41
+ - lib/rails/templates/docker-compose.yml.erb
42
+ - lib/rails/templates/dockerignore
43
+ - lib/rails/templates/entrypoint.sh
44
+ - lib/version.rb
45
+ homepage: https://github.com/MiguelSavignano/dockerize-stack
46
+ licenses:
47
+ - MIT
48
+ metadata: {}
49
+ post_install_message:
50
+ rdoc_options: []
51
+ require_paths:
52
+ - lib
53
+ required_ruby_version: !ruby/object:Gem::Requirement
54
+ requirements:
55
+ - - ">="
56
+ - !ruby/object:Gem::Version
57
+ version: '0'
58
+ required_rubygems_version: !ruby/object:Gem::Requirement
59
+ requirements:
60
+ - - ">="
61
+ - !ruby/object:Gem::Version
62
+ version: '0'
63
+ requirements: []
64
+ rubyforge_project:
65
+ rubygems_version: 2.6.14
66
+ signing_key:
67
+ specification_version: 4
68
+ summary: DockerizeStack
69
+ test_files: []