mina-docker 0.0.1 → 0.0.2

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 027e03c63cbd4dc57775ecd64a5740de9e9ea004add09af3427c00a17a7a8768
4
- data.tar.gz: 24b8519d05fe49daeb1302a18936e9ba4f06e45fd67a642c014a12e0af1219a2
3
+ metadata.gz: fd0b7dac4d0764fbc61913ac4d71a3b311820d6d385b5249e4c38448067a76c6
4
+ data.tar.gz: 3c51f7833cb202ccbec309ec00e4b06c312e072b77c5633efdd0b0eb27895969
5
5
  SHA512:
6
- metadata.gz: e73a09d565a62b453a4cde9caa1ff28857c265a59b4201e9101e9aff1318f59e2d5ad8a3bb226887bd4ecbed434577658e260233bd11bb67cae4ec40317289fe
7
- data.tar.gz: ad79f730dca10b367e5352c57270ec62df15b050e286ff267270ab51f8e480727b7c10de040f8a6403cb38c4f522c034a0bbf005cfbab1d4649a4d3776d78e0f
6
+ metadata.gz: 68e697d9e20a939dfc3ab8ddf8e8d60489218b865ccf554fa0c89c25ccb3883a6bdbe604c9d63b96216f258122680dcb431626a54e99befde6cc8fd336b0737d
7
+ data.tar.gz: bbb17af00f54981d8cd4277c719aea17e72036e8098af031945eb54bccc61e03cf033319432352d192435870fd9272ffb6931531d7a1041f88f3611db19655f2
data/README.md ADDED
@@ -0,0 +1,34 @@
1
+ # Docker support for Mina
2
+
3
+ You can use mina now to deploy docker servers.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'mina-docker', git: "git@github.com:flydrago/mina-docker.git", branch: 'main', require: false
10
+
11
+ ## Usage
12
+
13
+ Load the tasks:
14
+
15
+ ```ruby
16
+ require 'mina/docker'
17
+ ```
18
+
19
+ Config
20
+
21
+ ```ruby
22
+ set :docker_compose_file, 'docker-compose.yml'
23
+ set :docker_image, 'xxxxx'
24
+ set :docker_hub, 'xxxxxx'
25
+ ```
26
+
27
+ Setup it
28
+
29
+ $ bundle exec mina docker_compose:setup
30
+
31
+ Deploy it!
32
+
33
+ $ bundle exec mina docker_compose:deploy
34
+
data/lib/docker.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  module Mina
2
2
  module Docker
3
- VERSION = "0.0.1"
3
+ VERSION = '0.0.2'
4
4
  end
5
5
  end
@@ -0,0 +1,130 @@
1
+ def command_with_comment(code)
2
+ comment code
3
+ command code
4
+ end
5
+
6
+ set :docker_compose_file, 'docker-compose.yml'
7
+ set :docker_image, 'xxxxx'
8
+ set :docker_hub, 'xxxxxx'
9
+
10
+ namespace :docker do
11
+ desc 'docker build image'
12
+ task :build do
13
+ run(:local) do
14
+ command_with_comment %{docker build -t #{fetch(:docker_image)}:#{ENV.fetch('IMAGE_VERSION', 'latest')} -t #{fetch(:docker_image)}:latest ./}
15
+
16
+ command_with_comment %{docker tag #{fetch(:docker_image)}:#{ENV.fetch('IMAGE_VERSION', 'latest')} #{fetch(:docker_hub)}#{fetch(:docker_image)}:#{ENV.fetch('IMAGE_VERSION', 'latest')}}
17
+ end
18
+ end
19
+
20
+ desc 'docker push image'
21
+ task :push do
22
+ run(:local) do
23
+ command_with_comment %{docker push #{fetch(:docker_hub)}#{fetch(:docker_image)}:#{ENV.fetch('IMAGE_VERSION', 'latest')}}
24
+ end
25
+ end
26
+
27
+ desc 'docker push image'
28
+ task :image, [:command] do |t, args|
29
+ command_with_comment %{docker image #{args.command}}
30
+ end
31
+ end
32
+
33
+ namespace :docker_compose do
34
+ desc 'docker_compose pull images'
35
+ task :pull do
36
+ in_path(fetch(:deploy_to)) do
37
+ command_with_comment %{docker-compose --file #{fetch(:docker_compose_file)} pull}
38
+ end
39
+ end
40
+
41
+ desc 'docker_compose up'
42
+ task :up do
43
+ in_path(fetch(:deploy_to)) do
44
+ command_with_comment %{docker-compose --file #{fetch(:docker_compose_file)} up -d}
45
+ end
46
+ end
47
+
48
+ desc 'docker_compose down'
49
+ task :down do
50
+ in_path(fetch(:deploy_to)) do
51
+ command_with_comment %{docker-compose --file #{fetch(:docker_compose_file)} down}
52
+ end
53
+ end
54
+
55
+ desc 'docker_compose restart'
56
+ task :restart do
57
+ in_path(fetch(:deploy_to)) do
58
+ invoke :'docker_compose:down'
59
+ invoke :'docker_compose:up'
60
+ end
61
+ end
62
+
63
+ desc 'docker_compose ps'
64
+ task :ps do
65
+ in_path(fetch(:deploy_to)) do
66
+ command_with_comment %{docker-compose --file #{fetch(:docker_compose_file)} ps}
67
+ end
68
+ end
69
+
70
+ desc 'docker_compose run'
71
+ task :run, [:command] do |t, args|
72
+ in_path(fetch(:deploy_to)) do
73
+ command_with_comment %{docker-compose --file #{fetch(:docker_compose_file)} run --rm -e RAILS_ENV=#{fetch(:rails_env)} app #{args.command}}
74
+ end
75
+ end
76
+
77
+ desc 'docker_compose run with an interactive'
78
+ task :run_with_it, [:command] do |t, args|
79
+ set :execution_mode, :exec
80
+
81
+ in_path(fetch(:deploy_to)) do
82
+ command_with_comment %{docker-compose --file #{fetch(:docker_compose_file)} run --rm -e RAILS_ENV=#{fetch(:rails_env)} app #{args.command}}
83
+ end
84
+ end
85
+
86
+ desc 'docker_compose migrate'
87
+ task :migrate do
88
+ comment "Call migrate"
89
+
90
+ invoke :'docker_compose:run', "bundle exec rake db:migrate"
91
+ end
92
+
93
+ desc 'docker_compose update_menus_and_permissions'
94
+ task :update_menus_and_permissions => :remote_environment do
95
+ comment "Update menus and permissions"
96
+
97
+ invoke :'docker_compose:run', "bundle exec rake roles_and_permissions:update_menus"
98
+ invoke :'docker_compose:run', "bundle exec rake roles_and_permissions:update_permissions"
99
+ end
100
+
101
+ desc 'docker_compose Starts an interactive console.'
102
+ task :console do
103
+ comment "rails console"
104
+
105
+ invoke :'docker_compose:run_with_it', "bundle exec rails c"
106
+ end
107
+
108
+ desc 'docker_compose setup'
109
+ task :setup do
110
+ run(:remote) do
111
+ command_with_comment %(mkdir -p "#{fetch(:deploy_to)}/log/")
112
+ command_with_comment %(mkdir -p "#{fetch(:deploy_to)}/config")
113
+ end
114
+
115
+ run(:local) do
116
+ command_with_comment "scp #{fetch(:docker_compose_file)} #{fetch(:user)}@#{fetch(:domain)}:#{fetch(:deploy_to)}/#{fetch(:docker_compose_file)}"
117
+ end
118
+ end
119
+
120
+ desc "Deploys the current version to the server."
121
+ task :deploy do
122
+ command_with_comment "export IMAGE_VERSION=#{ENV.fetch('IMAGE_VERSION', 'latest')}"
123
+
124
+ invoke :'docker:image', 'prune -f'
125
+ invoke :'docker_compose:pull'
126
+ invoke :'docker_compose:migrate'
127
+ invoke :'docker_compose:update_menus_and_permissions'
128
+ invoke :'docker_compose:up'
129
+ end
130
+ end
@@ -0,0 +1,17 @@
1
+ require './lib/docker.rb'
2
+
3
+ Gem::Specification.new do |s|
4
+ s.name = 'mina-docker'
5
+ s.version = Mina::Docker::VERSION
6
+ s.date = '2020-11-22'
7
+ s.summary = 'add docker support for mina.'
8
+ s.description = 'add docker support for mina.'
9
+ s.authors = ['flydragon']
10
+ s.email = 'flydragon@gmail.com'
11
+ s.files = `git ls-files`.split("\n")
12
+ s.homepage = 'https://github.com/flydrago/mina-docker'
13
+ s.license = 'MIT'
14
+ s.require_paths = ['lib']
15
+
16
+ s.add_runtime_dependency 'mina', '>= 1.0.2'
17
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mina-docker
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - flydragon
@@ -30,8 +30,11 @@ executables: []
30
30
  extensions: []
31
31
  extra_rdoc_files: []
32
32
  files:
33
+ - README.md
33
34
  - lib/docker.rb
34
- homepage: https://rubygems.org/gems/mina-docker
35
+ - lib/mina/docker.rb
36
+ - mina-docker.gemspec
37
+ homepage: https://github.com/flydrago/mina-docker
35
38
  licenses:
36
39
  - MIT
37
40
  metadata: {}
@@ -53,5 +56,5 @@ requirements: []
53
56
  rubygems_version: 3.1.4
54
57
  signing_key:
55
58
  specification_version: 4
56
- summary: dd docker support for mina.
59
+ summary: add docker support for mina.
57
60
  test_files: []