dpmrb 0.1.0

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
+ SHA256:
3
+ metadata.gz: 0d251b5232b12841efab78a0f74f65056ae375e39a08445338d9265b6d83d75e
4
+ data.tar.gz: ce4fd73830d32e9d8384c151a9f8a9c1d80c0adece695b94ccd52f12abcf5627
5
+ SHA512:
6
+ metadata.gz: 95386af7e0176db7a926b5cbea3e3e1822d7d7ef4ce31dfc35446b7d59aeb50f060f27542f7ca34bc0bb0a5ae2d86de03fe81f0b36f75ed0bc5c014eeb775dd8
7
+ data.tar.gz: 235b12ac3c8c62bdafaad7a6c3632c319a4396fbcd98feb36cc102611c6b8bc0e63b5436c63ce47472835d4efaf149bf85b12ad8653ed83733315af13ea06d44
data/.standard.yml ADDED
@@ -0,0 +1,3 @@
1
+ # For available configuration options, see:
2
+ # https://github.com/testdouble/standard
3
+ ruby_version: 2.6
data/CHANGELOG.md ADDED
@@ -0,0 +1,5 @@
1
+ ## [Unreleased]
2
+
3
+ ## [0.1.0] - 2022-08-13
4
+
5
+ - Initial release
@@ -0,0 +1,84 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ We as members, contributors, and leaders pledge to make participation in our community a harassment-free experience for everyone, regardless of age, body size, visible or invisible disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, religion, or sexual identity and orientation.
6
+
7
+ We pledge to act and interact in ways that contribute to an open, welcoming, diverse, inclusive, and healthy community.
8
+
9
+ ## Our Standards
10
+
11
+ Examples of behavior that contributes to a positive environment for our community include:
12
+
13
+ * Demonstrating empathy and kindness toward other people
14
+ * Being respectful of differing opinions, viewpoints, and experiences
15
+ * Giving and gracefully accepting constructive feedback
16
+ * Accepting responsibility and apologizing to those affected by our mistakes, and learning from the experience
17
+ * Focusing on what is best not just for us as individuals, but for the overall community
18
+
19
+ Examples of unacceptable behavior include:
20
+
21
+ * The use of sexualized language or imagery, and sexual attention or
22
+ advances of any kind
23
+ * Trolling, insulting or derogatory comments, and personal or political attacks
24
+ * Public or private harassment
25
+ * Publishing others' private information, such as a physical or email
26
+ address, without their explicit permission
27
+ * Other conduct which could reasonably be considered inappropriate in a
28
+ professional setting
29
+
30
+ ## Enforcement Responsibilities
31
+
32
+ Community leaders are responsible for clarifying and enforcing our standards of acceptable behavior and will take appropriate and fair corrective action in response to any behavior that they deem inappropriate, threatening, offensive, or harmful.
33
+
34
+ Community leaders have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, and will communicate reasons for moderation decisions when appropriate.
35
+
36
+ ## Scope
37
+
38
+ This Code of Conduct applies within all community spaces, and also applies when an individual is officially representing the community in public spaces. Examples of representing our community include using an official e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event.
39
+
40
+ ## Enforcement
41
+
42
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be reported to the community leaders responsible for enforcement at songhuang@gitlab.cn. All complaints will be reviewed and investigated promptly and fairly.
43
+
44
+ All community leaders are obligated to respect the privacy and security of the reporter of any incident.
45
+
46
+ ## Enforcement Guidelines
47
+
48
+ Community leaders will follow these Community Impact Guidelines in determining the consequences for any action they deem in violation of this Code of Conduct:
49
+
50
+ ### 1. Correction
51
+
52
+ **Community Impact**: Use of inappropriate language or other behavior deemed unprofessional or unwelcome in the community.
53
+
54
+ **Consequence**: A private, written warning from community leaders, providing clarity around the nature of the violation and an explanation of why the behavior was inappropriate. A public apology may be requested.
55
+
56
+ ### 2. Warning
57
+
58
+ **Community Impact**: A violation through a single incident or series of actions.
59
+
60
+ **Consequence**: A warning with consequences for continued behavior. No interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, for a specified period of time. This includes avoiding interactions in community spaces as well as external channels like social media. Violating these terms may lead to a temporary or permanent ban.
61
+
62
+ ### 3. Temporary Ban
63
+
64
+ **Community Impact**: A serious violation of community standards, including sustained inappropriate behavior.
65
+
66
+ **Consequence**: A temporary ban from any sort of interaction or public communication with the community for a specified period of time. No public or private interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, is allowed during this period. Violating these terms may lead to a permanent ban.
67
+
68
+ ### 4. Permanent Ban
69
+
70
+ **Community Impact**: Demonstrating a pattern of violation of community standards, including sustained inappropriate behavior, harassment of an individual, or aggression toward or disparagement of classes of individuals.
71
+
72
+ **Consequence**: A permanent ban from any sort of public interaction within the community.
73
+
74
+ ## Attribution
75
+
76
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 2.0,
77
+ available at https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.
78
+
79
+ Community Impact Guidelines were inspired by [Mozilla's code of conduct enforcement ladder](https://github.com/mozilla/diversity).
80
+
81
+ [homepage]: https://www.contributor-covenant.org
82
+
83
+ For answers to common questions about this code of conduct, see the FAQ at
84
+ https://www.contributor-covenant.org/faq. Translations are available at https://www.contributor-covenant.org/translations.
data/Gemfile ADDED
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ source "https://rubygems.org"
4
+
5
+ # Specify your gem's dependencies in dpm.gemspec
6
+ gemspec
7
+
8
+ gem "rake", "~> 13.0"
9
+
10
+ gem "minitest", "~> 5.0"
11
+
12
+ gem "standard", "~> 1.3"
data/Gemfile.lock ADDED
@@ -0,0 +1,61 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ dpmrb (0.1.0)
5
+ activesupport (~> 7.x)
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ activesupport (7.0.3.1)
11
+ concurrent-ruby (~> 1.0, >= 1.0.2)
12
+ i18n (>= 1.6, < 2)
13
+ minitest (>= 5.1)
14
+ tzinfo (~> 2.0)
15
+ ast (2.4.2)
16
+ concurrent-ruby (1.1.10)
17
+ i18n (1.12.0)
18
+ concurrent-ruby (~> 1.0)
19
+ json (2.6.2)
20
+ minitest (5.16.2)
21
+ parallel (1.22.1)
22
+ parser (3.1.2.1)
23
+ ast (~> 2.4.1)
24
+ rainbow (3.1.1)
25
+ rake (13.0.6)
26
+ regexp_parser (2.5.0)
27
+ rexml (3.2.5)
28
+ rubocop (1.33.0)
29
+ json (~> 2.3)
30
+ parallel (~> 1.10)
31
+ parser (>= 3.1.0.0)
32
+ rainbow (>= 2.2.2, < 4.0)
33
+ regexp_parser (>= 1.8, < 3.0)
34
+ rexml (>= 3.2.5, < 4.0)
35
+ rubocop-ast (>= 1.19.1, < 2.0)
36
+ ruby-progressbar (~> 1.7)
37
+ unicode-display_width (>= 1.4.0, < 3.0)
38
+ rubocop-ast (1.21.0)
39
+ parser (>= 3.1.1.0)
40
+ rubocop-performance (1.14.3)
41
+ rubocop (>= 1.7.0, < 2.0)
42
+ rubocop-ast (>= 0.4.0)
43
+ ruby-progressbar (1.11.0)
44
+ standard (1.15.0)
45
+ rubocop (= 1.33.0)
46
+ rubocop-performance (= 1.14.3)
47
+ tzinfo (2.0.5)
48
+ concurrent-ruby (~> 1.0)
49
+ unicode-display_width (2.2.0)
50
+
51
+ PLATFORMS
52
+ arm64-darwin-21
53
+
54
+ DEPENDENCIES
55
+ dpmrb!
56
+ minitest (~> 5.0)
57
+ rake (~> 13.0)
58
+ standard (~> 1.3)
59
+
60
+ BUNDLED WITH
61
+ 2.3.20
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2022 Song Huang
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,41 @@
1
+ [English](README.md) | [简体中文](README.zh-CN.md)
2
+
3
+ # DPM
4
+
5
+ Docker Package Manager, makes using your containers as easy as package managers (`apt`, `yml`, `brew`).
6
+
7
+ ## Installation
8
+
9
+ ```bash
10
+ gem install dpmrb
11
+ ```
12
+
13
+ ## Usage
14
+
15
+ ```bash
16
+ dpm help # Show help
17
+ dpm list # docker ps --filter "name=dpm-"
18
+ dpm start mysql # docker run --name=dpm-mysql -d --rm -p 3306:3306 -e MYSQL_ALLOW_EMPTY_PASSWORD=yes ...
19
+ dpm stop mysql # docker stop dpm-mysql
20
+ dpm status mysql # docker ps --filter "name=dpm-mysql"
21
+ dpm start elasticsearch:7.10.2 # docker run --name=dpm-elasticsearch-7.10.2 -d --rm -p 9200:9200 -e discovery.type=single-node ...
22
+ dpm start mysql:5.7 # docker run --name=dpm-mysql-5.7 -d --rm -p 3306:3306 -e MYSQL_ALLOW_EMPTY_PASSWORD=yes ...
23
+ ```
24
+
25
+ ## Development
26
+
27
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
28
+
29
+ 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 the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
30
+
31
+ ## Contributing
32
+
33
+ Bug reports and pull requests are welcome on GitHub at https://github.com/songhuangcn/dpm. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/songhuangcn/dpm/blob/main/CODE_OF_CONDUCT.md).
34
+
35
+ ## License
36
+
37
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
38
+
39
+ ## Code of Conduct
40
+
41
+ Everyone interacting in the Dpm project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/songhuangcn/dpm/blob/main/CODE_OF_CONDUCT.md).
data/README.zh-CN.md ADDED
@@ -0,0 +1,103 @@
1
+ [English](README.md) | [简体中文](README.zh-CN.md)
2
+
3
+ # DPM
4
+
5
+ Docker Package Manager, 让你的容器用起来跟包管理器(`apt`, `yml`, `brew`)一样简单。
6
+
7
+ ## 安装
8
+
9
+ ```bash
10
+ gem install dpmrb
11
+ ```
12
+
13
+ ## 使用
14
+
15
+ ```bash
16
+ dpm help # Show help
17
+ dpm list # docker ps --filter "name=dpm-"
18
+ dpm start mysql # docker run --name=dpm-mysql -d --rm -p 3306:3306 -e MYSQL_ALLOW_EMPTY_PASSWORD=yes ...
19
+ dpm stop mysql # docker stop dpm-mysql
20
+ dpm status mysql # docker ps --filter "name=dpm-mysql"
21
+ dpm start elasticsearch:7.10.2 # docker run --name=dpm-elasticsearch-7.10.2 -d --rm -p 9200:9200 -e discovery.type=single-node ...
22
+ dpm start mysql:5.7 # docker run --name=dpm-mysql-5.7 -d --rm -p 3306:3306 -e MYSQL_ALLOW_EMPTY_PASSWORD=yes ...
23
+ ```
24
+
25
+ ## 为项目添加新包
26
+
27
+ DPM 跟 [Homebrew](https://brew.sh/) 一样,需要完善更多的包配置,欢迎为 `packages` 目录添加你需要的包配置。
28
+
29
+ ### 配置级别
30
+
31
+ 容器配置都是通用的 YAML 格式,有三个级别:
32
+
33
+ 1. 默认级别:`packages/default.yml`
34
+ 1. 包级别:`packages/PACKAGE/default.yml`
35
+ 1. 版本级别:`packages/PACKAGE/tag-TAG.yml`
36
+
37
+ 配置是合并机制,如果一个包没有自定义配置,他就会根据默认级别配置跑起来。
38
+
39
+ ### 配置示例
40
+
41
+ 例如有配置如下:
42
+
43
+ 1. `packages/default.yml`:
44
+ ```yml
45
+ run_options:
46
+ rm: true
47
+ d: true
48
+ ```
49
+ 1. `packages/mysql/default.yml`:
50
+ ```yml
51
+ run_options:
52
+ e: "MYSQL_ALLOW_EMPTY_PASSWORD=yes"
53
+ p: "3306:3306"
54
+ ```
55
+ 1. `packages/mysql/tag-5.7.yml`:
56
+ ```yml
57
+ run_options:
58
+ p: "3307:3307"
59
+ ```
60
+
61
+ 则最终这些包配置的启动命令为:
62
+
63
+ - `mysql:5.7` 的配置:
64
+ ```bash
65
+ docker run --rm -d -p 3307:3307 -e MYSQL_ALLOW_EMPTY_PASSWORD=yes mysql:5.7
66
+ ```
67
+ - `mysql` 的配置:
68
+ ```bash
69
+ docker run --rm -d -p 3306:3306 -e MYSQL_ALLOW_EMPTY_PASSWORD=yes mysql
70
+ ```
71
+ - `not-exist-pkg` 的配置:
72
+ ```bash
73
+ docker run --rm -d not-exist-pkg
74
+ ```
75
+
76
+ ### 其他配置
77
+
78
+ 有一些其他配置项,例如 `image`:
79
+
80
+ `packages/elasticsearch/default.yml`
81
+ ```yml
82
+ image: "docker.elastic.co/elasticsearch/elasticsearch"
83
+ ```
84
+
85
+ 则 `elasticsearch` 包的镜像将不在按约定自动计算,而是变成了:
86
+
87
+ ```bash
88
+ docker.elastic.co/elasticsearch/elasticsearch
89
+ ```
90
+
91
+ 还有一些配置,例如:`args`,这个是传入到容器的参数,例如有配置文件 `packages/mysql/default.yml`:
92
+
93
+ ```yml
94
+ args:
95
+ character-set-server: "utf8mb4"
96
+ collation-server: "utf8mb4_unicode_ci"
97
+ ```
98
+
99
+ 则所有版本的 `mysql` 包将会多这两个启动参数:
100
+
101
+ ```bash
102
+ docker run mysql --character-set-server=utf8mb4 --collation-server=utf8mb4_unicode_ci
103
+ ```
data/Rakefile ADDED
@@ -0,0 +1,14 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "bundler/gem_tasks"
4
+ require "rake/testtask"
5
+
6
+ Rake::TestTask.new(:test) do |t|
7
+ t.libs << "test"
8
+ t.libs << "lib"
9
+ t.test_files = FileList["test/**/test_*.rb"]
10
+ end
11
+
12
+ require "standard/rake"
13
+
14
+ task default: %i[test standard]
data/bin/dpm ADDED
@@ -0,0 +1,10 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require_relative "../lib/dpm"
4
+
5
+ begin
6
+ DPM::Runner.call!(ARGV)
7
+ rescue => exception
8
+ puts "Errors: #{exception.message}"
9
+ exit 1
10
+ end
data/dpm.gemspec ADDED
@@ -0,0 +1,35 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "lib/dpm/version"
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = "dpmrb"
7
+ spec.version = Dpm::VERSION
8
+ spec.authors = ["Song Huang"]
9
+ spec.email = ["songhuangcn@gmail.com"]
10
+
11
+ spec.summary = "Docker Package Manager."
12
+ spec.description = "Makes using your containers as easy as package managers (`apt`, `yml`, `brew`)."
13
+ spec.homepage = "https://github.com/songhuangcn/dpm"
14
+ spec.license = "MIT"
15
+ spec.required_ruby_version = ">= 2.6.0"
16
+
17
+ spec.metadata["homepage_uri"] = spec.homepage
18
+ spec.metadata["source_code_uri"] = spec.homepage
19
+
20
+ # Specify which files should be added to the gem when it is released.
21
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
22
+ spec.files = Dir.chdir(__dir__) do
23
+ `git ls-files -z`.split("\x0").reject do |f|
24
+ (f == __FILE__) || f.match(%r{\A(?:(?:bin|test|spec|features)/|\.(?:git|travis|circleci)|appveyor)})
25
+ end
26
+ end
27
+ spec.bindir = "bin"
28
+ spec.executables = ["dpm"]
29
+ spec.require_paths = ["lib"]
30
+
31
+ spec.post_install_message = "Please start with `dpm help`"
32
+
33
+ spec.add_dependency "activesupport", "~> 7.x"
34
+
35
+ end
data/lib/dpm/errors.rb ADDED
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module DPM
4
+ class Error < StandardError; end
5
+ end
data/lib/dpm/runner.rb ADDED
@@ -0,0 +1,166 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "yaml"
4
+ require "erb"
5
+
6
+ module DPM
7
+ class Runner
8
+ PACKAGE_COMMANDS = %w[status start stop restart].freeze
9
+ PACKAGE_REGEX = /\A[\w.\-:]+\z/.freeze
10
+ CONTAINER_NAME_PREFIX = "dpm-"
11
+ BASH_COLOR_GRAY = "\033[0;37m"
12
+ BASH_COLOR_NONE = "\033[0m"
13
+
14
+ attr_reader :command, :package
15
+
16
+ def self.call!(argv)
17
+ new(argv).call!
18
+ end
19
+
20
+ def initialize(argv)
21
+ @command, @package = argv
22
+ validate_argv!
23
+ end
24
+
25
+ def call!
26
+ if docker_command
27
+ puts bash_color(docker_command)
28
+ puts ""
29
+ puts `#{docker_command}`
30
+ else
31
+ puts help_text
32
+ end
33
+ end
34
+
35
+ private
36
+
37
+ def validate_argv!
38
+ if PACKAGE_COMMANDS.include?(command) && !PACKAGE_REGEX.match?(package)
39
+ raise Error, "`package` invalid, valid regex: #{PACKAGE_REGEX}"
40
+ end
41
+ end
42
+
43
+ def bash_color(text)
44
+ "#{BASH_COLOR_GRAY}#{text}#{BASH_COLOR_NONE}"
45
+ end
46
+
47
+ def docker_command
48
+ case command
49
+ when "list"
50
+ %(docker ps --filter "name=#{CONTAINER_NAME_PREFIX}")
51
+ when "status"
52
+ %(docker ps --filter "name=#{container_name}")
53
+ when "start"
54
+ "docker run #{docker_run_params}"
55
+ when "stop"
56
+ "docker stop #{container_name}"
57
+ when "restart"
58
+ "dpm stop #{package} && dpm start #{package}"
59
+ end
60
+ end
61
+
62
+ def help_text
63
+ <<~EOF
64
+ Usage: dpm command [PACKAGE]
65
+
66
+ Docker Package Manager
67
+
68
+ dpm help:
69
+ Show the help
70
+ dpm list:
71
+ List running packages
72
+ dpm status PACKAGE:
73
+ Get the status of the package
74
+ dpm start PACKAGE:
75
+ Start the package
76
+ dpm stop PACKAGE:
77
+ Stop the package
78
+ dpm restart PACKAGE:
79
+ Restart the package
80
+
81
+ See more at https://github.com/songhuangcn/dpm
82
+ EOF
83
+ end
84
+
85
+ def docker_run_params
86
+ @docker_run_params ||= [config_run_options, docker_image, config_command, config_args].select(&:present?).join(" ")
87
+ end
88
+
89
+ def config_run_options
90
+ process_options(manager_config["run_options"])
91
+ end
92
+
93
+ def config_command
94
+ manager_config["command"]
95
+ end
96
+
97
+ def config_args
98
+ process_options(manager_config["args"])
99
+ end
100
+
101
+ def process_options(hash)
102
+ return "" unless hash
103
+
104
+ hash = hash.reject { |key, value| value == false }
105
+ hash_arr = hash.map do |key, value|
106
+ if key.length == 1
107
+ option_prefix = "-"
108
+ value_joiner = " "
109
+ else
110
+ option_prefix = "--"
111
+ value_joiner = "="
112
+ end
113
+ full_value = "#{value_joiner}#{value}" if value != true
114
+
115
+ "#{option_prefix}#{key}#{full_value}"
116
+ end
117
+ hash_arr.join(" ")
118
+ end
119
+
120
+ def docker_image
121
+ image_tag ? "#{image_name}:#{image_tag}" : image_name
122
+ end
123
+
124
+ def image_name
125
+ @image_name ||= manager_config["image_name"] || package_name
126
+ end
127
+
128
+ def image_tag
129
+ @image_tag ||= manager_config["image_tag"] || package_tag
130
+ end
131
+
132
+ def manager_config
133
+ @manager_config ||= begin
134
+ default_options = load_yaml(File.join(ROOT, "packages", "default.yml"))
135
+ image_options = load_yaml(File.join(ROOT, "packages", package_name, "default.yml"))
136
+ tag_options = load_yaml(File.join(ROOT, "packages", package_name, "tag-#{package_tag}.yml"))
137
+
138
+ default_options \
139
+ .deep_merge(image_options) \
140
+ .deep_merge(tag_options)
141
+ end
142
+ end
143
+
144
+ def package_name
145
+ @package_name ||= package.split(":")[0]
146
+ end
147
+
148
+ def package_tag
149
+ @package_tag ||= package.split(":")[1]
150
+ end
151
+
152
+ def container_name
153
+ @container_name ||= "#{CONTAINER_NAME_PREFIX}#{package.tr(":", "-")}"
154
+ end
155
+
156
+ def load_yaml(file_path)
157
+ text = File.read(file_path)
158
+ data = ERB.new(text).result(binding)
159
+ YAML.safe_load(data).tap do |yaml|
160
+ raise Error, "Config need to be a hash yaml: #{file_path}" unless yaml.is_a?(Hash)
161
+ end
162
+ rescue Errno::ENOENT
163
+ {}
164
+ end
165
+ end
166
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Dpm
4
+ VERSION = "0.1.0"
5
+ end
data/lib/dpm.rb ADDED
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "active_support"
4
+ require "active_support/core_ext"
5
+
6
+ require_relative "dpm/version"
7
+ require_relative "dpm/errors"
8
+ require_relative "dpm/runner"
9
+
10
+ module DPM
11
+ ROOT = File.expand_path("..", __dir__).freeze
12
+ HOME = File.expand_path("~/.dpm").freeze
13
+ end
@@ -0,0 +1,7 @@
1
+ run_options:
2
+ name: "<%= container_name %>"
3
+ d: true
4
+ rm: true
5
+ image: ""
6
+ command: ""
7
+ args: {}
@@ -0,0 +1,5 @@
1
+ image_name: "docker.elastic.co/elasticsearch/elasticsearch"
2
+ run_options:
3
+ p: "9200:9200"
4
+ e: "discovery.type=single-node"
5
+ v: "<%= DPM::HOME %>/data/<%= package_name %>/<%= package_tag || 'default' %>:/usr/share/elasticsearch/data"
@@ -0,0 +1,7 @@
1
+ run_options:
2
+ p: "3306:3306"
3
+ e: "MYSQL_ALLOW_EMPTY_PASSWORD=yes"
4
+ v: "<%= DPM::HOME %>/data/<%= package_name %>/<%= package_tag || 'default' %>:/var/lib/mysql"
5
+ args:
6
+ character-set-server: "utf8mb4"
7
+ collation-server: "utf8mb4_unicode_ci"
@@ -0,0 +1,2 @@
1
+ run_options:
2
+ v: "<%= DPM::HOME %>/data/mysql-5.7:/var/lib/mysql"
@@ -0,0 +1,2 @@
1
+ run_options:
2
+ p: "80:80"
@@ -0,0 +1,2 @@
1
+ run_options:
2
+ p: "6379:6379"
data/sig/dpm.rbs ADDED
@@ -0,0 +1,4 @@
1
+ module Dpm
2
+ VERSION: String
3
+ # See the writing guide of rbs: https://github.com/ruby/rbs#guides
4
+ end
metadata ADDED
@@ -0,0 +1,83 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: dpmrb
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Song Huang
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2022-08-13 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: activesupport
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: 7.x
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: 7.x
27
+ description: Makes using your containers as easy as package managers (`apt`, `yml`,
28
+ `brew`).
29
+ email:
30
+ - songhuangcn@gmail.com
31
+ executables:
32
+ - dpm
33
+ extensions: []
34
+ extra_rdoc_files: []
35
+ files:
36
+ - ".standard.yml"
37
+ - CHANGELOG.md
38
+ - CODE_OF_CONDUCT.md
39
+ - Gemfile
40
+ - Gemfile.lock
41
+ - LICENSE.txt
42
+ - README.md
43
+ - README.zh-CN.md
44
+ - Rakefile
45
+ - bin/dpm
46
+ - dpm.gemspec
47
+ - lib/dpm.rb
48
+ - lib/dpm/errors.rb
49
+ - lib/dpm/runner.rb
50
+ - lib/dpm/version.rb
51
+ - packages/default.yml
52
+ - packages/elasticsearch/default.yml
53
+ - packages/mysql/default.yml
54
+ - packages/mysql/tag-5.7.yml
55
+ - packages/nginx/default.yml
56
+ - packages/redis/default.yml
57
+ - sig/dpm.rbs
58
+ homepage: https://github.com/songhuangcn/dpm
59
+ licenses:
60
+ - MIT
61
+ metadata:
62
+ homepage_uri: https://github.com/songhuangcn/dpm
63
+ source_code_uri: https://github.com/songhuangcn/dpm
64
+ post_install_message: Please start with `dpm help`
65
+ rdoc_options: []
66
+ require_paths:
67
+ - lib
68
+ required_ruby_version: !ruby/object:Gem::Requirement
69
+ requirements:
70
+ - - ">="
71
+ - !ruby/object:Gem::Version
72
+ version: 2.6.0
73
+ required_rubygems_version: !ruby/object:Gem::Requirement
74
+ requirements:
75
+ - - ">="
76
+ - !ruby/object:Gem::Version
77
+ version: '0'
78
+ requirements: []
79
+ rubygems_version: 3.3.20
80
+ signing_key:
81
+ specification_version: 4
82
+ summary: Docker Package Manager.
83
+ test_files: []