fly.io-rails 0.0.1-x64-mingw32

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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: d04c1833679c8a3759c8f566c78117ee25032f8d3646dc9763193228637189f6
4
+ data.tar.gz: f75740f51563fab4e39f5d63d1196a438200df57bd4be7cc70af1d8c247f8556
5
+ SHA512:
6
+ metadata.gz: cfc366488d47248c1bba97e360ccebb25420b8f52065798bc14f90b27331925c1027a7c68a64872a8607ebba9b485221b134831c522f5cc81c831bdb9b4b86dd
7
+ data.tar.gz: 441d3d2c03ae6a42bcc26f05aa79cfec1f875f58c9a7b030edb699e35e1ad48c7b3f760bf66ea4ea59c51c96f2836d1afc776a9be7bc02289ccca38190a1bd17
data/LICENSE ADDED
@@ -0,0 +1,202 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright [yyyy] [name of copyright owner]
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
data/README.md ADDED
@@ -0,0 +1,189 @@
1
+ ## Purpose
2
+
3
+ Add [Fly.io](https://fly.io) support to [Rails](https://rubyonrails.org/).
4
+
5
+ ## Status
6
+
7
+ <u>pre-alpha</u>.
8
+
9
+ In fact, the gem has not been yet been pushed to the rubygems
10
+ repository as while creating a github repository is an easily reversible act,
11
+ wiping all memory of a mis-named gem is considerably more challenging.
12
+
13
+ It currently is possible to build the gem files, install the prerequisite
14
+ `ruby-fly` gem, and then install the platform specific gem using `--local`.
15
+ You can also add the gem to your Gemfile using the `path:` argument to the
16
+ `gem` statement/method call. Of course, all of this will be taken care of
17
+ for you once this gem has been published.
18
+
19
+ ## Quickstart/summary
20
+
21
+ ```sh
22
+ rails new demo
23
+ cd demo
24
+ bundle add fly.io-rails
25
+ flyctl auth login
26
+ bin/rails fly:launch
27
+ bin/rails deploy
28
+ ```
29
+
30
+ ## Build instructions
31
+
32
+ ```
33
+ rake package
34
+ ```
35
+
36
+ This will involve downloading binaries from github and building gems for
37
+ every supported platform as well as an additional gem that doesn't
38
+ include a binary.
39
+
40
+ To download new binaries, run `rake clobber` then `rake package` agein.
41
+
42
+ ## Description
43
+
44
+ - `bundle add fly.io-rails`
45
+
46
+ This will install `ruby-fly` middleware, add new Rails tasks, extend the
47
+ channel and job generatotors, and platform binaries for
48
+ [flyctl](https://github.com/superfly/flyctl#readme). I've followed the
49
+ trail blazed by [nokogiri](https://nokogiri.org/) and others to make
50
+ platform binaries happen.
51
+
52
+ - `bin/rails fly:launch`
53
+
54
+ This won't be a mere front enty to [`flyctl
55
+ launch`](https://fly.io/docs/flyctl/launch/). It will use
56
+ [`thor`](https://github.com/rails/thor#thor) to rewrite the configuration
57
+ for the `production` environment as well as tweak the `Dockerfile` and
58
+ `fly.toml` based on your application - in particular the configuration for
59
+ ActiveRecord, ActiveJob, and ActionCable. The people at Fly will know what
60
+ databases and message queing systems work best on their platform and should
61
+ make it easy to do the right thing.
62
+
63
+ As an example, the default production database for a new application in
64
+ Rails is sqlite3. Either this will need to be replaced by Postgre in
65
+ the Rails configuration *or* a volume will need to be defined, mounted,
66
+ and the Rails configuration modified to point to the new mount point.
67
+
68
+ This gem should pick one of those paths as the default, and provide an option to chose other paths.
69
+
70
+ - `bin/rails generate channel`, `bin/rails generate job`, etc.
71
+
72
+ Rails applications are generally not invented fully formed. They evolve and
73
+ add features. I don't want people to think about having to configure rails
74
+ AND configure fly when then add features. Generators that developers
75
+ already use today should be able to update both the Rails and Fly
76
+ configurations in a consistent manner.
77
+
78
+ For now, both the Rails tasks and generators don't actually modify the Rails
79
+ configuratio to support Fly, instead they merely output the string `Configuring
80
+ fly...`. Let your imagination run wild.
81
+
82
+ ## Motivation
83
+
84
+ Oversimplifying and exagerating to make a point, `flyctl launch` generates an
85
+ initial fly configuration based on the state of the application at launch time
86
+ but leaves configuring your Rails application up to you. The initial Fly
87
+ configuration may need to be tweaked, and both the fly and Rails configurations
88
+ will need to be maintained as the application evolves.
89
+
90
+ From a Rails developer perspective, this makes fly an additional framework that
91
+ must be learned and attended to.
92
+
93
+ This can all be changed with a single `bundle add` command. Everything from
94
+ new `rails` tasks to extending the behavior of existing generators to making
95
+ changes to configuration to monkeypatching Rails internals itself are on the
96
+ table.
97
+
98
+ A few sublte but important mindset changes are necessary to pull this off:
99
+
100
+ * Instead of "we support every (or perhaps even only 'most') Rails
101
+ configuration" the mindset we should strive for is "we provide a default
102
+ production configuration that works for most, and provide options to add or
103
+ replace components as desired".
104
+
105
+ We should be bold and daring. We should chose a default web server, a
106
+ default database, a default active job queue adapter, a default action
107
+ cable subscription adapter, etc., etc., etc.
108
+
109
+ Over time, this should encompas everything needed for monitoring and
110
+ deployment. Requirements for things like log file management should be
111
+ anticipated and accounted for.
112
+
113
+ * Any configuration artifact that is generated and needs to be checked into
114
+ the application's source control repository needs to be [beautiful
115
+ code](https://rubyonrails.org/doctrine#beautiful-code). If you look at
116
+ configuration files provided by either `rails new` or by rails generators,
117
+ they have comments. They don't configure things that don't apply to you.
118
+
119
+ A concrete example: Rails 7 applications default to import maps. A
120
+ `Dockerfile` generated for such an app should not contain code that deals
121
+ with `yarn` or `node_modules`.
122
+
123
+ And as a closing remark - to be fair adding Rails support to Fly and adding Fly
124
+ support to Rails are more complementary than competing efforts.
125
+
126
+ ## Future
127
+
128
+ > Que sera, sera
129
+
130
+ -- Doris Day
131
+
132
+ I don't know what the future is going to hold, but some guesses:
133
+
134
+ * It is plausible that a code base written in Ruby and with access to
135
+ libraries like [Thos](http://whatisthor.com/) and focused exclusively on
136
+ Rails may attract more contributions from the Rails community than a
137
+ codebase written in Go and targetting many disparate frameworks.
138
+ * Flyctl launch can continue to provide a basic Fly configuration for Rails,
139
+ but if this effort is successful these configurations would largely be
140
+ replaced by more tailors configurations that are updated by generators and
141
+ rake tasks as the application evolves.
142
+ * Not every flyctl command needs to have a Rails wrapper -- only the common
143
+ task do. It is quiet OK for developers to deal directly with fly when it
144
+ makes sence to do so. But those flyctl command that are wrapped may need
145
+ options added that enable them to be run without the need to prompt the
146
+ user.
147
+ * This gem could be built and published alongside the flyctl executables, and
148
+ `flyctl version update` could detect whether or not it was installed as a
149
+ gem and react appropriately.
150
+
151
+ ## Call to Action
152
+
153
+ > good ideas and bad code build communities, the other three combinations do
154
+ > not
155
+
156
+ -- Stefano Mazzocchi
157
+
158
+ > the best way to get the right answer on the internet is not to ask a
159
+ > question; it's to post the wrong answer.
160
+
161
+ -- Ward Cunningham
162
+
163
+ I don't presume that any specific line of code in this initial implementation
164
+ will last the test of time. Heck, I'm not even confident enough in the
165
+ proposed name to register the gem, though the name does feel *rails-like* -
166
+ just take a look at any Rails `Gemfile` to see.
167
+
168
+ My hope is that there is enough scaffolding here to not only make clear what
169
+ the possibilities are, but also enough structure so that it is fairly obvious
170
+ where new logic should go, together there is not only enough promise and
171
+ structure to attract a community.
172
+
173
+ Some starter ideas:
174
+
175
+ * Can we make `bin/rails deploy` smart enough to invoke `flyctl auth login` if
176
+ you are not logged in and `bin/rails fly:launch` if the application had not
177
+ previously been launched, with the goal of reducing the number of commands a
178
+ user has to issue to get started. Also I'm impressed by the way auth login
179
+ launches a browser, can we do the same for fly launch?
180
+
181
+ * While a number of application configuration changes are made through
182
+ generators, not all are. For example, upgrading the version of Ruby to be
183
+ used. Perhaps we could create tasks for some of these, but likely it will
184
+ be worthwhile to create a `fly:reconfig` task.
185
+
186
+ Finally, once this repository is in the superfly github organization and
187
+ a gem has been published, this README should be rewritten from focus on
188
+ raison d'être and to a focus on what value it would bring to those that
189
+ install and use it.
data/Rakefile ADDED
@@ -0,0 +1,158 @@
1
+ # coding: utf-8
2
+ #
3
+ # Rake tasks to manage native gem packages with flyctl binary executables from github
4
+ #
5
+ # TL;DR: run "rake package"
6
+ #
7
+ # The native platform gems (defined by Fly_io::PLATFORMS)
8
+ # will each contain two files in addition to what the vanilla ruby gem contains:
9
+ #
10
+ # exe/
11
+ # ├── flyctl # generic ruby script to find and run the binary
12
+ # └── <Gem::Platform architecture name>/
13
+ # └── flyctl # the flyctl binary executable
14
+ #
15
+ # The ruby script `exe/flyctl` is installed into the user's path, and it simply locates the
16
+ # binary and executes it. Note that this script is required because rubygems requires that
17
+ # executables declared in a gemspec must be Ruby scripts.
18
+ #
19
+ # As a concrete example, an x86_64-linux system will see these files on disk after installing
20
+ # fly.io-rails-1.x.x-x86_64-linux.gem:
21
+ #
22
+ # exe/
23
+ # ├── flyctl
24
+ # └── x86_64-linux/
25
+ # └── flyctl
26
+ #
27
+ # So the full set of gem files created will be:
28
+ #
29
+ # - pkg/fly.io-rails-1.0.0.gem
30
+ # - pkg/fly.io-rails-1.0.0-arm64-darwin.gem
31
+ # - pkg/fly.io-rails-1.0.0-x64-mingw32.gem
32
+ # - pkg/fly.io-rails-1.0.0-x86_64-darwin.gem
33
+ # - pkg/fly.io-rails-1.0.0-x86_64-linux.gem
34
+ #
35
+ # Note that in addition to the native gems, a vanilla "ruby" gem will also be created without
36
+ # either the `exe/flyctl` script or a binary executable present.
37
+ #
38
+ #
39
+ # New rake tasks created:
40
+ #
41
+ # - rake gem:ruby # Build the ruby gem
42
+ # - rake gem:arm64-darwin # Build the arm64-darwin gem
43
+ # - rake gem:x64-mingw32 # Build the x64-mingw32 gem
44
+ # - rake gem:x86_64-darwin # Build the x86_64-darwin gem
45
+ # - rake gem:x86_64-linux # Build the x86_64-linux gem
46
+ # - rake download # Download all flyctl binaries
47
+ #
48
+ # Modified rake tasks:
49
+ #
50
+ # - rake gem # Build all the gem files
51
+ # - rake package # Build all the gem files (same as `gem`)
52
+ # - rake repackage # Force a rebuild of all the gem files
53
+ #
54
+ # Note also that the binary executables will be lazily downloaded when needed, but you can
55
+ # explicitly download them with the `rake download` command.
56
+ #
57
+ require "bundler/setup"
58
+ require "bundler/gem_tasks"
59
+ require "rubygems/package_task"
60
+ require 'net/http'
61
+ require 'json'
62
+ require 'stringio'
63
+ require 'zip'
64
+ require_relative 'lib/fly.io-rails/platforms'
65
+
66
+ task default: :package
67
+
68
+ FLY_IO_RAILS_GEMSPEC = Bundler.load_gemspec("fly.io-rails.gemspec")
69
+
70
+ gem_path = Gem::PackageTask.new(FLY_IO_RAILS_GEMSPEC).define
71
+ desc "Build the ruby gem"
72
+ task "gem:ruby" => [gem_path]
73
+
74
+ def fetch(uri, limit = 10)
75
+ raise ArgumentError, 'HTTP redirect too deep' unless limit > 0
76
+ response = Net::HTTP.get_response(URI(uri))
77
+
78
+ case response
79
+ when Net::HTTPSuccess
80
+ response.body
81
+ when Net::HTTPRedirection
82
+ fetch(response['location'], limit - 1)
83
+ else
84
+ STDERR.puts 'HTTP Error: ' + response.message.to_s
85
+ exit 1
86
+ end
87
+ end
88
+
89
+ exepaths = []
90
+ uri = 'https://api.github.com/repos/superfly/flyctl/releases/latest'
91
+ release = JSON.parse(fetch(uri))
92
+
93
+ release['assets'].each do |asset|
94
+ platform = Fly_io::PLATFORMS[asset['name'][/^flyctl_.*?_(.*?)\./, 1]]
95
+ next unless platform
96
+
97
+ FLY_IO_RAILS_GEMSPEC.dup.tap do |gemspec|
98
+ exedir = File.join(gemspec.bindir, platform) # "exe/x86_64-linux"
99
+ exepath = File.join(exedir, "flyctl") # "exe/x86_64-linux/flyctl"
100
+
101
+ if asset['name'] =~ /Windows/i
102
+ exepath += '.exe'
103
+ dll = File.join(exedir, 'wintun.dll')
104
+ gemspec.files << dll
105
+ file dll => exepath
106
+ end
107
+
108
+ exepaths << exepath
109
+ gemspec.files << exepath
110
+
111
+ # modify a copy of the gemspec to include the native executable
112
+ gemspec.platform = platform
113
+
114
+ # create a package task
115
+ gem_path = Gem::PackageTask.new(gemspec).define
116
+ desc "Build the #{platform} gem"
117
+ task "gem:#{platform}" => [gem_path]
118
+
119
+ directory exedir
120
+ file exepath => [exedir] do
121
+ release_url = asset['browser_download_url']
122
+ warn "Downloading #{release_url} ..."
123
+
124
+ case File.extname(asset['name'])
125
+ when '.gz'
126
+ Zlib::GzipReader.wrap(StringIO.new(fetch(release_url))) do |gz|
127
+ Gem::Package::TarReader.new(gz) do |tar|
128
+ tar.each do |entry|
129
+ exepath = File.join(exedir, entry.full_name)
130
+ File.open(exepath, "wb") do |local|
131
+ local.write(entry.read)
132
+ end
133
+ FileUtils.chmod(0755, exepath, verbose: true)
134
+ end
135
+ end
136
+ end
137
+ when '.zip'
138
+ Zip::File.open_buffer(fetch(release_url)) do |zip_file|
139
+ zip_file.each do |entry|
140
+ exepath = File.join(exedir, entry.name)
141
+ STDERR.puts exepath
142
+ File.open(exepath, "wb") do |local|
143
+ local.write(zip_file.read(entry.name))
144
+ end
145
+ end
146
+ end
147
+ end
148
+ end
149
+ end
150
+ end
151
+
152
+ desc "Download all flyctl binaries"
153
+ task download: exepaths
154
+
155
+ task package: :download
156
+
157
+ CLOBBER.add(exepaths.map { |path| File.dirname(path) })
158
+
data/exe/flyctl ADDED
@@ -0,0 +1,44 @@
1
+ #! /usr/bin/env ruby
2
+ # because rubygems shims assume a gem's executables are Ruby
3
+
4
+ require "fly.io-rails/platforms"
5
+
6
+ supported_platforms = Fly_io::PLATFORMS.values
7
+ platform = [:cpu, :os].map { |m| Gem::Platform.local.send(m) }.join("-")
8
+
9
+ if supported_platforms.none? { |supported_platform| Gem::Platform.match(supported_platform) }
10
+ STDERR.puts(<<~ERRMSG)
11
+ ERROR: flyctl does not support the #{platform} platform
12
+ ERRMSG
13
+ exit 1
14
+ end
15
+
16
+ exe_path = Dir.glob(File.join(__dir__, "*", "flyctl*")).find do |f|
17
+ Gem::Platform.match(File.basename(File.dirname(f)))
18
+ end
19
+ if exe_path.nil?
20
+ STDERR.puts(<<~ERRMSG)
21
+ ERROR: Cannot find the flyctl executable for #{platform} in #{__dir__}
22
+ If you're using bundler, please make sure you're on the latest bundler version:
23
+
24
+ gem install bundler
25
+ bundle update --bundler
26
+
27
+ Then make sure your lock file includes this platform by running:
28
+
29
+ bundle lock --add-platform #{platform}
30
+ bundle install
31
+
32
+ See `bundle lock --help` output for details.
33
+ ERRMSG
34
+ exit 1
35
+ end
36
+
37
+ if Gem.win_platform?
38
+ # use system rather than exec as exec inexplicably fails to find the executable
39
+ # on Windows
40
+ system exe_path, *ARGV
41
+ else
42
+ # use exec rather than system to avoid creating a new process
43
+ exec exe_path, *ARGV
44
+ end
Binary file
Binary file
@@ -0,0 +1,15 @@
1
+ require 'rails/generators'
2
+ require 'rails/generators/channel/channel_generator'
3
+ require 'rails/generators/job/job_generator'
4
+
5
+ class Rails::Generators::ChannelGenerator
6
+ def configure_fly
7
+ STDERR.puts 'Configuring fly...'
8
+ end
9
+ end
10
+
11
+ class Rails::Generators::JobGenerator
12
+ def configure_fly
13
+ STDERR.puts 'Configuring fly...'
14
+ end
15
+ end
@@ -0,0 +1,10 @@
1
+ module Fly_io
2
+ PLATFORMS = {
3
+ 'Linux_arm64' => 'aarch64-linux',
4
+ 'Linux_x86_64' => 'x86-linux',
5
+ 'macOS_arm64' => 'arm64-darwin',
6
+ 'macOS_x86_64' => 'x86_64-darwin',
7
+ 'Windows_arm64' => nil, # Can't find a match
8
+ 'Windows_x86_64' => 'x64-mingw32'
9
+ }
10
+ end
@@ -0,0 +1,3 @@
1
+ module Fly_io
2
+ VERSION = '0.0.1'
3
+ end
@@ -0,0 +1,10 @@
1
+ require 'rails'
2
+ require 'fly.io-rails/generators'
3
+
4
+ class FlyIoRailtie < Rails::Railtie
5
+ rake_tasks do
6
+ Dir[File.expand_path('tasks/*.rake', __dir__)].each do |file|
7
+ load file
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,26 @@
1
+ namespace :fly do
2
+ desc 'Launch a new app'
3
+ task :launch do
4
+ sh 'flyctl launch'
5
+
6
+ # note: Rake task argument syntax isn't particularly user friendy,
7
+ # but Rake is a Ruby program and we have full access to ARGV,
8
+ # meaning we can do our own thing with OptionParser or whatever.
9
+ # The only real caveat if we do so is that we need to exit the
10
+ # program at the completion of the task lest Rails tries to interpet
11
+ # the next argument as the name of the next task to execute.
12
+
13
+ Rake.rake_output_message 'Customizing Dockerfile...'
14
+
15
+ exit
16
+ end
17
+
18
+ desc 'Deploy fly application'
19
+ task :deploy do
20
+ sh 'flyctl deploy'
21
+ end
22
+ end
23
+
24
+ # Alias, for convenience
25
+ desc 'Deploy fly application'
26
+ task deploy: 'fly:deploy'
metadata ADDED
@@ -0,0 +1,69 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: fly.io-rails
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: x64-mingw32
6
+ authors:
7
+ - Sam Ruby
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2022-09-13 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: fly-ruby
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ description:
28
+ email: rubys@intertwingly.net
29
+ executables:
30
+ - flyctl
31
+ extensions: []
32
+ extra_rdoc_files: []
33
+ files:
34
+ - LICENSE
35
+ - README.md
36
+ - Rakefile
37
+ - exe/flyctl
38
+ - exe/x64-mingw32/flyctl.exe
39
+ - exe/x64-mingw32/wintun.dll
40
+ - lib/fly.io-rails.rb
41
+ - lib/fly.io-rails/generators.rb
42
+ - lib/fly.io-rails/platforms.rb
43
+ - lib/fly.io-rails/version.rb
44
+ - lib/tasks/fly.rake
45
+ homepage: https://github.com/rubys/fly-io.rails
46
+ licenses:
47
+ - Apache-2.0
48
+ metadata:
49
+ homepage_uri: https://github.com/rubys/fly-io.rails
50
+ post_install_message:
51
+ rdoc_options: []
52
+ require_paths:
53
+ - lib
54
+ required_ruby_version: !ruby/object:Gem::Requirement
55
+ requirements:
56
+ - - ">="
57
+ - !ruby/object:Gem::Version
58
+ version: '0'
59
+ required_rubygems_version: !ruby/object:Gem::Requirement
60
+ requirements:
61
+ - - ">="
62
+ - !ruby/object:Gem::Version
63
+ version: '0'
64
+ requirements: []
65
+ rubygems_version: 3.3.22
66
+ signing_key:
67
+ specification_version: 4
68
+ summary: Rails support for Fly-io
69
+ test_files: []