shippy 0.2.7 → 0.2.8

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: 8a2298a6d94f32d0806671b2a6bac47a04cfeb628b40e4c7d265c9212de2a9a5
4
- data.tar.gz: 6afec3af342b493695d3afdb34a7f4bf6c1ab839393e595c123005fb9e3a6d93
3
+ metadata.gz: 1fe36006872a9b130eecbfa26b391a3a645dafaced62917c530ac9510944abd8
4
+ data.tar.gz: a8c0268d4cdb6c776600a21038eeb5de722c7601a770a8f33630bb8b414f0fc6
5
5
  SHA512:
6
- metadata.gz: ec171c742bd1808a0647b2c5a017d4db62ed26e6e0c832844fc2438b966eb5cf5bb5474b958f7cc92f8f91e127f4ee60fe5df31ee3489a1e28404d5b685961b8
7
- data.tar.gz: 46c255b01d31766abd742c1321d1316abdfa8ad73fef2862c803420ffe25f535e3621c98c7e60d294770eb25b3d6f0b54d54d02f213702321d0de4cfe1d75136
6
+ metadata.gz: 7b70994648b3f4c7c842460b335faf0f9a70ae62fff47a3236bcf145d052d45a189c05bddf72cbc1be14ce692f854366df846b925fa248a7ca841c65354a7340
7
+ data.tar.gz: abd35fa707247d73707c3c41ec15e5f65cb46d01a386aa48a7c003f92640b341ccb3cfd229224e03c759dcdf064cf2cfd960663bc0af79c085ea866897a51dd5
data/README.md CHANGED
@@ -1,44 +1,33 @@
1
- # Shippy
1
+ # 🚢 Shippy
2
2
 
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/).
3
+ Shippy is a lightweight container orchestration tool designed specifically for homelabs. It combines the simplicity of Docker Compose with a powerful Ruby DSL, inspired by the deployment workflows of Capistrano and Kamal.
4
4
 
5
5
  ## Features
6
6
 
7
7
  - Ruby DSL to generate the docker-compose YAML files
8
8
  - Centralized source to define secrets
9
9
  - Uses Traefik as a reverse proxy with SSL wildcard support
10
+ - Manage the entire lab with a local `bin/shippy` command.
10
11
 
11
- ## Installation
12
+ ## 🚀 Getting Started
12
13
 
13
- Install the gem and add to the application's Gemfile by executing:
14
-
15
- ```shell
16
- $ bundle add shippy
17
- ```
18
-
19
- Or
14
+ Install the gem:
20
15
 
21
16
  ```shell
22
17
  $ gem install shippy
23
18
  ```
24
19
 
25
- ## Usage
26
-
27
20
  In you homelab directory execute:
28
21
 
29
22
  ```shell
30
- homelab$ bundle exec shippy init
31
- ```
32
-
33
- Or
34
-
35
- ```shell
23
+ home$ mkdir homelab && cd homelab
36
24
  homelab$ shippy init
37
25
  ```
38
26
 
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`.
27
+ This creates the core structure:
28
+ - `apps/`: Where your service definitions live.
29
+ - `config/`: Shippy configuration and secrets.
30
+ - `bin/shippy`: Your local entry point for all commands.
42
31
 
43
32
  ### Docker compose DSL:
44
33
 
@@ -55,7 +44,7 @@ Example:
55
44
  ```ruby
56
45
  Shippy.define do
57
46
  service :proxy do
58
- image { "traefik:v2.9" }
47
+ image { "traefik:v3.6" }
59
48
  command { "--configFile=/config/config.yml" }
60
49
 
61
50
  environment do
@@ -71,17 +60,22 @@ Shippy.define do
71
60
 
72
61
  volumes do
73
62
  [
74
- "/var/run/docker.sock:/var/run/docker.sock",
63
+ "/var/run/docker.sock:/var/run/docker.sock:ro",
75
64
  "./traefik:/config",
76
65
  "acme:/etc/traefik/acme"
77
66
  ]
78
67
  end
79
68
 
80
- use_default_options
69
+ use_default_options # Automatically handles networks, logging, and restart policies
81
70
  end
82
71
  end
72
+
83
73
  ```
84
74
 
75
+ By running `bin/shippy deploy proxy` the DSL gets converted to YAML and deployed on the server.
76
+
77
+ See the examples directory for more options.
78
+
85
79
  ## Development
86
80
 
87
81
  After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
@@ -57,8 +57,40 @@ class Shippy::Cli::App < Shippy::Cli::Base
57
57
  desc "compile", "Compile application"
58
58
  def compile
59
59
  say "Compiling #{app_name}...", :magenta
60
- # Load app config and pass to builder
61
60
  app_config = Shippy::Repo.load_app(app_name)
62
61
  Shippy::Builder.new(app_config).compile
63
62
  end
63
+
64
+ desc "rollback", "Rollback to a previous release"
65
+ method_option :step, aliases: "-n", type: :numeric, default: 1, desc: "Releases to go back"
66
+ def rollback
67
+ steps = options[:step]
68
+
69
+ backups = @remote_app.list_backups
70
+ if backups.empty?
71
+ error "No backups found."
72
+ exit(1)
73
+ end
74
+
75
+ target_index = steps - 1
76
+ if target_index < 0 || target_index >= backups.length
77
+ error "Cannot rollback #{steps} steps. Only #{backups.length} backups available."
78
+ exit(1)
79
+ end
80
+
81
+ target_ts = backups[target_index]
82
+ say "Rolling back #{steps} step(s) to: #{target_ts}", :yellow
83
+
84
+ @docker.compose_down(@remote_app.current_path)
85
+
86
+ say "Restoring files...", :blue
87
+ @remote_app.restore_backup(target_ts)
88
+
89
+ say "Starting restored application...", :green
90
+ app_config = Shippy::Repo.load_app(app_name)
91
+ @docker.compose_up(@remote_app.current_path, flags: app_config&.deploy_flags)
92
+ rescue => e
93
+ error "Rollback failed: #{e.message}"
94
+ exit(1)
95
+ end
64
96
  end
@@ -11,12 +11,12 @@ Shippy.define do
11
11
  end
12
12
 
13
13
  ports do
14
- ["80:80", "443:443", "8080:8080"]
14
+ ["80:80", "443:443"]
15
15
  end
16
16
 
17
17
  volumes do
18
18
  [
19
- "/var/run/docker.sock:/var/run/docker.sock",
19
+ "/var/run/docker.sock:/var/run/docker.sock:ro",
20
20
  "./traefik:/config",
21
21
  "acme:/etc/traefik/acme"
22
22
  ]
@@ -4,10 +4,6 @@ providers:
4
4
  file:
5
5
  filename: "/config/dynamic_config.yml"
6
6
 
7
- api:
8
- insecure: true
9
- dashboard: true
10
-
11
7
  entryPoints:
12
8
  web:
13
9
  address: ":80"
@@ -63,6 +63,36 @@ module Shippy
63
63
  end
64
64
  end
65
65
 
66
+ def list_backups
67
+ base = backups_path
68
+ data = []
69
+
70
+ on(@host) do
71
+ if test("[ -d #{base} ]")
72
+ data = capture(:ls, "-1r", base).split
73
+ end
74
+ end
75
+
76
+ data
77
+ end
78
+
79
+ def restore_backup(target_ts)
80
+ backup_source = backups_path.join(target_ts, @app_name)
81
+ target = current_path
82
+
83
+ on(@host) do
84
+ unless test("[ -d #{backup_source} ]")
85
+ raise "Backup directory #{backup_source} does not exist"
86
+ end
87
+ end
88
+
89
+ backup_current_release
90
+
91
+ on(@host) do
92
+ execute :mv, backup_source, target
93
+ end
94
+ end
95
+
66
96
  def current_path
67
97
  SHIPPY.deploy_path.join("apps", @app_name)
68
98
  end
@@ -33,7 +33,11 @@ module Shippy
33
33
  @config.read
34
34
  else
35
35
  "# Add your secrets here. They will be encrypted on save.\n" \
36
- "# keys: values\n"
36
+ "# proxy:\n" \
37
+ "# cloudflare_token: value\n" \
38
+ "# cloudflare_email: name@example.com\n" \
39
+ "# other_service:\n" \
40
+ "# value: secret\n"
37
41
  end
38
42
 
39
43
  Tempfile.create(["secrets", ".yml"]) do |tmp_file|
@@ -1,3 +1,3 @@
1
1
  module Shippy
2
- VERSION = "0.2.7"
2
+ VERSION = "0.2.8"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: shippy
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.7
4
+ version: 0.2.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Marius Bobin