fly.io-rails 0.1.3-aarch64-linux → 0.1.4-aarch64-linux
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/fly.io-rails/actions.rb +26 -8
- data/lib/fly.io-rails/utils.rb +3 -1
- data/lib/fly.io-rails/version.rb +1 -1
- data/lib/generators/fly/app_generator.rb +7 -3
- data/lib/generators/fly/terraform_generator.rb +5 -3
- data/lib/generators/templates/Dockerfile.erb +35 -2
- data/lib/generators/templates/fly.rake.erb +2 -0
- data/lib/generators/templates/fly.toml.erb +11 -0
- data/lib/generators/templates/litefs.yml.erb +14 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 22b91ca60f3ae2c948b1ebae2ca41ca8f3d4b086506b879c1f895f00a974b9ca
|
4
|
+
data.tar.gz: 9de48ba6a2585299e327682b402883756836d4131202ae7ba6051ca5ac27d705
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4acc687e3cbaca4f6e125c27d11753b5d1e0c9f4476b2b41901aafaf465ece4f952d450478f84681dbd5e8e026a70ad674e93cc80e0b040aff548bf1923a4847
|
7
|
+
data.tar.gz: 34551d1ee07779d81cc7a3bd7d7c4b3316fc0fdb882d7aa167eca32048b5c4a55cab716f11c51efaccec35a300818de197c3b21dcfc4800ab3f5afca2f07d4e9
|
data/lib/fly.io-rails/actions.rb
CHANGED
@@ -16,8 +16,11 @@ module Fly
|
|
16
16
|
include Fly::Scanner
|
17
17
|
attr_accessor :options
|
18
18
|
|
19
|
-
def initialize(app,
|
19
|
+
def initialize(app, options={})
|
20
20
|
self.app = app
|
21
|
+
regions = options[:region].flatten || []
|
22
|
+
@litefs = options[:litefs]
|
23
|
+
@set_stage = options[:nomad] ? 'set' : 'set --stage'
|
21
24
|
|
22
25
|
@ruby_version = RUBY_VERSION
|
23
26
|
@bundler_version = Bundler::VERSION
|
@@ -37,6 +40,7 @@ module Fly
|
|
37
40
|
end
|
38
41
|
|
39
42
|
@region = @regions.first || 'iad'
|
43
|
+
@regions = [@region] if @regions.empty?
|
40
44
|
|
41
45
|
@config = Fly::DSL::Config.new
|
42
46
|
if File.exist? 'config/fly.rb'
|
@@ -87,6 +91,10 @@ module Fly
|
|
87
91
|
app_template 'fly.rake.erb', 'lib/tasks/fly.rake'
|
88
92
|
end
|
89
93
|
|
94
|
+
def generate_litefs
|
95
|
+
app_template 'litefs.yml.erb', 'config/litefs.yml'
|
96
|
+
end
|
97
|
+
|
90
98
|
def generate_key
|
91
99
|
credentials = nil
|
92
100
|
if File.exist? 'config/credentials/production.key'
|
@@ -96,8 +104,8 @@ module Fly
|
|
96
104
|
end
|
97
105
|
|
98
106
|
if credentials
|
99
|
-
say_status :run, "flyctl secrets
|
100
|
-
system "flyctl secrets
|
107
|
+
say_status :run, "flyctl secrets #{@set_stage} RAILS_MASTER_KEY from #{credentials}"
|
108
|
+
system "flyctl secrets #{@set_stage} RAILS_MASTER_KEY=#{IO.read(credentials).chomp}"
|
101
109
|
puts
|
102
110
|
end
|
103
111
|
|
@@ -126,9 +134,9 @@ module Fly
|
|
126
134
|
def create_volume(app, region, size)
|
127
135
|
volume = "#{app.gsub('-', '_')}_volume"
|
128
136
|
volumes = JSON.parse(`flyctl volumes list --json`).
|
129
|
-
map {|volume| volume['Name']}
|
137
|
+
map {|volume| [volume['Name'], volume['Region']]}
|
130
138
|
|
131
|
-
unless volumes.include? volume
|
139
|
+
unless volumes.include? [volume, region]
|
132
140
|
cmd = "flyctl volumes create #{volume} --app #{app} --region #{region} --size #{size}"
|
133
141
|
say_status :run, cmd
|
134
142
|
system cmd
|
@@ -204,7 +212,13 @@ module Fly
|
|
204
212
|
end
|
205
213
|
|
206
214
|
if @sqlite3
|
207
|
-
|
215
|
+
if @litefs
|
216
|
+
@regions.each do |region|
|
217
|
+
@volume = create_volume(app, region, @config.sqlite3.size)
|
218
|
+
end
|
219
|
+
else
|
220
|
+
@volume = create_volume(app, @region, @config.sqlite3.size)
|
221
|
+
end
|
208
222
|
elsif @postgresql and not secrets.include? 'DATABASE_URL'
|
209
223
|
secret = create_postgres(app, @org, @region,
|
210
224
|
@config.postgres.vm_size,
|
@@ -212,7 +226,7 @@ module Fly
|
|
212
226
|
@config.postgres.initial_cluster_size)
|
213
227
|
|
214
228
|
if secret
|
215
|
-
cmd = "flyctl secrets
|
229
|
+
cmd = "flyctl secrets #{@set_stage} DATABASE_URL=#{secret}"
|
216
230
|
say_status :run, cmd
|
217
231
|
system cmd
|
218
232
|
end
|
@@ -225,7 +239,7 @@ module Fly
|
|
225
239
|
secret = create_redis(app, @org, @region, eviction)
|
226
240
|
|
227
241
|
if secret
|
228
|
-
cmd = "flyctl secrets
|
242
|
+
cmd = "flyctl secrets #{@set_stage} REDIS_URL=#{secret}"
|
229
243
|
say_status :run, cmd
|
230
244
|
system cmd
|
231
245
|
end
|
@@ -293,6 +307,10 @@ module Fly
|
|
293
307
|
config[:env] = {
|
294
308
|
"DATABASE_URL" => "sqlite3:///mnt/volume/production.sqlite3"
|
295
309
|
}
|
310
|
+
|
311
|
+
if @litefs
|
312
|
+
config[:env]['DATABASE_URL'] = "sqlite3:///data/production.sqlite3"
|
313
|
+
end
|
296
314
|
end
|
297
315
|
|
298
316
|
# process toml overrides
|
data/lib/fly.io-rails/utils.rb
CHANGED
@@ -28,12 +28,14 @@ module FlyIoRails
|
|
28
28
|
data.join
|
29
29
|
end
|
30
30
|
|
31
|
-
def create_app(name
|
31
|
+
def create_app(name: nil, org: 'personal', regions: [], nomad: false, **rest)
|
32
32
|
cmd = if name
|
33
33
|
"flyctl apps create #{name.inspect} --org #{org.inspect} --machines"
|
34
34
|
else
|
35
35
|
"flyctl apps create --generate-name --org #{org.inspect} --machines"
|
36
36
|
end
|
37
|
+
|
38
|
+
cmd.sub! ' --machines', '' if nomad
|
37
39
|
|
38
40
|
output = tee cmd
|
39
41
|
exit 1 unless output =~ /^New app created: /
|
data/lib/fly.io-rails/version.rb
CHANGED
@@ -7,19 +7,23 @@ class AppGenerator < Rails::Generators::Base
|
|
7
7
|
class_option :name, type: :string, required: false
|
8
8
|
class_option :org, type: :string, default: 'personal'
|
9
9
|
class_option :region, type: :array, repeatable: true, default: []
|
10
|
+
class_option :nomad, type: :boolean, default: false
|
11
|
+
|
12
|
+
class_option :litefs, type: :boolean, default: false
|
10
13
|
|
11
14
|
def generate_app
|
12
15
|
source_paths.push File.expand_path('../templates', __dir__)
|
13
16
|
|
14
|
-
create_app(options
|
17
|
+
create_app(**options.symbolize_keys)
|
15
18
|
|
16
|
-
action = Fly::Actions.new(@app, options
|
19
|
+
action = Fly::Actions.new(@app, options)
|
17
20
|
|
18
21
|
action.generate_toml
|
19
22
|
action.generate_fly_config unless File.exist? 'config/fly.rb'
|
20
23
|
action.generate_dockerfile unless File.exist? 'Dockerfile'
|
21
24
|
action.generate_dockerignore unless File.exist? '.dockerignore'
|
22
25
|
action.generate_raketask unless File.exist? 'lib/tasks/fly.rake'
|
26
|
+
action.generate_litefs if options[:litefs] and not File.exist? 'config/litefs'
|
23
27
|
action.generate_patches
|
24
28
|
action.generate_ipv4
|
25
29
|
action.generate_ipv6
|
@@ -27,4 +31,4 @@ class AppGenerator < Rails::Generators::Base
|
|
27
31
|
action.launch(@app)
|
28
32
|
end
|
29
33
|
end
|
30
|
-
end
|
34
|
+
end
|
@@ -8,12 +8,14 @@ class TerraformGenerator < Rails::Generators::Base
|
|
8
8
|
class_option :org, type: :string, default: 'personal'
|
9
9
|
class_option :region, type: :array, repeatable: true, default: []
|
10
10
|
|
11
|
+
class_option :litefs, type: :boolean, default: false
|
12
|
+
|
11
13
|
def terraform
|
12
14
|
source_paths.push File.expand_path('../templates', __dir__)
|
13
15
|
|
14
|
-
create_app(options
|
16
|
+
create_app(**options.symbolize_keys)
|
15
17
|
|
16
|
-
action = Fly::Actions.new(@app, options
|
18
|
+
action = Fly::Actions.new(@app, options)
|
17
19
|
|
18
20
|
action.generate_toml
|
19
21
|
action.generate_dockerfile
|
@@ -27,4 +29,4 @@ class TerraformGenerator < Rails::Generators::Base
|
|
27
29
|
tee 'terraform init'
|
28
30
|
end
|
29
31
|
end
|
30
|
-
end
|
32
|
+
end
|
@@ -21,6 +21,8 @@ ARG RUBY_VERSION=<%= @ruby_version %>
|
|
21
21
|
ARG VARIANT=jemalloc-slim
|
22
22
|
FROM quay.io/evl.ms/fullstaq-ruby:${RUBY_VERSION}-${VARIANT} as base
|
23
23
|
|
24
|
+
LABEL fly_launch_runtime="rails"
|
25
|
+
|
24
26
|
<% if @node -%>
|
25
27
|
ARG NODE_VERSION=<%= @node_version %>
|
26
28
|
<% end -%>
|
@@ -54,7 +56,12 @@ RUN volta install node@${NODE_VERSION} yarn
|
|
54
56
|
|
55
57
|
FROM base as build_deps
|
56
58
|
|
57
|
-
|
59
|
+
<%
|
60
|
+
@build_packages = %w(git build-essential wget vim curl gzip xz-utils)
|
61
|
+
@build_packages << 'libpq-dev' if @postgresql
|
62
|
+
@build_packages << 'libsqlite3-dev' if @sqlite3
|
63
|
+
-%>
|
64
|
+
ARG BUILD_PACKAGES=<%= @build_packages.join(' ').inspect %>
|
58
65
|
ENV BUILD_PACKAGES ${BUILD_PACKAGES}
|
59
66
|
|
60
67
|
RUN --mount=type=cache,id=dev-apt-cache,sharing=locked,target=/var/cache/apt \
|
@@ -92,12 +99,24 @@ RUN npm install
|
|
92
99
|
|
93
100
|
<% end -%>
|
94
101
|
#######################################################################
|
102
|
+
<% if @litefs -%>
|
103
|
+
|
104
|
+
# Fetch the LiteFS binary
|
105
|
+
FROM flyio/litefs:pr-109 AS litefs
|
95
106
|
|
107
|
+
#######################################################################
|
108
|
+
<% end %>
|
96
109
|
# install deployment packages
|
97
110
|
|
98
111
|
FROM base
|
99
112
|
|
100
|
-
|
113
|
+
<%
|
114
|
+
@deploy_packages = %w(file vim curl gzip)
|
115
|
+
@deploy_packages << 'postgresql-client' if @postgresql
|
116
|
+
@deploy_packages << 'libsqlite3-0' if @sqlite3
|
117
|
+
@deploy_packages << 'fuse' if @litefs
|
118
|
+
-%>
|
119
|
+
ARG DEPLOY_PACKAGES=<%= @deploy_packages.join(' ').inspect %>
|
101
120
|
ENV DEPLOY_PACKAGES=${DEPLOY_PACKAGES}
|
102
121
|
|
103
122
|
RUN --mount=type=cache,id=prod-apt-cache,sharing=locked,target=/var/cache/apt \
|
@@ -116,6 +135,16 @@ COPY --from=gems /usr/local/bundle /usr/local/bundle
|
|
116
135
|
# copy installed node modules
|
117
136
|
COPY --from=node_modules /app/node_modules /app/node_modules
|
118
137
|
|
138
|
+
<% end -%>
|
139
|
+
<% if @litefs -%>
|
140
|
+
# copy litefs binary
|
141
|
+
COPY --from=litefs /usr/local/bin/litefs /usr/local/bin/litefs
|
142
|
+
|
143
|
+
# Copy our LiteFS configuration.
|
144
|
+
ADD config/litefs.yml /etc/litefs.yml
|
145
|
+
|
146
|
+
# Create mount point
|
147
|
+
RUN mkdir /data
|
119
148
|
<% end -%>
|
120
149
|
#######################################################################
|
121
150
|
|
@@ -140,6 +169,10 @@ RUN ${BUILD_COMMAND}
|
|
140
169
|
|
141
170
|
# Default server start instructions. Generally Overridden by fly.toml.
|
142
171
|
ENV PORT 8080
|
172
|
+
<% if @litefs -%>
|
173
|
+
ARG SERVER_COMMAND="litefs"
|
174
|
+
<% else -%>
|
143
175
|
ARG SERVER_COMMAND="bin/rails fly:server"
|
176
|
+
<% end -%>
|
144
177
|
ENV SERVER_COMMAND ${SERVER_COMMAND}
|
145
178
|
CMD ${SERVER_COMMAND}
|
@@ -6,6 +6,7 @@ namespace :fly do
|
|
6
6
|
# - Failures here prevent deployment
|
7
7
|
task :build => 'assets:precompile'
|
8
8
|
|
9
|
+
<% unless @litefs -%>
|
9
10
|
# RELEASE step:
|
10
11
|
# - changes to the filesystem made here are DISCARDED
|
11
12
|
# - full access to secrets, databases
|
@@ -16,6 +17,7 @@ namespace :fly do
|
|
16
17
|
task :release => 'db:migrate'
|
17
18
|
<%- end -%>
|
18
19
|
|
20
|
+
<% end -%>
|
19
21
|
# SERVER step:
|
20
22
|
# - changes to the filesystem made here are deployed
|
21
23
|
# - full access to secrets, databases
|
@@ -6,15 +6,23 @@ processes = []
|
|
6
6
|
[build]
|
7
7
|
[build.args]
|
8
8
|
BUILD_COMMAND = "bin/rails fly:build"
|
9
|
+
<% if @litefs -%>
|
10
|
+
SERVER_COMMAND = "litefs"
|
11
|
+
<% else -%>
|
9
12
|
SERVER_COMMAND = "bin/rails fly:server"
|
10
13
|
|
11
14
|
[deploy]
|
12
15
|
release_command = "bin/rails fly:release"
|
16
|
+
<% end -%>
|
13
17
|
|
14
18
|
[env]
|
15
19
|
PORT = "8080"
|
16
20
|
<% if @sqlite3 -%>
|
21
|
+
<% if @litefs -%>
|
22
|
+
DATABASE_URL = "sqlite3:///data/production.sqlite3"
|
23
|
+
<% else -%>
|
17
24
|
DATABASE_URL = "sqlite3:///mnt/volume/production.sqlite3"
|
25
|
+
<% end -%>
|
18
26
|
|
19
27
|
[mounts]
|
20
28
|
source = <%= "#{app.gsub('-', '_')}_volume".inspect %>
|
@@ -24,6 +32,9 @@ destination = "/mnt/volume"
|
|
24
32
|
[experimental]
|
25
33
|
allowed_public_ports = []
|
26
34
|
auto_rollback = true
|
35
|
+
<% if @litefs -%>
|
36
|
+
enable_consul = true
|
37
|
+
<% end -%>
|
27
38
|
|
28
39
|
[[services]]
|
29
40
|
http_checks = []
|
@@ -0,0 +1,14 @@
|
|
1
|
+
# The path to where the SQLite database will be accessed.
|
2
|
+
mount-dir: "/data"
|
3
|
+
|
4
|
+
# The path to where the underlying volume mount is.
|
5
|
+
data-dir: "/mnt/volume"
|
6
|
+
|
7
|
+
# Execute this subprocess once LiteFS connects to the cluster.
|
8
|
+
exec: "bin/rails fly:server"
|
9
|
+
|
10
|
+
# These environment variables will be available in your Fly.io application.
|
11
|
+
# You must specify "experiement.enable_consul" for FLY_CONSUL_URL to be available.
|
12
|
+
consul:
|
13
|
+
url: "${FLY_CONSUL_URL}"
|
14
|
+
advertise-url: "http://${HOSTNAME}.vm.${FLY_APP_NAME}.internal:20202"
|
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.1.4
|
5
5
|
platform: aarch64-linux
|
6
6
|
authors:
|
7
7
|
- Sam Ruby
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-09-
|
11
|
+
date: 2022-09-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: fly-ruby
|
@@ -67,6 +67,7 @@ files:
|
|
67
67
|
- lib/generators/templates/fly.rake.erb
|
68
68
|
- lib/generators/templates/fly.rb.erb
|
69
69
|
- lib/generators/templates/fly.toml.erb
|
70
|
+
- lib/generators/templates/litefs.yml.erb
|
70
71
|
- lib/generators/templates/main.tf.erb
|
71
72
|
- lib/generators/templates/patches/action_cable.rb
|
72
73
|
- lib/tasks/fly.rake
|