shippy 0.1.3 → 0.1.4

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
  SHA256:
3
- metadata.gz: 16d22f393393da56cb043a62389601922ba62bc3dc7ce8b0f6d11a7b3880f991
4
- data.tar.gz: daae530d2031f02777ebee3ee60cc2d2988415498496e6ac37eda94c82b6ec99
3
+ metadata.gz: 88e53546e6bcac389ac600b0432bed0809b162857622e3bc560dbc98ea87da94
4
+ data.tar.gz: bc1e127d902f21cf04d3282d3f04c10db1aff3ea6113df213e2af0ceea8e69f4
5
5
  SHA512:
6
- metadata.gz: fc45722dcf032d0b8d0f0023da31a1d03c97af039851cbd67c81ac1a907587d0f964a6b96c49af1aa05cbea96bb4264c1df6859bf49ad748711394fd9eb2ff93
7
- data.tar.gz: 5e1efdbee18892ddcee10e52ad5078c60ed5aad448f98a536f8b54130c4ccae3081176a5262fbec06ab27abea5cb3cd400447fff780cd5c2c5fc1ac012e78b78
6
+ metadata.gz: 430ed1debda3020d516dd4d5902b6b176a747cb53d9775eed6e49ecf070fe5cd028b3ed343641d60c3e38959e918d9d8730d3bb9a6aba43a7650393aa24b55b1
7
+ data.tar.gz: 2596088fa15a92310a8fd4e5db8909267892b1c04b4cbaacbeffe37fceaf8ba1905c57580ac9d8cf277e94b64629cb88e97620aef6f7db9de6c81db4e5d3cbb4
data/README.md CHANGED
@@ -1,24 +1,44 @@
1
1
  # Shippy
2
2
 
3
- TODO: Delete this and the text below, and describe your gem
3
+ Container orchestration solution for homelabs inspired by [Capistrano](https://capistranorb.com/) and [mrsk](https://github.com/mrsked/mrsk) and built on top of [docker-compose](https://docs.docker.com/compose/).
4
4
 
5
- Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/shippy`. To experiment with that code, run `bin/console` for an interactive prompt.
5
+ ## Features
6
6
 
7
- ## Installation
7
+ - Ruby DSL to generate the docker-compose YAML files
8
+ - Centralized source to define secrets
9
+ - Uses Traefik as a reverse proxy with SSL wildcard support
8
10
 
9
- TODO: Replace `UPDATE_WITH_YOUR_GEM_NAME_PRIOR_TO_RELEASE_TO_RUBYGEMS_ORG` with your gem name right after releasing it to RubyGems.org. Please do not do it earlier due to security reasons. Alternatively, replace this section with instructions to install your gem from git if you don't plan to release to RubyGems.org.
11
+ ## Installation
10
12
 
11
13
  Install the gem and add to the application's Gemfile by executing:
12
14
 
13
- $ bundle add UPDATE_WITH_YOUR_GEM_NAME_PRIOR_TO_RELEASE_TO_RUBYGEMS_ORG
15
+ ```shell
16
+ $ bundle add shippy
17
+ ```
14
18
 
15
- If bundler is not being used to manage dependencies, install the gem by executing:
19
+ Or
16
20
 
17
- $ gem install UPDATE_WITH_YOUR_GEM_NAME_PRIOR_TO_RELEASE_TO_RUBYGEMS_ORG
21
+ ```shell
22
+ $ gem install shippy
23
+ ```
18
24
 
19
25
  ## Usage
20
26
 
21
- TODO: Write usage instructions here
27
+ In you homelab directory execute:
28
+
29
+ ```shell
30
+ homelab$ bundle exec shippy init
31
+ ```
32
+
33
+ Or
34
+
35
+ ```shell
36
+ homelab$ shippy init
37
+ ```
38
+
39
+ This will generate the config files and the `apps` directory with Traefik in the `proxy` app. This can be used as a guide for other apps.
40
+
41
+ Now `shippy` can be called using `bin/shippy` binstub and the other commands can be listed using `bin/shippy -h`.
22
42
 
23
43
  ## Development
24
44
 
@@ -28,7 +48,7 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
28
48
 
29
49
  ## Contributing
30
50
 
31
- Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/shippy. 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/[USERNAME]/shippy/blob/master/CODE_OF_CONDUCT.md).
51
+ Bug reports and merge requests are welcome on GitLab at https://gitlab.com/mrbobin/shippy. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](./CODE_OF_CONDUCT.md).
32
52
 
33
53
  ## License
34
54
 
@@ -36,4 +56,4 @@ The gem is available as open source under the terms of the [MIT License](https:/
36
56
 
37
57
  ## Code of Conduct
38
58
 
39
- Everyone interacting in the Shippy project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/shippy/blob/master/CODE_OF_CONDUCT.md).
59
+ Everyone interacting in the Shippy project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](./CODE_OF_CONDUCT.md).
@@ -0,0 +1,50 @@
1
+ class Shippy::Cli::Init < Thor::Group
2
+ include Thor::Actions
3
+
4
+ def self.exit_on_failure?
5
+ true
6
+ end
7
+
8
+ def self.source_root
9
+ File.dirname(__FILE__)
10
+ end
11
+
12
+ def create_config_file
13
+ copy_file "templates/config/shippy.yml", "config/shippy.yml"
14
+ end
15
+
16
+ def create_secrets_file
17
+ copy_file "templates/config/secrets.yml", "config/secrets.yml"
18
+ end
19
+
20
+ def init_gemfile
21
+ return if ::File.exist?("Gemfile")
22
+
23
+ run "bundle init", abort_on_failure: false
24
+ end
25
+
26
+ def add_shippy_to_gemfile
27
+ insert_into_file "Gemfile", "gem 'shippy', '~> #{Shippy::VERSION}'"
28
+
29
+ run "bundle install", abort_on_failure: false
30
+ end
31
+
32
+ def generate_binstubs
33
+ run "bundle binstubs shippy"
34
+ end
35
+
36
+ def create_default_apps
37
+ directory "templates/apps", "apps"
38
+ end
39
+
40
+ def init_git
41
+ run "git init"
42
+ end
43
+
44
+ def genegate_gitignore
45
+ create_file ".gitignore"
46
+ insert_into_file ".gitignore", "/.bundle/\n"
47
+ insert_into_file ".gitignore", "/builds/\n"
48
+ insert_into_file ".gitignore", "/config/secrets.yml\n"
49
+ end
50
+ end
@@ -1,38 +1,9 @@
1
1
  require "thor"
2
2
 
3
3
  class Shippy::Cli::Main < Shippy::Cli::Base
4
- desc "init", "Create config stub in config/shippy.yml"
5
- option :bundle, type: :boolean, default: false, desc: "Add SHIPPY to the Gemfile and create a bin/shippy binstub"
4
+ desc "init", "Create config files and app setup"
6
5
  def init
7
- require "fileutils"
8
-
9
- if (config_file = Pathname.new(File.expand_path("config/shippy.yml"))).exist?
10
- puts "Config file already exists in config/shippy.yml (remove first to create a new one)"
11
- else
12
- FileUtils.mkdir_p config_file.dirname
13
- FileUtils.cp_r Pathname.new(File.expand_path("templates/shippy.yml", __dir__)), config_file
14
- puts "Created configuration file in config/shippy.yml"
15
- end
16
-
17
- if Pathname.new(File.expand_path("apps")).exist?
18
- puts "Apps directory already exists in ./apps (remove first to create a new one)"
19
- else
20
- FileUtils.mkdir_p "apps"
21
- puts "Created apps directory in ./apps"
22
- end
23
-
24
- if options[:bundle]
25
- if Pathname.new(File.expand_path("bin/shippy")).exist?
26
- puts "Binstub already exists in bin/shippy (remove first to create a new one)"
27
- else
28
- puts "Adding SHIPPY to Gemfile and bundle..."
29
- run_locally do
30
- execute :bundle, :add, :shippy
31
- execute :bundle, :binstubs, :shippy
32
- end
33
- puts "Created binstub file in bin/shippy"
34
- end
35
- end
6
+ Shippy::Cli::Init.new.invoke_all
36
7
  end
37
8
 
38
9
  desc "version", "Show SHIPPY version"
@@ -0,0 +1,27 @@
1
+ Shippy.define do
2
+ service :proxy do
3
+ image { "traefik:v2.9" }
4
+ command { "--configFile=/config/config.yml" }
5
+
6
+ environment do
7
+ {
8
+ CF_API_EMAIL: secrets(:cloudflare_email),
9
+ CF_DNS_API_TOKEN: secrets(:cloudflare_token)
10
+ }
11
+ end
12
+
13
+ ports do
14
+ ["80:80", "443:443", "8080:8080"]
15
+ end
16
+
17
+ volumes do
18
+ [
19
+ "/var/run/docker.sock:/var/run/docker.sock",
20
+ "./traefik:/config",
21
+ "acme:/etc/traefik/acme"
22
+ ]
23
+ end
24
+
25
+ use_default_options
26
+ end
27
+ end
@@ -0,0 +1,27 @@
1
+ providers:
2
+ docker:
3
+ exposedByDefault: false
4
+ file:
5
+ filename: "/config/dynamic_config.yml"
6
+
7
+ api:
8
+ insecure: true
9
+ dashboard: true
10
+
11
+ entryPoints:
12
+ web:
13
+ address: ":80"
14
+ websecure:
15
+ address: ":443"
16
+
17
+ log:
18
+ level: TRACE
19
+ accessLog: {}
20
+
21
+ certificatesResolvers:
22
+ ssl-resolver:
23
+ acme:
24
+ email: <%= secrets(:cloudflare_email) %>
25
+ storage: /etc/traefik/acme/acme.json
26
+ dnsChallenge:
27
+ provider: cloudflare
@@ -0,0 +1,7 @@
1
+ http:
2
+ routers:
3
+ middlewares:
4
+ secure-redirect-scheme:
5
+ redirectscheme:
6
+ scheme: https
7
+ permanent: true
@@ -0,0 +1,3 @@
1
+ proxy:
2
+ cloudflare_email: me@example.org
3
+ cloudflare_token: token
@@ -3,6 +3,5 @@ ssh:
3
3
  user: root
4
4
  wildcard_domain: 'local.homelab.com'
5
5
  local_domain: local
6
- secrets:
7
- proxy:
8
- token: TOKEN
6
+ deploy_to: '/var/lib/homelab'
7
+ secrets_file: 'config/secrets.yml'
data/lib/shippy/cli.rb CHANGED
@@ -1,4 +1,5 @@
1
1
  require_relative "cli/base"
2
+ require_relative "cli/init"
2
3
  require_relative "cli/server"
3
4
  require_relative "cli/app"
4
5
  require_relative "cli/prune"
data/lib/shippy/config.rb CHANGED
@@ -4,13 +4,11 @@ module Shippy
4
4
 
5
5
  def initialize(file)
6
6
  @data = YAML.load_file(file).deep_symbolize_keys
7
+ @secrets = Secrets.new(@data.fetch(:secrets_file))
7
8
  end
8
9
 
9
10
  def secrets(app, name)
10
- @data
11
- .fetch(:secrets)
12
- .fetch(app.to_sym)
13
- .fetch(name.to_sym)
11
+ @secrets.fetch(app, name)
14
12
  end
15
13
 
16
14
  def ssh_options
@@ -30,15 +28,15 @@ module Shippy
30
28
  end
31
29
 
32
30
  def method_missing(name, *args)
33
- if @data.key?(name)
34
- @data.fetch(name)
31
+ if data.key?(name)
32
+ data.fetch(name)
35
33
  else
36
34
  super
37
35
  end
38
36
  end
39
37
 
40
38
  def respond_to_missing?(name, include_private = false)
41
- @data.key?(name) || super
39
+ data.key?(name) || super
42
40
  end
43
41
  end
44
42
  end
@@ -0,0 +1,15 @@
1
+ module Shippy
2
+ class Secrets
3
+ attr_reader :data
4
+
5
+ def initialize(file)
6
+ @data = YAML.load_file(file).deep_symbolize_keys
7
+ end
8
+
9
+ def fetch(app, name)
10
+ data
11
+ .fetch(app.to_sym)
12
+ .fetch(name.to_sym)
13
+ end
14
+ end
15
+ end
@@ -1,3 +1,3 @@
1
1
  module Shippy
2
- VERSION = "0.1.3"
2
+ VERSION = "0.1.4"
3
3
  end
data/lib/shippy.rb CHANGED
@@ -9,6 +9,7 @@ require "minitar"
9
9
  require "zlib"
10
10
 
11
11
  require_relative "shippy/version"
12
+ require_relative "shippy/secrets"
12
13
  require_relative "shippy/config"
13
14
  require_relative "shippy/commander"
14
15
  require_relative "shippy/cli"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: shippy
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Marius Bobin
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-03-25 00:00:00.000000000 Z
11
+ date: 2023-04-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -163,15 +163,21 @@ files:
163
163
  - lib/shippy/cli.rb
164
164
  - lib/shippy/cli/app.rb
165
165
  - lib/shippy/cli/base.rb
166
+ - lib/shippy/cli/init.rb
166
167
  - lib/shippy/cli/main.rb
167
168
  - lib/shippy/cli/prune.rb
168
169
  - lib/shippy/cli/server.rb
169
- - lib/shippy/cli/templates/shippy.yml
170
+ - lib/shippy/cli/templates/apps/proxy/docker-compose.rb
171
+ - lib/shippy/cli/templates/apps/proxy/traefik/config.yml.erb
172
+ - lib/shippy/cli/templates/apps/proxy/traefik/dynamic_config.yml
173
+ - lib/shippy/cli/templates/config/secrets.yml
174
+ - lib/shippy/cli/templates/config/shippy.yml
170
175
  - lib/shippy/commander.rb
171
176
  - lib/shippy/compiler.rb
172
177
  - lib/shippy/compose.rb
173
178
  - lib/shippy/config.rb
174
179
  - lib/shippy/repo.rb
180
+ - lib/shippy/secrets.rb
175
181
  - lib/shippy/service.rb
176
182
  - lib/shippy/version.rb
177
183
  homepage: https://mbobin.me/shippy