fly.io-rails 0.1.19 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Rakefile +1 -161
- data/lib/fly.io-rails/scanner.rb +4 -0
- data/lib/fly.io-rails/version.rb +1 -1
- data/lib/generators/templates/Dockerfile.erb +18 -4
- metadata +3 -5
- data/exe/flyctl +0 -44
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7d44b178e905d455c46dd7b537b594327b4d42c851c7c64fc84683de3f66f8e5
|
4
|
+
data.tar.gz: a8370f586bb8f7fff41794d51b270c2d4d62ba2ad4f849621ed1ff76339d67a2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8dfbe824f8a4a8c2b04e9bfaab4257490dc110063240edbd9aba1cc3480978fdd1170c362fcda0ea2dae960c4237a53627f98255088a385d4ff7cb9db5d47b9e
|
7
|
+
data.tar.gz: ada5cac909a279a0aef6d00161690522c306fa1c2b3046fa408645ead53833cdc16364a692bf7055b92797b873b66bc7781f7a09af1d573fa0b2583f0884246f
|
data/Rakefile
CHANGED
@@ -1,163 +1,3 @@
|
|
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
1
|
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
2
|
|
66
|
-
|
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
|
-
|
159
|
-
namespace :gem do
|
160
|
-
task :push do
|
161
|
-
sh 'for i in pkg/*.gem; do gem push $i; done'
|
162
|
-
end
|
163
|
-
end
|
3
|
+
# Run `rake release` to release a new version of the gem.
|
data/lib/fly.io-rails/scanner.rb
CHANGED
@@ -19,6 +19,10 @@ module Fly
|
|
19
19
|
@anycable = gemfile.include? 'anycable'
|
20
20
|
@rmagick = gemfile.include? 'rmagick'
|
21
21
|
@bootstrap = gemfile.include? 'bootstrap'
|
22
|
+
@puppeteer = gemfile.include? 'puppeteer'
|
23
|
+
|
24
|
+
package_json = IO.read('package.json') rescue ''
|
25
|
+
@puppeteer ||= package_json.include? 'puppeteer'
|
22
26
|
|
23
27
|
@cable = ! Dir['app/channels/*.rb'].empty?
|
24
28
|
|
data/lib/fly.io-rails/version.rb
CHANGED
@@ -51,7 +51,13 @@ RUN mkdir -p tmp/pids
|
|
51
51
|
RUN curl https://get.volta.sh | bash
|
52
52
|
ENV VOLTA_HOME /root/.volta
|
53
53
|
ENV PATH $VOLTA_HOME/bin:/usr/local/bin:$PATH
|
54
|
-
RUN volta install node@${NODE_VERSION} yarn@${YARN_VERSION}
|
54
|
+
RUN volta install node@${NODE_VERSION} yarn@${YARN_VERSION} && \
|
55
|
+
gem update --system --no-document && \
|
56
|
+
gem install -N bundler -v ${BUNDLER_VERSION}
|
57
|
+
|
58
|
+
<% else -%>
|
59
|
+
RUN gem update --system --no-document && \
|
60
|
+
gem install -N bundler -v ${BUNDLER_VERSION}
|
55
61
|
|
56
62
|
<% end -%>
|
57
63
|
#######################################################################
|
@@ -82,9 +88,6 @@ RUN --mount=type=cache,id=dev-apt-cache,sharing=locked,target=/var/cache/apt \
|
|
82
88
|
|
83
89
|
FROM build_deps as gems
|
84
90
|
|
85
|
-
RUN gem update --system --no-document && \
|
86
|
-
gem install -N bundler -v ${BUNDLER_VERSION}
|
87
|
-
|
88
91
|
COPY Gemfile* ./
|
89
92
|
RUN bundle install && rm -rf vendor/bundle/ruby/*/cache
|
90
93
|
|
@@ -95,6 +98,10 @@ RUN bundle install && rm -rf vendor/bundle/ruby/*/cache
|
|
95
98
|
|
96
99
|
FROM build_deps as node_modules
|
97
100
|
|
101
|
+
<% if @puppeteer -%>
|
102
|
+
ENV PUPPETEER_SKIP_CHROMIUM_DOWNLOAD true
|
103
|
+
|
104
|
+
<% end -%>
|
98
105
|
COPY package*json ./
|
99
106
|
<% if @yarn -%>
|
100
107
|
COPY yarn.* ./
|
@@ -132,6 +139,12 @@ RUN apt-get install -y dirmngr gnupg apt-transport-https ca-certificates curl &&
|
|
132
139
|
gpg --dearmor > /etc/apt/trusted.gpg.d/phusion.gpg && \
|
133
140
|
sh -c 'echo deb https://oss-binaries.phusionpassenger.com/apt/passenger bullseye main > /etc/apt/sources.list.d/passenger.list'
|
134
141
|
|
142
|
+
<% end -%>
|
143
|
+
<% if @puppeteer -%>
|
144
|
+
# add google chrome repository
|
145
|
+
RUN wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add - \
|
146
|
+
&& echo "deb http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google-chrome.list
|
147
|
+
|
135
148
|
<% end -%>
|
136
149
|
<%
|
137
150
|
@deploy_packages = %w(file vim curl gzip)
|
@@ -139,6 +152,7 @@ RUN apt-get install -y dirmngr gnupg apt-transport-https ca-certificates curl &&
|
|
139
152
|
@deploy_packages << 'postgresql-client' if @postgresql
|
140
153
|
@deploy_packages << 'libsqlite3-0' if @sqlite3
|
141
154
|
@deploy_packages << 'default-mysql-client' if @mysql
|
155
|
+
@deploy_packages << 'google-chrome-stable' if @puppeteer
|
142
156
|
@deploy_packages << 'imagemagick' if @rmagick
|
143
157
|
@deploy_packages << 'nodejs' if not @node and @bootstrap
|
144
158
|
@deploy_packages << 'fuse' if @litefs
|
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.1
|
4
|
+
version: 0.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sam Ruby
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-11-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: fly-ruby
|
@@ -54,15 +54,13 @@ dependencies:
|
|
54
54
|
version: '0'
|
55
55
|
description:
|
56
56
|
email: rubys@intertwingly.net
|
57
|
-
executables:
|
58
|
-
- flyctl
|
57
|
+
executables: []
|
59
58
|
extensions: []
|
60
59
|
extra_rdoc_files: []
|
61
60
|
files:
|
62
61
|
- LICENSE
|
63
62
|
- README.md
|
64
63
|
- Rakefile
|
65
|
-
- exe/flyctl
|
66
64
|
- lib/fly.io-rails.rb
|
67
65
|
- lib/fly.io-rails/actions.rb
|
68
66
|
- lib/fly.io-rails/dsl.rb
|
data/exe/flyctl
DELETED
@@ -1,44 +0,0 @@
|
|
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
|