shippy 0.1.3 → 0.1.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +72 -10
- data/lib/shippy/cli/init.rb +50 -0
- data/lib/shippy/cli/main.rb +2 -31
- data/lib/shippy/cli/templates/apps/proxy/docker-compose.rb +27 -0
- data/lib/shippy/cli/templates/apps/proxy/traefik/config.yml.erb +27 -0
- data/lib/shippy/cli/templates/apps/proxy/traefik/dynamic_config.yml +7 -0
- data/lib/shippy/cli/templates/config/secrets.yml +3 -0
- data/lib/shippy/cli/templates/{shippy.yml → config/shippy.yml} +2 -3
- data/lib/shippy/cli.rb +1 -0
- data/lib/shippy/config.rb +5 -7
- data/lib/shippy/secrets.rb +15 -0
- data/lib/shippy/service.rb +1 -1
- data/lib/shippy/version.rb +1 -1
- data/lib/shippy.rb +1 -0
- metadata +9 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e28ff568f47b1c6ab79cd83a7f136a07187f9966d71fc134200396f9a7f235c4
|
4
|
+
data.tar.gz: c3d4d946f98cfc6c993e00ff3e5bc685261a34e05bad9b1e9e7c776a5fe26bf2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c964e8762f426cae3ed46adb35c117dc327a15f9a378a39015ebe30b17bc045418a6bbbe786988f48884cb96e71863436693fd53267ca6fb9662efd272b045af
|
7
|
+
data.tar.gz: e87db690c30bb9939114fd95a06f315c0356f79efceff5353baaf99ea9cadabfe54d0e89465f7f5e5c0d8c7cc43cd3d39e024123a8803b8581a310542fc7d4c1
|
data/README.md
CHANGED
@@ -1,24 +1,86 @@
|
|
1
1
|
# Shippy
|
2
2
|
|
3
|
-
|
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
|
-
|
5
|
+
## Features
|
6
6
|
|
7
|
-
|
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
|
-
|
11
|
+
## Installation
|
10
12
|
|
11
13
|
Install the gem and add to the application's Gemfile by executing:
|
12
14
|
|
13
|
-
|
15
|
+
```shell
|
16
|
+
$ bundle add shippy
|
17
|
+
```
|
14
18
|
|
15
|
-
|
19
|
+
Or
|
16
20
|
|
17
|
-
|
21
|
+
```shell
|
22
|
+
$ gem install shippy
|
23
|
+
```
|
18
24
|
|
19
25
|
## Usage
|
20
26
|
|
21
|
-
|
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`.
|
42
|
+
|
43
|
+
### Docker compose DSL:
|
44
|
+
|
45
|
+
Conventions:
|
46
|
+
|
47
|
+
- the file needs to be located at `apps/app_name/docker-compose.rb`
|
48
|
+
- the `Shippy.define {}` block describes multiple services for the same compose file
|
49
|
+
- `service :name` describes a docker service
|
50
|
+
- most of the docker-compose keywords are implemented as [methods](./lib/shippy/service.rb) that accept a block.
|
51
|
+
- `volumes` and `networks` are automatically defined
|
52
|
+
|
53
|
+
Example:
|
54
|
+
|
55
|
+
```ruby
|
56
|
+
Shippy.define do
|
57
|
+
service :proxy do
|
58
|
+
image { "traefik:v2.9" }
|
59
|
+
command { "--configFile=/config/config.yml" }
|
60
|
+
|
61
|
+
environment do
|
62
|
+
{
|
63
|
+
CF_API_EMAIL: secrets(:cloudflare_email),
|
64
|
+
CF_DNS_API_TOKEN: secrets(:cloudflare_token)
|
65
|
+
}
|
66
|
+
end
|
67
|
+
|
68
|
+
ports do
|
69
|
+
["80:80", "443:443", "8080:8080"]
|
70
|
+
end
|
71
|
+
|
72
|
+
volumes do
|
73
|
+
[
|
74
|
+
"/var/run/docker.sock:/var/run/docker.sock",
|
75
|
+
"./traefik:/config",
|
76
|
+
"acme:/etc/traefik/acme"
|
77
|
+
]
|
78
|
+
end
|
79
|
+
|
80
|
+
use_default_options
|
81
|
+
end
|
82
|
+
end
|
83
|
+
```
|
22
84
|
|
23
85
|
## Development
|
24
86
|
|
@@ -28,7 +90,7 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
|
|
28
90
|
|
29
91
|
## Contributing
|
30
92
|
|
31
|
-
Bug reports and
|
93
|
+
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
94
|
|
33
95
|
## License
|
34
96
|
|
@@ -36,4 +98,4 @@ The gem is available as open source under the terms of the [MIT License](https:/
|
|
36
98
|
|
37
99
|
## Code of Conduct
|
38
100
|
|
39
|
-
Everyone interacting in the Shippy project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](
|
101
|
+
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
|
data/lib/shippy/cli/main.rb
CHANGED
@@ -1,38 +1,9 @@
|
|
1
1
|
require "thor"
|
2
2
|
|
3
3
|
class Shippy::Cli::Main < Shippy::Cli::Base
|
4
|
-
desc "init", "Create config
|
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
|
-
|
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
|
data/lib/shippy/cli.rb
CHANGED
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
|
-
@
|
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
|
34
|
-
|
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
|
-
|
39
|
+
data.key?(name) || super
|
42
40
|
end
|
43
41
|
end
|
44
42
|
end
|
data/lib/shippy/service.rb
CHANGED
@@ -2,7 +2,7 @@ module Shippy
|
|
2
2
|
class Service
|
3
3
|
ATTRIBUTES = %i[
|
4
4
|
build command depends_on devices entrypoint environment hostname image
|
5
|
-
labels logging networks ports restart volumes volumes_from working_dir
|
5
|
+
labels logging networks user ports restart volumes volumes_from working_dir
|
6
6
|
security_opt
|
7
7
|
].freeze
|
8
8
|
|
data/lib/shippy/version.rb
CHANGED
data/lib/shippy.rb
CHANGED
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.
|
4
|
+
version: 0.1.5
|
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-
|
11
|
+
date: 2023-04-17 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/
|
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
|