mimas 0.3.0 → 0.4.0

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: ea7a87706ea7f9976b782cb891e446b813c7c866e2a4907f451565e670d194a5
4
- data.tar.gz: adde800fcc3df657cc512cfd14b9fe1ef314e3d4f19f903c68259c3d7394ef28
3
+ metadata.gz: 89a173c94a94713193d4a7c75a56b3aea832ac73d414fece78c19b4a331e4065
4
+ data.tar.gz: 5cba822934db35c755f15109611c970c9e417309df4888f17a6ec1fc0a485634
5
5
  SHA512:
6
- metadata.gz: 984c764fc02feeb671c63f33528258abb8ad271811400d27affe7e220fd4eb6d66652b57a3b829fa1bf972aa23a6a2d5fbb42fe6bc7ec290cf1c1155fc352654
7
- data.tar.gz: 939fa01df07457e75ecb9b2929757edfa0045cb109ec7f7b33366566397af491aca94df1f4a00125f99bd119ab05fc8cc4b318f3cb6c21e0bdabbc03a1853619
6
+ metadata.gz: e8a56d19ff9fa37ed56e486b5cc6caedb172ce9b78e8b9232ef6706fa2ed2daef0bbde3ab5721aee683e3f8a2ed0aef09a8fb60c5449085712aeab2751d9cb90
7
+ data.tar.gz: 1a02a80c18fb91f212052d6cbe68bf6b418328e5597611ed95659d34df4bf780558bf05d60ebc642fc2a7f79d86767e1a73aee65e8e72b1a65d8266d9fcc4e19
@@ -5,8 +5,8 @@ module Mimas
5
5
  class Archiver
6
6
  DEFAULT_OUTPUT_PATH = Pathname.new(Dir.pwd).join("tmp")
7
7
 
8
- def initialize(root:, output_path: DEFAULT_OUTPUT_PATH, output_file:, archive_root: nil, glob: nil, files: [])
9
- @root = root || Dir.pwd
8
+ def initialize(root: Dir.pwd, output_path: DEFAULT_OUTPUT_PATH, output_file:, archive_root: nil, glob: nil, files: [])
9
+ @root = root
10
10
  @output = Pathname.new(output_path).join(output_file)
11
11
  @archive_root = archive_root || ""
12
12
  @glob = glob
data/lib/mimas/cli.rb CHANGED
@@ -3,15 +3,18 @@ module Mimas
3
3
  module Commands
4
4
  extend Dry::CLI::Registry
5
5
 
6
- register "init", Init
7
- register "install ruby", Install
8
- register "provision", Provision
9
- register "push", Push
10
- register "console", Console
11
- register "archive", Archive
12
- register "setup caddy", Setup::Caddy
13
- register "setup deploy_user", Setup::DeployUser
14
- register "setup ruby", Setup::Ruby
6
+ register "init", Init
7
+ register "install ruby", Install
8
+ register "provision", Provision
9
+ register "push", Push, aliases: ["deploy"]
10
+ register "console", Console
11
+ register "archive", Archive
12
+
13
+ register "setup" do |setup|
14
+ setup.register "caddy", Setup::Caddy
15
+ setup.register "deploy_user", Setup::DeployUser
16
+ setup.register "ruby", Setup::Ruby
17
+ end
15
18
  end
16
19
 
17
20
  Plugins.fetch.each do |plugin|
@@ -2,9 +2,9 @@ module Mimas
2
2
  module CLI
3
3
  module Commands
4
4
  class Archive < BaseCommand
5
- desc "Create your site's archive which will be uploaded to the server"
5
+ desc "Create your site's archive which will be uploaded to the server, in a `tmp` folder. Use this to inspect what will be uploaded."
6
6
 
7
- argument :site, desc: "The name of the site to archive"
7
+ argument :site, desc: "The name of the site to archive."
8
8
 
9
9
  def call(site: :default)
10
10
  site = Config.current.sites[site.to_sym]
@@ -4,10 +4,10 @@ module Mimas
4
4
  class Console < BaseCommand
5
5
  desc "Run your app's console"
6
6
 
7
- argument :server_name, required: true, desc: "The name of the server to run the console on"
8
- argument :site, desc: "The site to run the console for. Uses the default site if unspecified"
7
+ argument :server_name, required: true, desc: "The name of the server to run the console on"
8
+ argument :site, default: :default, desc: "The site to run the console for. Uses the default site if unspecified"
9
9
 
10
- def call(server_name:, site: :default)
10
+ def call(server_name:, site:, **)
11
11
  server = Config.current.servers[server_name.to_sym]
12
12
  site = Config.current.sites[site.to_sym]
13
13
 
@@ -40,9 +40,12 @@ module Mimas
40
40
  server.install_caddy(sudo_user: sudo_user)
41
41
 
42
42
  unless skip_ruby
43
- server.install_ruby_prerequisites(sudo_user: sudo_user)
43
+ server.install_server_software(sudo_user: sudo_user)
44
44
  server.install_ruby
45
45
  end
46
+
47
+ say ""
48
+ say "Your server is provisioned and ready to serve websites."
46
49
  end
47
50
  end
48
51
  end
@@ -5,17 +5,24 @@ module Mimas
5
5
  desc "Push your Ruby app to the server"
6
6
 
7
7
  argument :server_name, required: true, desc: "The name of the server to push to"
8
- argument :site, desc: "The site to push. Uses the default site if unspecified"
8
+ argument :site, default: :default, desc: "The site to push. Uses the default site if unspecified"
9
9
 
10
10
  example [
11
11
  "production # Push the default site to the production server",
12
12
  "production app # Push the `:app` site to the production server"
13
13
  ]
14
14
 
15
- def call(server_name:, site: :default)
15
+ def call(server_name:, site:, **)
16
16
  server = Config.current.servers[server_name.to_sym]
17
17
  site = Config.current.sites[site.to_sym]
18
18
 
19
+ unless server && site
20
+ say "Server or site not found. Please ensure you've invoked the command correctly.".red
21
+ say ""
22
+ puts Dry::CLI::Banner.call(self, "mimas push")
23
+ exit 1
24
+ end
25
+
19
26
  working_copy = `git status --porcelain`
20
27
  unless working_copy == ""
21
28
  confirm = ask "You have modified files in your working copy, would you like to continue with deployment? (y|n)"
@@ -2,13 +2,13 @@ module Mimas
2
2
  module CLI
3
3
  module Commands
4
4
  class Setup::Ruby < Setup
5
- desc "Install Ruby prerequisites and build a Ruby binary on a server"
5
+ desc "Install server prerequisites and download a pre-built Ruby binary on a server"
6
6
 
7
7
  def call(server_name:, **options)
8
8
  server = Config.current.servers[server_name.to_sym]
9
9
  sudo_user = options[:user]
10
10
 
11
- server.install_ruby_prerequisites(sudo_user: sudo_user)
11
+ server.install_server_software(sudo_user: sudo_user)
12
12
  server.install_ruby
13
13
  end
14
14
  end
@@ -33,7 +33,7 @@ module Mimas
33
33
 
34
34
  say "Running deploy script"
35
35
  session.upload StringIO.new(site.deploy), deploy_script_path
36
- session.run "cd #{remote_destination} && /usr/bin/env bash -l #{deploy_script}"
36
+ session.run "cd #{remote_destination} && ~/.cargo/bin/rv run sh #{deploy_script}"
37
37
  session.run "rm #{deploy_script_path}"
38
38
 
39
39
  say "Setting current symlink"
@@ -21,7 +21,7 @@ module Mimas
21
21
  deploy_ruby_app
22
22
  end
23
23
  ensure
24
- File.delete(archive_path)
24
+ File.delete(archive_path) if archive_path
25
25
  end
26
26
  end
27
27
  end
@@ -2,18 +2,17 @@
2
2
 
3
3
  set -e
4
4
 
5
- cat << STRING >> ~/.profile
5
+ # Install RV
6
+ curl -LsSf https://rv.dev/install | sh
6
7
 
7
- # Use chruby to auto-switch Ruby versions
8
- source /usr/local/share/chruby/chruby.sh
9
- source /usr/local/share/chruby/auto.sh
10
- STRING
11
-
12
- source /usr/local/share/chruby/chruby.sh
13
- source /usr/local/share/chruby/auto.sh
8
+ echo 'eval "$(~/.cargo/bin/rv shell init bash)"' >> ~/.profile
9
+ echo 'eval "$(~/.cargo/bin/rv shell completions bash)"' >> ~/.profile
14
10
 
15
11
  echo 'gem: --no-document' >> ~/.gemrc
16
12
 
17
- gem update --system
18
- gem install bundler
19
- bundle config set --global without 'development test'
13
+ mkdir -p ~/.bundle/
14
+ cat << STRING > ~/.bundle/config
15
+ ---
16
+ BUNDLE_WITHOUT: "development:test"
17
+ BUNDLE_FROZEN: "true"
18
+ STRING
@@ -8,7 +8,7 @@ module Mimas
8
8
  Net::SSH.start(host, user) do |session|
9
9
  session.open_channel do |channel|
10
10
  channel.request_pty do
11
- channel.exec("cd #{current_path(site)} && /bin/bash -lc #{console_command}") do
11
+ channel.exec("cd #{current_path(site)} && ~/.cargo/bin/rv run #{console_command}") do
12
12
  channel.on_data do |_, data|
13
13
  $stdout.print(data) if data
14
14
  end
@@ -1,35 +1,27 @@
1
1
  module Mimas
2
2
  class Server
3
3
  module Ruby
4
- def install_ruby_prerequisites(sudo_user:)
4
+ def install_server_software(sudo_user:)
5
5
  ssh(self, user: sudo_user) do |session|
6
- prerequisites = Prerequisites.for_ruby + Prerequisites.utilities
7
- prerequisites = prerequisites.join(" ")
6
+ software_list = Software.utilities + Software.prerequisites
7
+ software_list = software_list.join(" ")
8
8
 
9
- session.script("install_ruby_prerequisites",
10
- sudo: true,
11
- vars: { PREREQUISITES: "'#{prerequisites}'" }
12
- )
9
+ session.run "sudo apt-get install #{software_list} -y"
13
10
  end
14
11
  end
15
12
 
16
13
  def install_ruby(version: Config.current.ruby_version)
17
14
  ssh(self) do |session|
18
- current_ruby = session.run "/usr/bin/env bash -lc 'which ruby'", capture: true, silent: true
19
-
20
- if current_ruby != ""
21
- ruby_grep = session.run "/usr/bin/env bash -lc 'chruby' | grep #{version}", capture: true, silent: true
22
- if ruby_grep.size > 0
23
- return say "Ruby #{version} is already installed!"
24
- end
15
+ begin
16
+ session.run "test -d ~/.rubies/ruby-*"
17
+ rescue SSH::Session::NonZeroExitCode
18
+ # Install `rv` for fresh installs
19
+ session.script "configure_ruby"
25
20
  end
26
21
 
27
- session.run "ruby-install --no-install-deps --cleanup #{version} -- --enable-yjit --with-jemalloc --disable-install-rdoc"
22
+ session.run "~/.cargo/bin/rv ruby install #{version} -i ~/.rubies"
28
23
  session.run "echo '#{version}' > ~/.ruby-version"
29
-
30
- if current_ruby == ""
31
- session.script("configure_ruby")
32
- end
24
+ session.run "~/.cargo/bin/rv run gem update --system"
33
25
  end
34
26
  end
35
27
  end
@@ -0,0 +1,21 @@
1
+ module Mimas
2
+ class Server
3
+ module Software
4
+ extend self
5
+
6
+ PREREQUISITES = %w[build-essential libyaml-dev libssl-dev libjemalloc-dev]
7
+ private_constant :PREREQUISITES
8
+
9
+ def prerequisites
10
+ MUTEX.synchronize { @prerequisites ||= PREREQUISITES }
11
+ end
12
+
13
+ UTILITIES = %w[curl jq]
14
+ private_constant :UTILITIES
15
+
16
+ def utilities
17
+ MUTEX.synchronize { @utilities ||= UTILITIES }
18
+ end
19
+ end
20
+ end
21
+ end
data/lib/mimas/server.rb CHANGED
@@ -5,6 +5,8 @@ module Mimas
5
5
  # Server setup helpers
6
6
  include Harden, DeployUser, Ruby, Caddy
7
7
 
8
+ include Console
9
+
8
10
  attr_reader :name, :host, :user, :ssh_options
9
11
 
10
12
  def initialize(name, args)
@@ -1,3 +1,4 @@
1
1
  MIMAS_UNIX_SOCKET=<%= unix_socket %>
2
2
  RUBY_YJIT_ENABLE=1
3
+ LD_PRELOAD=/usr/lib/x86_64-linux-gnu/libjemalloc.so
3
4
  <%= env %>
@@ -9,7 +9,7 @@ User=<%= user %>
9
9
  EnvironmentFile=<%= site_root %>/.env
10
10
  EnvironmentFile=<%= site_root %>/mimas/mimas.env
11
11
  WorkingDirectory=<%= site_root %>/current
12
- ExecStart=/usr/bin/env bash -lc '<%= command %>'
12
+ ExecStart=%h/.cargo/bin/rv run <%= command %>
13
13
  StandardOutput=append:<%= site_root %>/logs/<%= service_name %>.log
14
14
  StandardError=append:<%= site_root %>/logs/<%= service_name %>.log
15
15
  KillMode=mixed
data/lib/mimas/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Mimas
2
- VERSION = "0.3.0"
2
+ VERSION = "0.4.0"
3
3
  end
data/lib/mimas.rb CHANGED
@@ -19,11 +19,12 @@ require_relative "mimas/config"
19
19
  require_relative "mimas/site/archive"
20
20
  require_relative "mimas/site"
21
21
 
22
- require_relative "mimas/server/prerequisites"
22
+ require_relative "mimas/server/software"
23
23
  require_relative "mimas/server/harden"
24
24
  require_relative "mimas/server/deploy_user"
25
25
  require_relative "mimas/server/caddy"
26
26
  require_relative "mimas/server/ruby"
27
+ require_relative "mimas/server/console"
27
28
  require_relative "mimas/server"
28
29
 
29
30
  require_relative "mimas/deployment/caddy"
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mimas
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ayush Newatia
8
8
  bindir: bin
9
9
  cert_chain: []
10
- date: 2026-07-30 00:00:00.000000000 Z
10
+ date: 1980-01-02 00:00:00.000000000 Z
11
11
  dependencies:
12
12
  - !ruby/object:Gem::Dependency
13
13
  name: dry-cli
@@ -127,14 +127,13 @@ files:
127
127
  - lib/mimas/scripts/create_deploy_user.sh
128
128
  - lib/mimas/scripts/harden.sh
129
129
  - lib/mimas/scripts/install_caddy.sh
130
- - lib/mimas/scripts/install_ruby_prerequisites.sh
131
130
  - lib/mimas/server.rb
132
131
  - lib/mimas/server/caddy.rb
133
132
  - lib/mimas/server/console.rb
134
133
  - lib/mimas/server/deploy_user.rb
135
134
  - lib/mimas/server/harden.rb
136
- - lib/mimas/server/prerequisites.rb
137
135
  - lib/mimas/server/ruby.rb
136
+ - lib/mimas/server/software.rb
138
137
  - lib/mimas/site.rb
139
138
  - lib/mimas/site/archive.rb
140
139
  - lib/mimas/ssh.rb
@@ -168,7 +167,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
168
167
  - !ruby/object:Gem::Version
169
168
  version: '0'
170
169
  requirements: []
171
- rubygems_version: 3.6.2
170
+ rubygems_version: 4.0.18
172
171
  specification_version: 4
173
172
  summary: Deploy Ruby apps to a single server using an omakase setup
174
173
  test_files: []
@@ -1,26 +0,0 @@
1
- #!/usr/bin/env bash
2
-
3
- set -euo pipefail
4
- export DEBIAN_FRONTEND=noninteractive
5
-
6
- # Install Ruby prerequisites
7
- sudo apt-get install $PREREQUISITES -y
8
-
9
- # Install Ruby Install
10
- wget https://github.com/postmodern/ruby-install/releases/download/v0.10.2/ruby-install-0.10.2.tar.gz
11
- tar -xzvf ruby-install-0.10.2.tar.gz
12
- cd ruby-install-0.10.2/
13
- sudo make install
14
- cd ..
15
- rm ruby-install-0.10.2.tar.gz
16
- rm -rf ruby-install-0.10.2/
17
-
18
- # Install chruby
19
- wget https://github.com/postmodern/chruby/releases/download/v0.3.9/chruby-0.3.9.tar.gz
20
- tar -xzvf chruby-0.3.9.tar.gz
21
- cd chruby-0.3.9/
22
- sudo make install
23
- cd ..
24
- rm chruby-0.3.9.tar.gz
25
- rm -rf chruby-0.3.9/
26
-
@@ -1,25 +0,0 @@
1
- module Mimas
2
- class Server
3
- module Prerequisites
4
- extend self
5
-
6
- def for_ruby
7
- %w[
8
- xz-utils
9
- build-essential
10
- zlib1g-dev
11
- libyaml-dev
12
- libssl-dev
13
- libncurses-dev
14
- libffi-dev
15
- rustc
16
- libjemalloc-dev
17
- ]
18
- end
19
-
20
- def utilities
21
- %w[curl jq]
22
- end
23
- end
24
- end
25
- end