mrsk 0.6.2 → 0.6.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: 0e810a4dc3e4a8e859440ab1902e51ada21f3267b5687efd3fb344d9d8d6af20
4
- data.tar.gz: 1fbef83c2a77a821b011d43c22243e34bf8f0b631011441532b369b3a175e7da
3
+ metadata.gz: 72714468cef4a41762f0da7a7a1af4b63a09181ae8ce73839b642ff0f91dd7ab
4
+ data.tar.gz: 147c1b2ca7bca7b0a5e91489b0cfa5d4efec52a9233978c50e5e4c3b6079b1d0
5
5
  SHA512:
6
- metadata.gz: 18b1110d168d3cb05daece74232d31dbca6008d68f041aa4d90dd56b48422ded2df552d133dd3c0bf6e5a19de297e9f6e0eb1c84190fc42b700a81940b7bb406
7
- data.tar.gz: 4c2f34570b9c3d193b874625afd8067aa271ee10556f0c756b8246d1cb93eec591b73ae7ae43eb3bc6713d24f14ee96e1b0e2c237ff0320ac75919e09132a792
6
+ metadata.gz: e69b26849eedbc5fe5a17870b7184e8f73bfa2ac9b8c802ceedfab9fd688427445422e1709037548b87d06478aae49e681a5250195b111ff4d6f3560c56db02e
7
+ data.tar.gz: dbbda93a73d43820ac11c184b5ce838eb95216f54fae27961fbd3e735066cc01906960da9759818a994b6d9629ef538319577e9c48d3cb1925c94cd09c33b1e4
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # MRSK
2
2
 
3
- MRSK deploys web apps in containers to servers running Docker with zero downtime. It uses the dynamic reverse-proxy Traefik to hold requests while the new application container is started and the old one is stopped. It works seamlessly across multiple hosts, using SSHKit to execute commands.
3
+ MRSK deploys web apps in containers to servers running Docker with zero downtime. It uses the dynamic reverse-proxy Traefik to hold requests while the new application container is started and the old one is stopped. It works seamlessly across multiple hosts, using SSHKit to execute commands. It was built for Rails applications, but works with any type of web app that can be bundled with Docker.
4
4
 
5
5
  ## Installation
6
6
 
@@ -43,6 +43,16 @@ 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
+ ## Vision
47
+
48
+ In the past decade+, there's been an explosion in commercial offerings that make deploying web apps easier. Heroku kicked it off with an incredible offering that stayed ahead of the competition seemingly forever. These days we have excellent alternatives like Fly.io and Render. And hosted Kubernetes is making things easier too on AWS, GCP, Digital Ocean, and elsewhere. But these are all offerings that have you renting computers in the cloud at a premium. If you want to run on our own hardware, or even just have a clear migration path to do so, you need to carefully consider how locked in you get to these commercial platforms. Preferably before the bills swallow your business whole!
49
+
50
+ MRSK seeks to bring the advance in ergonomics pioneered by these commercial offerings to deploying web apps anywhere. Whether that's low-cost cloud options without the managed-service markup from the likes of Digital Ocean, Hetzner, OVH, etc, or it's your own colocated metal. To MRSK, it's all the same. Feed the config file a list of IP addresses with vanilla Ubuntu servers that have seen no prep beyond an added SSH key, and you'll be running in literally minutes.
51
+
52
+ This structure also gives you enormous portability. You can have your web app deployed on several clouds at ease like this. Or you can buy the baseline with your own hardware, then deploy to a cloud before a big seasonal spike to get more capacity. When you're not locked into a single provider from a tooling perspective, there's a lot of compelling options available.
53
+
54
+ Ultimately, MRSK is meant to compress the complexity of going to production using open source tooling that isn't tied to any commercial offering. Not to zero, though. You're probably still better off with a fully managed service if basic Linux or Docker is still difficult, but from an early stage when those concepts are familiar.
55
+
46
56
  ## Why not just run Capistrano, Kubernetes or Docker Swarm?
47
57
 
48
58
  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.
@@ -253,11 +263,11 @@ This build secret can then be referenced in the Dockerfile:
253
263
  # Copy Gemfiles
254
264
  COPY Gemfile Gemfile.lock ./
255
265
 
256
- # Install dependencies, including private repositories via access token (then remove git configs with exposed GITHUB_TOKEN)
266
+ # Install dependencies, including private repositories via access token (then remove bundle cache with exposed GITHUB_TOKEN)
257
267
  RUN --mount=type=secret,id=GITHUB_TOKEN \
258
268
  BUNDLE_GITHUB__COM=x-access-token:$(cat /run/secrets/GITHUB_TOKEN) \
259
269
  bundle install && \
260
- find /usr/local/bundle/cache/bundler/git -name "config" -delete
270
+ rm -rf /usr/local/bundle/cache
261
271
  ```
262
272
 
263
273
  ### Using command arguments for Traefik
@@ -266,12 +276,13 @@ You can customize the traefik command line:
266
276
 
267
277
  ```yaml
268
278
  traefik:
269
- accesslog: true
270
- accesslog.format: json
271
- metrics.prometheus: true
272
- metrics.prometheus.buckets: 0.1,0.3,1.2,5.0
279
+ args:
280
+ accesslog: true
281
+ accesslog.format: json
273
282
  ```
274
283
 
284
+ This will start the traefik container with `--accesslog=true accesslog.format=json`.
285
+
275
286
  ### Configuring build args for new images
276
287
 
277
288
  Build arguments that aren't secret can also be configured:
data/lib/mrsk/cli/main.rb CHANGED
@@ -107,10 +107,14 @@ class Mrsk::Cli::Main < Mrsk::Cli::Base
107
107
  desc "envify", "Create .env by evaluating .env.erb (or .env.staging.erb -> .env.staging when using -d staging)"
108
108
  def envify
109
109
  if destination = options[:destination]
110
- File.write(".env.#{destination}", ERB.new(IO.read(Pathname.new(File.expand_path(".env.#{destination}.erb")))).result)
110
+ env_template_path = ".env.#{destination}.erb"
111
+ env_path = ".env.#{destination}"
111
112
  else
112
- File.write(".env", ERB.new(IO.read(Pathname.new(File.expand_path(".env.erb")))).result)
113
+ env_template_path = ".env.erb"
114
+ env_path = ".env"
113
115
  end
116
+
117
+ File.write(env_path, ERB.new(File.read(env_template_path)).result, perm: 0600)
114
118
  end
115
119
 
116
120
  desc "remove", "Remove Traefik, app, and registry session from servers"
@@ -5,19 +5,27 @@ class Mrsk::Commands::Builder::Base < Mrsk::Commands::Base
5
5
  docker :pull, config.absolute_image
6
6
  end
7
7
 
8
- def build_args
9
- argumentize "--build-arg", args, redacted: true
8
+ def build_options
9
+ [ *build_tags, *build_labels, *build_args, *build_secrets ]
10
10
  end
11
11
 
12
- def build_secrets
13
- argumentize "--secret", secrets.collect { |secret| [ "id", secret ] }
14
- end
12
+ private
13
+ def build_tags
14
+ [ "-t", config.absolute_image, "-t", config.latest_image ]
15
+ end
15
16
 
16
- def build_tags
17
- [ "-t", config.absolute_image, "-t", config.latest_image ]
18
- end
17
+ def build_labels
18
+ argumentize "--label", { service: config.service }
19
+ end
20
+
21
+ def build_args
22
+ argumentize "--build-arg", args, redacted: true
23
+ end
24
+
25
+ def build_secrets
26
+ argumentize "--secret", secrets.collect { |secret| [ "id", secret ] }
27
+ end
19
28
 
20
- private
21
29
  def args
22
30
  (config.builder && config.builder["args"]) || {}
23
31
  end
@@ -12,9 +12,7 @@ class Mrsk::Commands::Builder::Multiarch < Mrsk::Commands::Builder::Base
12
12
  "--push",
13
13
  "--platform", "linux/amd64,linux/arm64",
14
14
  "--builder", builder_name,
15
- *build_tags,
16
- *build_args,
17
- *build_secrets,
15
+ *build_options,
18
16
  "."
19
17
  end
20
18
 
@@ -16,9 +16,7 @@ class Mrsk::Commands::Builder::Native::Remote < Mrsk::Commands::Builder::Native
16
16
  "--push",
17
17
  "--platform", platform,
18
18
  "--builder", builder_name,
19
- *build_tags,
20
- *build_args,
21
- *build_secrets,
19
+ *build_options,
22
20
  "."
23
21
  end
24
22
 
@@ -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, *build_tags, *build_args, *build_secrets, "."),
12
+ docker(:build, *build_options, "."),
13
13
  docker(:push, config.absolute_image)
14
14
  end
15
15
 
@@ -6,11 +6,10 @@ class Mrsk::Commands::Prune < Mrsk::Commands::Base
6
6
  PRUNE_CONTAINERS_AFTER = 3.days.in_hours.to_i
7
7
 
8
8
  def images
9
- docker :image, :prune, "-f", "--filter", "until=#{PRUNE_IMAGES_AFTER}h"
9
+ docker :image, :prune, "--all", "--force", "--filter", "label=service=#{config.service}", "--filter", "until=#{PRUNE_IMAGES_AFTER}h"
10
10
  end
11
11
 
12
12
  def containers
13
- docker :image, :prune, "-f", "--filter", "until=#{PRUNE_IMAGES_AFTER}h"
14
- docker :container, :prune, "-f", "--filter", "label=service=#{config.service}", "--filter", "'until=#{PRUNE_CONTAINERS_AFTER}h'"
13
+ docker :container, :prune, "--force", "--filter", "label=service=#{config.service}", "--filter", "until=#{PRUNE_CONTAINERS_AFTER}h"
15
14
  end
16
15
  end
data/lib/mrsk/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Mrsk
2
- VERSION = "0.6.2"
2
+ VERSION = "0.6.4"
3
3
  end
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.2
4
+ version: 0.6.4
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-09 00:00:00.000000000 Z
11
+ date: 2023-02-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport