railsdocks 1.0.0 → 1.1.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 +4 -4
- data/lib/railsdocks/cli.rb +132 -8
- data/lib/railsdocks/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: ee057c9a4fb29cb3002d6dd8eaac99bab25b44cd4650eb42a5940c9da1e7b239
|
|
4
|
+
data.tar.gz: ad097635e565df2cd32f882db1a0881382e762e3590f1add79347b3140eb294d
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 8298495d87240c7e310c123ad76d1c6daa3cf2596b1d8307728f33b66bf84e6fac2af39cf42fb0456d256a5f5586eaff2750cc33651aeda39d5c1c2a136d580d
|
|
7
|
+
data.tar.gz: 83d0a1b2a5b3cca7d362bb2e712564626ac6ad730aa8eae86eca0201c45e3d730f97dcff330f82445d80c1f3c598364f17059c8eb0a7212089fc7bdffba3ec8c
|
data/lib/railsdocks/cli.rb
CHANGED
|
@@ -23,6 +23,8 @@ module RailsDocks
|
|
|
23
23
|
database_command("migrate")
|
|
24
24
|
when "db:rollback"
|
|
25
25
|
database_command("rollback")
|
|
26
|
+
when "db:seed"
|
|
27
|
+
database_command("seed")
|
|
26
28
|
when "domains:list"
|
|
27
29
|
domains_list
|
|
28
30
|
when "domains:add"
|
|
@@ -181,6 +183,7 @@ module RailsDocks
|
|
|
181
183
|
end
|
|
182
184
|
|
|
183
185
|
if inside_git_repository?
|
|
186
|
+
configure_production_credentials_key
|
|
184
187
|
add_git_remote(git_url)
|
|
185
188
|
else
|
|
186
189
|
puts
|
|
@@ -337,7 +340,8 @@ module RailsDocks
|
|
|
337
340
|
1
|
|
338
341
|
rescue KeyError
|
|
339
342
|
warn(
|
|
340
|
-
"Destroy failed: RailsDocks returned "
|
|
343
|
+
"Destroy failed: RailsDocks returned " \
|
|
344
|
+
"an unexpected response."
|
|
341
345
|
)
|
|
342
346
|
1
|
|
343
347
|
end
|
|
@@ -366,9 +370,14 @@ module RailsDocks
|
|
|
366
370
|
end
|
|
367
371
|
|
|
368
372
|
display_name =
|
|
369
|
-
operation
|
|
370
|
-
|
|
373
|
+
case operation
|
|
374
|
+
when "migrate"
|
|
375
|
+
"Migrating"
|
|
376
|
+
when "rollback"
|
|
371
377
|
"Rolling back"
|
|
378
|
+
when "seed"
|
|
379
|
+
"Seeding"
|
|
380
|
+
end
|
|
372
381
|
|
|
373
382
|
puts "#{display_name} #{slug}..."
|
|
374
383
|
|
|
@@ -384,11 +393,17 @@ module RailsDocks
|
|
|
384
393
|
|
|
385
394
|
puts output unless output.empty?
|
|
386
395
|
|
|
387
|
-
|
|
388
|
-
operation
|
|
389
|
-
|
|
396
|
+
completion_message =
|
|
397
|
+
case operation
|
|
398
|
+
when "migrate"
|
|
399
|
+
"Migration complete."
|
|
400
|
+
when "rollback"
|
|
390
401
|
"Rollback complete."
|
|
391
|
-
|
|
402
|
+
when "seed"
|
|
403
|
+
"Seed complete."
|
|
404
|
+
end
|
|
405
|
+
|
|
406
|
+
puts completion_message
|
|
392
407
|
|
|
393
408
|
0
|
|
394
409
|
rescue Client::Error => e
|
|
@@ -660,6 +675,109 @@ module RailsDocks
|
|
|
660
675
|
match[:slug]
|
|
661
676
|
end
|
|
662
677
|
|
|
678
|
+
def self.configure_production_credentials_key
|
|
679
|
+
key_path =
|
|
680
|
+
File.join(
|
|
681
|
+
"config",
|
|
682
|
+
"credentials",
|
|
683
|
+
"production.key"
|
|
684
|
+
)
|
|
685
|
+
|
|
686
|
+
unless File.file?(key_path)
|
|
687
|
+
warn
|
|
688
|
+
warn(
|
|
689
|
+
"Production credentials key not found at " \
|
|
690
|
+
"#{key_path}."
|
|
691
|
+
)
|
|
692
|
+
warn(
|
|
693
|
+
"RailsDocks could not add it to the deployment."
|
|
694
|
+
)
|
|
695
|
+
return
|
|
696
|
+
end
|
|
697
|
+
|
|
698
|
+
configure_dockerignore_for_production_key
|
|
699
|
+
add_production_key_to_git(key_path)
|
|
700
|
+
end
|
|
701
|
+
|
|
702
|
+
def self.configure_dockerignore_for_production_key
|
|
703
|
+
dockerignore_path =
|
|
704
|
+
".dockerignore"
|
|
705
|
+
|
|
706
|
+
return unless File.file?(
|
|
707
|
+
dockerignore_path
|
|
708
|
+
)
|
|
709
|
+
|
|
710
|
+
exception =
|
|
711
|
+
"!/config/credentials/production.key"
|
|
712
|
+
|
|
713
|
+
lines =
|
|
714
|
+
File.readlines(
|
|
715
|
+
dockerignore_path,
|
|
716
|
+
chomp: true
|
|
717
|
+
)
|
|
718
|
+
|
|
719
|
+
return if lines.include?(
|
|
720
|
+
exception
|
|
721
|
+
)
|
|
722
|
+
|
|
723
|
+
File.open(
|
|
724
|
+
dockerignore_path,
|
|
725
|
+
"a"
|
|
726
|
+
) do |file|
|
|
727
|
+
file.puts unless File.zero?(
|
|
728
|
+
dockerignore_path
|
|
729
|
+
)
|
|
730
|
+
|
|
731
|
+
file.puts exception
|
|
732
|
+
end
|
|
733
|
+
|
|
734
|
+
_output,
|
|
735
|
+
error,
|
|
736
|
+
status =
|
|
737
|
+
Open3.capture3(
|
|
738
|
+
"git",
|
|
739
|
+
"add",
|
|
740
|
+
dockerignore_path
|
|
741
|
+
)
|
|
742
|
+
|
|
743
|
+
unless status.success?
|
|
744
|
+
warn(
|
|
745
|
+
"Could not stage .dockerignore: " \
|
|
746
|
+
"#{error.strip}"
|
|
747
|
+
)
|
|
748
|
+
return
|
|
749
|
+
end
|
|
750
|
+
|
|
751
|
+
puts(
|
|
752
|
+
"Production credentials key allowed " \
|
|
753
|
+
"through .dockerignore."
|
|
754
|
+
)
|
|
755
|
+
end
|
|
756
|
+
|
|
757
|
+
def self.add_production_key_to_git(key_path)
|
|
758
|
+
_output,
|
|
759
|
+
error,
|
|
760
|
+
status =
|
|
761
|
+
Open3.capture3(
|
|
762
|
+
"git",
|
|
763
|
+
"add",
|
|
764
|
+
"-f",
|
|
765
|
+
key_path
|
|
766
|
+
)
|
|
767
|
+
|
|
768
|
+
unless status.success?
|
|
769
|
+
warn(
|
|
770
|
+
"Could not add production credentials key: " \
|
|
771
|
+
"#{error.strip}"
|
|
772
|
+
)
|
|
773
|
+
return
|
|
774
|
+
end
|
|
775
|
+
|
|
776
|
+
puts(
|
|
777
|
+
"Production credentials key added for deployment."
|
|
778
|
+
)
|
|
779
|
+
end
|
|
780
|
+
|
|
663
781
|
def self.add_git_remote(git_url)
|
|
664
782
|
_output,
|
|
665
783
|
_error,
|
|
@@ -734,6 +852,9 @@ module RailsDocks
|
|
|
734
852
|
db:rollback
|
|
735
853
|
Roll back the last application migration
|
|
736
854
|
|
|
855
|
+
db:seed
|
|
856
|
+
Run Rails database seeds
|
|
857
|
+
|
|
737
858
|
domains:list
|
|
738
859
|
List all custom domains
|
|
739
860
|
|
|
@@ -756,7 +877,10 @@ module RailsDocks
|
|
|
756
877
|
private_class_method \
|
|
757
878
|
:inside_git_repository?,
|
|
758
879
|
:current_app_slug,
|
|
880
|
+
:configure_production_credentials_key,
|
|
881
|
+
:configure_dockerignore_for_production_key,
|
|
882
|
+
:add_production_key_to_git,
|
|
759
883
|
:add_git_remote,
|
|
760
884
|
:help
|
|
761
885
|
end
|
|
762
|
-
end
|
|
886
|
+
end
|
data/lib/railsdocks/version.rb
CHANGED