mrsk 0.6.0 → 0.6.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +8 -5
- data/lib/mrsk/cli/app.rb +3 -6
- data/lib/mrsk/commander.rb +14 -2
- data/lib/mrsk/commands/accessory.rb +1 -0
- data/lib/mrsk/commands/app.rb +1 -0
- data/lib/mrsk/commands/base.rb +2 -0
- data/lib/mrsk/commands/builder/base.rb +4 -0
- data/lib/mrsk/commands/builder/multiarch.rb +1 -1
- data/lib/mrsk/commands/builder/native/remote.rb +1 -1
- data/lib/mrsk/commands/builder/native.rb +1 -1
- data/lib/mrsk/commands/prune.rb +2 -2
- data/lib/mrsk/commands/traefik.rb +2 -1
- data/lib/mrsk/configuration.rb +4 -0
- data/lib/mrsk/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0e810a4dc3e4a8e859440ab1902e51ada21f3267b5687efd3fb344d9d8d6af20
|
4
|
+
data.tar.gz: 1fbef83c2a77a821b011d43c22243e34bf8f0b631011441532b369b3a175e7da
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 18b1110d168d3cb05daece74232d31dbca6008d68f041aa4d90dd56b48422ded2df552d133dd3c0bf6e5a19de297e9f6e0eb1c84190fc42b700a81940b7bb406
|
7
|
+
data.tar.gz: 4c2f34570b9c3d193b874625afd8067aa271ee10556f0c756b8246d1cb93eec591b73ae7ae43eb3bc6713d24f14ee96e1b0e2c237ff0320ac75919e09132a792
|
data/README.md
CHANGED
@@ -43,11 +43,13 @@ This will:
|
|
43
43
|
|
44
44
|
Voila! All the servers are now serving the app on port 80. If you're just running a single server, you're ready to go. If you're running multiple servers, you need to put a load balancer in front of them.
|
45
45
|
|
46
|
-
## Why not just run Capistrano or
|
46
|
+
## Why not just run Capistrano, Kubernetes or Docker Swarm?
|
47
47
|
|
48
48
|
MRSK basically is Capistrano for Containers, which allow us to use vanilla servers as the hosts. No need to ensure that the servers have just the right version of Ruby or other dependencies you need. That all lives in the Docker image now. You can boot a brand new Ubuntu (or whatever) server, add it to the deploy servers of MRSK, and it'll be auto-provisioned with Docker, and run right away. Docker's layer caching also allows for quicker deployments with less mucking about on the server. And the images built for MRSK can be used for CI or later introspection.
|
49
49
|
|
50
|
-
Kubernetes is a beast. Running it yourself on your own hardware is not for the faint of heart. It's a fine option if you want to run on someone else's platform, like Render or
|
50
|
+
Kubernetes is a beast. Running it yourself on your own hardware is not for the faint of heart. It's a fine option if you want to run on someone else's platform, either transparently [like Render](https://thenewstack.io/render-cloud-deployment-with-less-engineering/) or explicitly on AWS/GCP, but if you'd like the freedom to move between cloud and your own hardware, or even mix the two, MRSK is much simpler. You can see everything that's going on, it's just basic Docker commands being called.
|
51
|
+
|
52
|
+
Docker Swarm is much simpler than Kubernetes, but it's still built on the same declarative model that uses state reconciliation. MRSK is intentionally designed to around imperative commands, like Capistrano.
|
51
53
|
|
52
54
|
## Configuration
|
53
55
|
|
@@ -247,14 +249,15 @@ builder:
|
|
247
249
|
|
248
250
|
This build secret can then be referenced in the Dockerfile:
|
249
251
|
|
250
|
-
```
|
252
|
+
```dockerfile
|
251
253
|
# Copy Gemfiles
|
252
254
|
COPY Gemfile Gemfile.lock ./
|
253
255
|
|
254
|
-
# Install dependencies, including private repositories via access token
|
256
|
+
# Install dependencies, including private repositories via access token (then remove git configs with exposed GITHUB_TOKEN)
|
255
257
|
RUN --mount=type=secret,id=GITHUB_TOKEN \
|
256
258
|
BUNDLE_GITHUB__COM=x-access-token:$(cat /run/secrets/GITHUB_TOKEN) \
|
257
|
-
bundle install
|
259
|
+
bundle install && \
|
260
|
+
find /usr/local/bundle/cache/bundler/git -name "config" -delete
|
258
261
|
```
|
259
262
|
|
260
263
|
### Using command arguments for Traefik
|
data/lib/mrsk/cli/app.rb
CHANGED
@@ -1,11 +1,6 @@
|
|
1
1
|
class Mrsk::Cli::App < Mrsk::Cli::Base
|
2
2
|
desc "boot", "Boot app on servers (or reboot app if already running)"
|
3
3
|
def boot
|
4
|
-
cli = self
|
5
|
-
|
6
|
-
say "Ensure no other version of the app is running...", :magenta
|
7
|
-
stop
|
8
|
-
|
9
4
|
say "Get most recent version available as an image...", :magenta unless options[:version]
|
10
5
|
using_version(options[:version] || most_recent_version_available) do |version|
|
11
6
|
say "Start container with version #{version} (or reboot if already running)...", :magenta
|
@@ -15,12 +10,14 @@ class Mrsk::Cli::App < Mrsk::Cli::Base
|
|
15
10
|
execute *MRSK.auditor.record("app boot version #{version}"), verbosity: :debug
|
16
11
|
|
17
12
|
begin
|
13
|
+
execute *MRSK.app.stop, raise_on_non_zero_exit: false
|
18
14
|
execute *MRSK.app.run(role: role.name)
|
19
15
|
rescue SSHKit::Command::Failed => e
|
20
16
|
if e.message =~ /already in use/
|
21
17
|
error "Rebooting container with same version already deployed on #{host}"
|
18
|
+
execute *MRSK.auditor.record("app rebooted with version #{version}"), verbosity: :debug
|
22
19
|
|
23
|
-
|
20
|
+
execute *MRSK.app.remove_container(version: version)
|
24
21
|
execute *MRSK.app.run(role: role.name)
|
25
22
|
else
|
26
23
|
raise
|
data/lib/mrsk/commander.rb
CHANGED
@@ -75,10 +75,14 @@ class Mrsk::Commander
|
|
75
75
|
|
76
76
|
|
77
77
|
def with_verbosity(level)
|
78
|
-
old_level =
|
78
|
+
old_level = self.verbosity
|
79
|
+
|
80
|
+
self.verbosity = level
|
79
81
|
SSHKit.config.output_verbosity = level
|
82
|
+
|
80
83
|
yield
|
81
84
|
ensure
|
85
|
+
self.verbosity = old_level
|
82
86
|
SSHKit.config.output_verbosity = old_level
|
83
87
|
end
|
84
88
|
|
@@ -91,7 +95,15 @@ class Mrsk::Commander
|
|
91
95
|
|
92
96
|
private
|
93
97
|
def cascading_version
|
94
|
-
version.presence || ENV["VERSION"] ||
|
98
|
+
version.presence || ENV["VERSION"] || current_commit_hash
|
99
|
+
end
|
100
|
+
|
101
|
+
def current_commit_hash
|
102
|
+
if system("git rev-parse")
|
103
|
+
`git rev-parse HEAD`.strip
|
104
|
+
else
|
105
|
+
raise "Can't use commit hash as version, no git repository found in #{Dir.pwd}"
|
106
|
+
end
|
95
107
|
end
|
96
108
|
|
97
109
|
# Lazy setup of SSHKit
|
data/lib/mrsk/commands/app.rb
CHANGED
data/lib/mrsk/commands/base.rb
CHANGED
@@ -13,6 +13,10 @@ class Mrsk::Commands::Builder::Base < Mrsk::Commands::Base
|
|
13
13
|
argumentize "--secret", secrets.collect { |secret| [ "id", secret ] }
|
14
14
|
end
|
15
15
|
|
16
|
+
def build_tags
|
17
|
+
[ "-t", config.absolute_image, "-t", config.latest_image ]
|
18
|
+
end
|
19
|
+
|
16
20
|
private
|
17
21
|
def args
|
18
22
|
(config.builder && config.builder["args"]) || {}
|
@@ -9,7 +9,7 @@ class Mrsk::Commands::Builder::Native < Mrsk::Commands::Builder::Base
|
|
9
9
|
|
10
10
|
def push
|
11
11
|
combine \
|
12
|
-
docker(:build,
|
12
|
+
docker(:build, *build_tags, *build_args, *build_secrets, "."),
|
13
13
|
docker(:push, config.absolute_image)
|
14
14
|
end
|
15
15
|
|
data/lib/mrsk/commands/prune.rb
CHANGED
@@ -2,8 +2,8 @@ require "active_support/duration"
|
|
2
2
|
require "active_support/core_ext/numeric/time"
|
3
3
|
|
4
4
|
class Mrsk::Commands::Prune < Mrsk::Commands::Base
|
5
|
-
PRUNE_IMAGES_AFTER =
|
6
|
-
PRUNE_CONTAINERS_AFTER =
|
5
|
+
PRUNE_IMAGES_AFTER = 7.days.in_hours.to_i
|
6
|
+
PRUNE_CONTAINERS_AFTER = 3.days.in_hours.to_i
|
7
7
|
|
8
8
|
def images
|
9
9
|
docker :image, :prune, "-f", "--filter", "until=#{PRUNE_IMAGES_AFTER}h"
|
@@ -2,7 +2,8 @@ class Mrsk::Commands::Traefik < Mrsk::Commands::Base
|
|
2
2
|
def run
|
3
3
|
docker :run, "--name traefik",
|
4
4
|
"-d",
|
5
|
-
"--restart unless-stopped",
|
5
|
+
"--restart", "unless-stopped",
|
6
|
+
"--log-opt", "max-size=#{MAX_LOG_SIZE}",
|
6
7
|
"-p 80:80",
|
7
8
|
"-v /var/run/docker.sock:/var/run/docker.sock",
|
8
9
|
"traefik",
|
data/lib/mrsk/configuration.rb
CHANGED
data/lib/mrsk/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mrsk
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.6.
|
4
|
+
version: 0.6.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- David Heinemeier Hansson
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-02-
|
11
|
+
date: 2023-02-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -146,5 +146,5 @@ requirements: []
|
|
146
146
|
rubygems_version: 3.4.6
|
147
147
|
signing_key:
|
148
148
|
specification_version: 4
|
149
|
-
summary: Deploy
|
149
|
+
summary: Deploy web apps in containers to servers running Docker with zero downtime.
|
150
150
|
test_files: []
|