fly.io-rails 0.0.19-arm64-darwin → 0.0.21-arm64-darwin

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: 840d8adfe7e5493983b7ac95dde1f35b5fd8fd6fdece36aa069bda5f3fef2f00
4
- data.tar.gz: f9ab0d5776cb9f48fe1c6e97405974ab59677917b0605073d126c1fb291ac3d7
3
+ metadata.gz: f173785bd8b4b709b0c35c2c339d576d42ad8874abf0e37237f12b0fa8dd153d
4
+ data.tar.gz: 924210805c7a4023087882c1645411bb61608f420ae8ade16941e637148aa0c2
5
5
  SHA512:
6
- metadata.gz: 891a801fe86a27b8b284ef605276e39fd7445a375c0adce471d73dc03dbec75ec52ed4794321f815359f8db31e71543ed3eb85ba37ef1a453cdb597c52462161
7
- data.tar.gz: 389f6f3063bdae204d68c67f06b0162df72854c640310835c700015ec04980fb4860e3ef42c017cebe05d8b83d013708977dce169b7df6b24486fd8740022e59
6
+ metadata.gz: 4dc311c231af69a08ed89182f7593501576c07b15f7e098250b103108a3f2909f0563fc16b3fe77803937ef504f0eee93854d7597505f6e4c1c0276183e88349
7
+ data.tar.gz: b56078f2ba98e8a8486043b518f2da121989590f9fd8672c2c216e32f4a2ad0c43689f8ff9216626f39be29501000f049bb5c2c1cc1bdb2681346dd9bb9dacdd
Binary file
@@ -0,0 +1,66 @@
1
+ require 'thor'
2
+ require 'active_support'
3
+ require 'active_support/core_ext/string/inflections'
4
+ require 'fly.io-rails/machines'
5
+
6
+ module Fly
7
+ class Actions < Thor::Group
8
+ include Thor::Actions
9
+ include Thor::Base
10
+ attr_accessor :options
11
+
12
+ def initialize(app = nil)
13
+ self.app = app if app
14
+
15
+ @ruby_version = RUBY_VERSION
16
+ @bundler_version = Bundler::VERSION
17
+ @node = File.exist? 'node_modules'
18
+ @yarn = File.exist? 'yarn.lock'
19
+ @node_version = @node ? `node --version`.chomp.sub(/^v/, '') : '16.17.0'
20
+ @org = Fly::Machines.org
21
+ @regions = []
22
+
23
+ @options = {}
24
+ @destination_stack = [Dir.pwd]
25
+ end
26
+
27
+ def app
28
+ return @app if @app
29
+ self.app = TOML.load_file('fly.toml')['app']
30
+ end
31
+
32
+ def app=(app)
33
+ @app = app
34
+ @appName = @app.gsub('-', '_').camelcase(:lower)
35
+ end
36
+
37
+ source_paths.push File::expand_path('../generators/templates', __dir__)
38
+
39
+ def generate_dockerfile
40
+ app
41
+ template 'Dockerfile.erb', 'Dockerfile'
42
+ end
43
+
44
+ def generate_dockerignore
45
+ app
46
+ template 'dockerignore.erb', '.dockerignore'
47
+ end
48
+
49
+ def generate_terraform
50
+ app
51
+ template 'main.tf.erb', 'main.tf'
52
+ end
53
+
54
+ def generate_raketask
55
+ app
56
+ template 'fly.rake.erb', 'lib/tasks/fly.rake'
57
+ end
58
+
59
+ def generate_all
60
+ generate_dockerfile
61
+ generate_dockerignore
62
+ generate_terraform
63
+ generate_raketask
64
+ end
65
+ end
66
+ end
@@ -28,11 +28,8 @@ module Fly
28
28
  end
29
29
  end
30
30
 
31
- # determine fly api hostname. Starts proxy if necessary
32
- def self.fly_api_hostname!
33
- hostname = fly_api_hostname
34
- return hostname if hostname
35
-
31
+ # determine application's organization
32
+ def self.org
36
33
  org = 'personal'
37
34
 
38
35
  if File.exist? 'fly.toml'
@@ -46,6 +43,14 @@ module Fly
46
43
  end
47
44
  end
48
45
 
46
+ org
47
+ end
48
+
49
+ # determine fly api hostname. Starts proxy if necessary
50
+ def self.fly_api_hostname!
51
+ hostname = fly_api_hostname
52
+ return hostname if hostname
53
+
49
54
  pid = fork { exec "flyctl machines api-proxy --org #{org}" }
50
55
  at_exit { Process.kill "INT", pid }
51
56
 
@@ -62,7 +67,7 @@ module Fly
62
67
  end
63
68
  end
64
69
 
65
- @@fy_api_hostname
70
+ @@fly_api_hostname
66
71
  end
67
72
 
68
73
  # create_fly_application app_name: 'user-functions', org_slug: 'personal'
@@ -1,3 +1,3 @@
1
1
  module Fly_io
2
- VERSION = '0.0.19'
2
+ VERSION = '0.0.21'
3
3
  end
@@ -2,11 +2,19 @@ terraform {
2
2
  required_providers {
3
3
  fly = {
4
4
  source = "fly-apps/fly"
5
- version = "0.0.10"
5
+ version = "0.0.18"
6
6
  }
7
7
  }
8
8
  }
9
9
 
10
+ /* uncomment if you want an internal tunnel
11
+ provider "fly" {
12
+ useinternaltunnel = true
13
+ internaltunnelorg = <%= (@org || "personal").inspect %>
14
+ internaltunnelregion = <%= (@regions.first || 'iad').inspect %>
15
+ }
16
+ */
17
+
10
18
  # Allocate an IPv4 address
11
19
  resource "fly_ip" "<%= @appName %>Ipv4" {
12
20
  app = <%= @app.inspect %>
@@ -1,4 +1,5 @@
1
1
  require 'open3'
2
+ require 'fly.io-rails/actions'
2
3
 
3
4
  class TerraformGenerator < Rails::Generators::Base
4
5
  include FlyIoRails::Utils
@@ -29,17 +30,8 @@ class TerraformGenerator < Rails::Generators::Base
29
30
  @regions = options[:regions].flatten
30
31
  end
31
32
 
32
- @ruby_version = RUBY_VERSION
33
- @bundler_version = Bundler::VERSION
34
- @node = File.exist? 'node_modules'
35
- @yarn = File.exist? 'yarn.lock'
36
- @node_version = @node ? `node --version`.chomp.sub(/^v/, '') : '16.17.0'
37
- @appName = @app.gsub('-', '_').camelcase(:lower)
38
-
39
- template 'Dockerfile.erb', 'Dockerfile'
40
- template 'dockerignore.erb', '.dockerignore'
41
- template 'main.tf.erb', 'main.tf'
42
- template 'fly.rake.erb', 'lib/tasks/fly.rake'
33
+ action = Fly::Actions.new(@app)
34
+ action.generate_all
43
35
 
44
36
  credentials = nil
45
37
  if File.exist? 'config/credentials/production.key'
@@ -58,4 +50,3 @@ class TerraformGenerator < Rails::Generators::Base
58
50
  tee 'terraform init'
59
51
  end
60
52
  end
61
-
data/lib/tasks/fly.rake CHANGED
@@ -46,6 +46,9 @@ namespace :fly do
46
46
  config[:env] ||= {}
47
47
  config[:env]['SERVER_COMMAND'] = 'bin/rails fly:release'
48
48
 
49
+ # start proxy, if necessary
50
+ endpoint = Fly::Machines::fly_api_hostname!
51
+
49
52
  # start release machine
50
53
  STDERR.puts "--> #{config[:env]['SERVER_COMMAND']}"
51
54
  start = Fly::Machines.create_start_machine(app, config: config)
@@ -75,6 +78,7 @@ namespace :fly do
75
78
 
76
79
  # use terraform apply to deploy
77
80
  ENV['FLY_API_TOKEN'] = `flyctl auth token`.chomp
81
+ ENV['FLY_HTTP_ENDPOINT'] = endpoint if endpoint
78
82
  system 'terraform apply -auto-approve'
79
83
  else
80
84
  STDERR.puts 'Error performing release'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fly.io-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.19
4
+ version: 0.0.21
5
5
  platform: arm64-darwin
6
6
  authors:
7
7
  - Sam Ruby
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-09-20 00:00:00.000000000 Z
11
+ date: 2022-09-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: fly-ruby
@@ -24,6 +24,20 @@ dependencies:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: toml
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
27
41
  description:
28
42
  email: rubys@intertwingly.net
29
43
  executables:
@@ -37,6 +51,7 @@ files:
37
51
  - exe/arm64-darwin/flyctl
38
52
  - exe/flyctl
39
53
  - lib/fly.io-rails.rb
54
+ - lib/fly.io-rails/actions.rb
40
55
  - lib/fly.io-rails/generators.rb
41
56
  - lib/fly.io-rails/hcl.rb
42
57
  - lib/fly.io-rails/machines.rb