appmap 0.78.0 → 0.80.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (59) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +4 -16
  3. data/CHANGELOG.md +30 -0
  4. data/{spec/fixtures/rails5_users_app/Dockerfile.pg → Dockerfile.pg} +0 -0
  5. data/README.md +14 -44
  6. data/README_CI.md +0 -7
  7. data/Rakefile +12 -150
  8. data/appmap.gemspec +3 -2
  9. data/docker-compose.yml +10 -0
  10. data/lib/appmap/agent.rb +8 -0
  11. data/lib/appmap/event.rb +26 -12
  12. data/lib/appmap/gem_hooks/actionpack.yml +6 -0
  13. data/lib/appmap/handler/rails/render_handler.rb +29 -0
  14. data/lib/appmap/handler/rails/request_handler.rb +13 -11
  15. data/lib/appmap/handler/rails/sql_handler.rb +43 -1
  16. data/lib/appmap/handler.rb +3 -0
  17. data/lib/appmap/hook/method.rb +0 -1
  18. data/lib/appmap/version.rb +1 -1
  19. data/spec/config_spec.rb +1 -1
  20. data/spec/depends/api_spec.rb +13 -5
  21. data/spec/depends/spec_helper.rb +0 -9
  22. data/spec/fixtures/database.yml +11 -0
  23. data/spec/fixtures/rails5_users_app/config/database.yml +1 -0
  24. data/spec/fixtures/rails6_users_app/Gemfile +1 -25
  25. data/spec/fixtures/rails6_users_app/config/database.yml +1 -0
  26. data/spec/fixtures/rails7_users_app/Gemfile +1 -25
  27. data/spec/fixtures/rails7_users_app/config/database.yml +1 -0
  28. data/spec/handler/eval_spec.rb +1 -1
  29. data/spec/hook_spec.rb +6 -1
  30. data/spec/rails_recording_spec.rb +7 -21
  31. data/spec/rails_spec_helper.rb +76 -63
  32. data/spec/rails_test_spec.rb +7 -17
  33. data/spec/railtie_spec.rb +4 -18
  34. data/spec/record_sql_rails_pg_spec.rb +44 -75
  35. data/spec/remote_recording_spec.rb +18 -30
  36. data/spec/spec_helper.rb +1 -0
  37. data/spec/swagger/swagger_spec.rb +1 -16
  38. data/spec/util_spec.rb +1 -1
  39. data/test/expectations/openssl_test_key_sign2-3.1.json +2 -1
  40. metadata +22 -21
  41. data/Dockerfile.appmap +0 -5
  42. data/spec/fixtures/rack_users_app/Dockerfile +0 -32
  43. data/spec/fixtures/rack_users_app/docker-compose.yml +0 -9
  44. data/spec/fixtures/rails5_users_app/Dockerfile +0 -29
  45. data/spec/fixtures/rails5_users_app/config/database.yml +0 -18
  46. data/spec/fixtures/rails5_users_app/create_app +0 -33
  47. data/spec/fixtures/rails5_users_app/docker-compose.yml +0 -31
  48. data/spec/fixtures/rails6_users_app/.ruby-version +0 -1
  49. data/spec/fixtures/rails6_users_app/Dockerfile +0 -44
  50. data/spec/fixtures/rails6_users_app/Dockerfile.pg +0 -3
  51. data/spec/fixtures/rails6_users_app/config/database.yml +0 -18
  52. data/spec/fixtures/rails6_users_app/create_app +0 -33
  53. data/spec/fixtures/rails6_users_app/docker-compose.yml +0 -31
  54. data/spec/fixtures/rails7_users_app/.ruby-version +0 -1
  55. data/spec/fixtures/rails7_users_app/Dockerfile +0 -30
  56. data/spec/fixtures/rails7_users_app/Dockerfile.pg +0 -3
  57. data/spec/fixtures/rails7_users_app/config/database.yml +0 -86
  58. data/spec/fixtures/rails7_users_app/create_app +0 -31
  59. data/spec/fixtures/rails7_users_app/docker-compose.yml +0 -31
@@ -2,89 +2,58 @@ require 'rails_spec_helper'
2
2
 
3
3
  describe 'SQL events' do
4
4
  include_context 'Rails app pg database', 'spec/fixtures/rails6_users_app' do
5
- around(:each) do |example|
6
- FileUtils.rm_rf tmpdir
7
- FileUtils.mkdir_p tmpdir
8
- cmd = "docker-compose run --rm -e ORM_MODULE=#{orm_module} -e RAILS_ENV=test -e APPMAP=true -v #{File.absolute_path tmpdir}:/app/tmp app ./bin/rspec spec/controllers/users_controller_api_spec.rb:#{test_line_number}"
9
- run_cmd cmd, chdir: fixture_dir
10
-
11
- example.run
12
- end
13
-
14
- let(:tmpdir) { "tmp/spec/record_sql_rails_pg_spec" }
15
-
16
- describe 'fields' do
17
- let(:test_line_number) { 8 }
18
- let(:appmap_json) { File.join(tmpdir, 'appmap/rspec/Api_UsersController_POST_api_users_with_required_parameters_creates_a_user.appmap.json') }
19
- let(:orm_module) { 'sequel' }
20
- let(:appmap) { JSON.parse(File.read(appmap_json)) }
21
- describe 'on a call event' do
22
- let(:event) do
23
- appmap['events'].find do |event|
24
- event['event'] == 'call' &&
25
- event.keys.include?('sql_query')
5
+ def self.check_queries(cases)
6
+ cases.each do |test_case, query|
7
+ context "in #{test_case}" do
8
+ let(:test_case) { test_case }
9
+ it "captures #{query}" do
10
+ expect(sql_events).to include sql_query query
26
11
  end
27
12
  end
28
- it 'do not include function-only fields' do
29
- expect(event.keys).to_not include('defined_class')
30
- expect(event.keys).to_not include('method_id')
31
- expect(event.keys).to_not include('path')
32
- expect(event.keys).to_not include('lineno')
33
- end
34
13
  end
35
14
  end
36
15
 
37
- describe 'in a Rails app' do
38
- let(:appmap) { JSON.parse(File.read(appmap_json)).to_yaml }
39
- context 'while creating a new record' do
40
- let(:test_line_number) { 8 }
41
- let(:appmap_json) { File.join(tmpdir, 'appmap/rspec/Api_UsersController_POST_api_users_with_required_parameters_creates_a_user.appmap.json') }
16
+ context 'with Sequel' do
17
+ before(:context) { run_specs 'sequel' }
42
18
 
43
- context 'using Sequel ORM' do
44
- let(:orm_module) { 'sequel' }
45
- it 'detects the sql INSERT' do
46
- expect(appmap).to include(<<-SQL_QUERY.strip)
47
- sql_query:
48
- sql: INSERT INTO "users" ("login") VALUES ('alice') RETURNING *
49
- SQL_QUERY
50
- end
51
- end
52
- context 'using ActiveRecord ORM' do
53
- let(:orm_module) { 'activerecord' }
54
- it 'detects the sql INSERT' do
55
- expect(appmap).to include(<<-SQL_QUERY.strip)
56
- sql_query:
57
- sql: INSERT INTO "users" ("login") VALUES ($1) RETURNING "id"
58
- SQL_QUERY
59
- end
60
- end
61
- end
19
+ check_queries(
20
+ 'Api_UsersController_POST_api_users_with_required_parameters_creates_a_user' =>
21
+ %(INSERT INTO "users" ("login") VALUES ('alice') RETURNING *),
22
+ 'Api_UsersController_GET_api_users_lists_the_users' => %(SELECT * FROM "users")
23
+ )
24
+ end
62
25
 
63
- context 'while listing records' do
64
- let(:test_line_number) { 29 }
65
- let(:appmap_json) { File.join(tmpdir, 'appmap/rspec/Api_UsersController_GET_api_users_lists_the_users.appmap.json') }
26
+ context 'with ActiveRecord' do
27
+ before(:context) { run_specs 'activerecord' }
66
28
 
67
- context 'using Sequel ORM' do
68
- let(:orm_module) { 'sequel' }
69
- it 'detects the sql SELECT' do
70
- expect(appmap).to include(<<-SQL_QUERY.strip)
71
- sql_query:
72
- sql: SELECT * FROM "users"
73
- SQL_QUERY
74
-
75
- expect(appmap).to include('sql:')
76
- end
77
- end
78
- context 'using ActiveRecord ORM' do
79
- let(:orm_module) { 'activerecord' }
80
- it 'detects the sql SELECT' do
81
- expect(appmap).to include(<<-SQL_QUERY.strip)
82
- sql_query:
83
- sql: SELECT "users".* FROM "users"
84
- SQL_QUERY
85
- end
86
- end
87
- end
29
+ check_queries(
30
+ 'Api_UsersController_POST_api_users_with_required_parameters_creates_a_user' =>
31
+ %(INSERT INTO "users" ("login") VALUES ($1) RETURNING "id"),
32
+ 'Api_UsersController_GET_api_users_lists_the_users' => %(SELECT "users".* FROM "users")
33
+ )
34
+ end
35
+
36
+ def run_specs(orm_module)
37
+ @app.prepare_db
38
+ @app.run_cmd \
39
+ './bin/rspec spec/controllers/users_controller_api_spec.rb:8 spec/controllers/users_controller_api_spec.rb:29',
40
+ 'ORM_MODULE' => orm_module,
41
+ 'RAILS_ENV' => 'test',
42
+ 'APPMAP' => 'true'
43
+ end
44
+
45
+ let(:appmap_json) { File.join tmpdir, "appmap/rspec/#{test_case}.appmap.json" }
46
+ let(:appmap) { JSON.parse(File.read(appmap_json)) }
47
+ let(:tmpdir) { app.tmpdir }
48
+ let(:sql_events) { appmap['events'].select { |ev| ev.include? 'sql_query' } }
49
+
50
+ RSpec::Matchers.define_negated_matcher :not_include, :include
51
+ def sql_query(query)
52
+ (include('sql_query' => (include 'sql' => query)))
53
+ .and(not_include('defined_class'))
54
+ .and(not_include('method_id'))
55
+ .and(not_include('path'))
56
+ .and(not_include('lineno'))
88
57
  end
89
58
  end
90
59
  end
@@ -1,41 +1,27 @@
1
1
  require 'rails_spec_helper'
2
+
3
+ require 'random-port'
4
+
2
5
  require 'net/http'
3
6
  require 'socket'
4
7
 
5
8
  describe 'remote recording', :order => :defined do
6
9
  include_context 'Rails app pg database', 'spec/fixtures/rails6_users_app' do
7
10
  before(:all) do
8
- fixture_dir = 'spec/fixtures/rails6_users_app'
9
- start_cmd = 'docker-compose up -d app'
10
- run_cmd({ 'ORM_MODULE' => 'sequel', 'APPMAP' => 'true' }, start_cmd, chdir: fixture_dir)
11
- Dir.chdir fixture_dir do
12
- wait_for_container 'app'
13
- end
11
+ @service_port = RandomPort::Pool::SINGLETON.acquire
12
+ @app.prepare_db
13
+ @server = @app.spawn_cmd \
14
+ "./bin/rails server -p #{@service_port}",
15
+ 'ORM_MODULE' => 'sequel',
16
+ 'APPMAP' => 'true'
14
17
 
15
- port_cmd = 'docker-compose port app 3000'
16
- port_out, = run_cmd port_cmd, chdir: fixture_dir
17
- @service_port = port_out.strip.split(':')[1]
18
-
19
- service_running = false
20
- retry_count = 0
21
18
  uri = URI("http://localhost:#{@service_port}/health")
22
19
 
23
- until service_running
24
- sleep(0.25)
25
- begin
26
- res = Net::HTTP.start(uri.hostname, uri.port) do |http|
27
- http.request(Net::HTTP::Get.new(uri))
28
- end
29
-
30
- status = res.response.code.to_i
31
- service_running = true if status >= 200 && status < 300
32
-
33
- # give up after a certain error threshold is met
34
- # we don't want to wait forever if there's an unrecoverable issue
35
- raise 'gave up waiting on fixture service' if (retry_count += 1) == 10
36
- rescue Errno::ETIMEDOUT, Errno::ECONNRESET, EOFError
37
- $stderr.print('.')
38
- end
20
+ 100.times do
21
+ Net::HTTP.get(uri)
22
+ break
23
+ rescue Errno::ECONNREFUSED
24
+ sleep 0.1
39
25
  end
40
26
  end
41
27
 
@@ -44,8 +30,10 @@ describe 'remote recording', :order => :defined do
44
30
  end
45
31
 
46
32
  after(:all) do
47
- fixture_dir = 'spec/fixtures/rails6_users_app'
48
- run_cmd 'docker-compose rm -fs app', chdir: fixture_dir
33
+ if @server
34
+ Process.kill 'INT', @server
35
+ Process.wait @server
36
+ end
49
37
  end
50
38
 
51
39
  let(:service_address) { URI("http://localhost:#{@service_port}") }
data/spec/spec_helper.rb CHANGED
@@ -13,6 +13,7 @@ require 'appmap'
13
13
 
14
14
  RSpec.configure do |config|
15
15
  config.example_status_persistence_file_path = "tmp/rspec_failed_examples.txt"
16
+ config.profile_examples = true
16
17
  end
17
18
 
18
19
  # Re-run the Rails specs without re-generating the data. This is useful for efficiently enhancing and
@@ -4,24 +4,9 @@ describe 'rake appmap:swagger' do
4
4
  include_context 'Rails app pg database', "spec/fixtures/rails6_users_app" unless use_existing_data?
5
5
  include_context 'rails integration test setup'
6
6
 
7
- def run_spec(spec_name)
8
- cmd = <<~CMD.gsub "\n", ' '
9
- docker-compose run --rm -e RAILS_ENV=test -e APPMAP=true
10
- -v #{File.absolute_path tmpdir}:/app/tmp app ./bin/rspec #{spec_name}
11
- CMD
12
- run_cmd cmd, chdir: fixture_dir
13
- end
14
-
15
- def generate_swagger
16
- cmd = <<~CMD.gsub "\n", ' '
17
- docker-compose run --rm -v #{File.absolute_path tmpdir}:/app/tmp app ./bin/rake appmap:swagger
18
- CMD
19
- run_cmd cmd, chdir: fixture_dir
20
- end
21
-
22
7
  unless use_existing_data?
23
8
  before(:all) do
24
- generate_swagger
9
+ @app.run_cmd './bin/rake appmap:swagger'
25
10
  end
26
11
  end
27
12
 
data/spec/util_spec.rb CHANGED
@@ -3,7 +3,7 @@
3
3
  require 'spec_helper'
4
4
  require 'appmap/util'
5
5
 
6
- describe AppMap::Util, docker: false do
6
+ describe AppMap::Util do
7
7
  describe 'scenario_filename' do
8
8
  let(:subject) { AppMap::Util.method(:scenario_filename) }
9
9
  it 'leaves short names alone' do
@@ -26,7 +26,8 @@
26
26
  "name": "arg",
27
27
  "class": "Array",
28
28
  "value": "[e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855, the document]",
29
- "kind": "rest"
29
+ "kind": "rest",
30
+ "size": 2
30
31
  }
31
32
  ],
32
33
  "receiver": {
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: appmap
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.78.0
4
+ version: 0.80.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kevin Gilpin
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-04-04 00:00:00.000000000 Z
11
+ date: 2022-04-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -86,14 +86,14 @@ dependencies:
86
86
  requirements:
87
87
  - - "~>"
88
88
  - !ruby/object:Gem::Version
89
- version: '5.14'
89
+ version: '5.15'
90
90
  type: :development
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
94
  - - "~>"
95
95
  - !ruby/object:Gem::Version
96
- version: '5.14'
96
+ version: '5.15'
97
97
  - !ruby/object:Gem::Dependency
98
98
  name: pry-byebug
99
99
  requirement: !ruby/object:Gem::Requirement
@@ -276,6 +276,20 @@ dependencies:
276
276
  - - ">="
277
277
  - !ruby/object:Gem::Version
278
278
  version: '0'
279
+ - !ruby/object:Gem::Dependency
280
+ name: random-port
281
+ requirement: !ruby/object:Gem::Requirement
282
+ requirements:
283
+ - - "~>"
284
+ - !ruby/object:Gem::Version
285
+ version: 0.5.1
286
+ type: :development
287
+ prerelease: false
288
+ version_requirements: !ruby/object:Gem::Requirement
289
+ requirements:
290
+ - - "~>"
291
+ - !ruby/object:Gem::Version
292
+ version: 0.5.1
279
293
  - !ruby/object:Gem::Dependency
280
294
  name: webrick
281
295
  requirement: !ruby/object:Gem::Requirement
@@ -312,7 +326,7 @@ files:
312
326
  - ARCHITECTURE.md
313
327
  - CHANGELOG.md
314
328
  - CONTRIBUTING.md
315
- - Dockerfile.appmap
329
+ - Dockerfile.pg
316
330
  - Gemfile
317
331
  - LICENSE.txt
318
332
  - README.md
@@ -321,6 +335,7 @@ files:
321
335
  - appmap.gemspec
322
336
  - appmap.yml
323
337
  - config-schema.yml
338
+ - docker-compose.yml
324
339
  - examples/install.rb
325
340
  - examples/mock_webapp/Gemfile
326
341
  - examples/mock_webapp/appmap.yml
@@ -379,6 +394,7 @@ files:
379
394
  - lib/appmap/handler/eval.rb
380
395
  - lib/appmap/handler/function.rb
381
396
  - lib/appmap/handler/net_http.rb
397
+ - lib/appmap/handler/rails/render_handler.rb
382
398
  - lib/appmap/handler/rails/request_handler.rb
383
399
  - lib/appmap/handler/rails/sql_handler.rb
384
400
  - lib/appmap/handler/rails/template.rb
@@ -421,6 +437,7 @@ files:
421
437
  - spec/fixtures/config/invalid_yaml_config.yml
422
438
  - spec/fixtures/config/missing_path_or_gem.yml
423
439
  - spec/fixtures/config/valid_config.yml
440
+ - spec/fixtures/database.yml
424
441
  - spec/fixtures/depends/.gitignore
425
442
  - spec/fixtures/depends/app/controllers/api/api_keys_controller.rb
426
443
  - spec/fixtures/depends/app/controllers/organizations_controller.rb
@@ -463,18 +480,14 @@ files:
463
480
  - spec/fixtures/hook/user_page_scenario.appmap.json
464
481
  - spec/fixtures/rack_users_app/.dockerignore
465
482
  - spec/fixtures/rack_users_app/.gitignore
466
- - spec/fixtures/rack_users_app/Dockerfile
467
483
  - spec/fixtures/rack_users_app/Gemfile
468
484
  - spec/fixtures/rack_users_app/appmap.yml
469
485
  - spec/fixtures/rack_users_app/config.ru
470
- - spec/fixtures/rack_users_app/docker-compose.yml
471
486
  - spec/fixtures/rack_users_app/lib/app.rb
472
487
  - spec/fixtures/rails5_users_app/.dockerignore
473
488
  - spec/fixtures/rails5_users_app/.gitignore
474
489
  - spec/fixtures/rails5_users_app/.rspec
475
490
  - spec/fixtures/rails5_users_app/.ruby-version
476
- - spec/fixtures/rails5_users_app/Dockerfile
477
- - spec/fixtures/rails5_users_app/Dockerfile.pg
478
491
  - spec/fixtures/rails5_users_app/Gemfile
479
492
  - spec/fixtures/rails5_users_app/Rakefile
480
493
  - spec/fixtures/rails5_users_app/app/controllers/api/users_controller.rb
@@ -523,10 +536,8 @@ files:
523
536
  - spec/fixtures/rails5_users_app/config/initializers/wrap_parameters.rb
524
537
  - spec/fixtures/rails5_users_app/config/locales/en.yml
525
538
  - spec/fixtures/rails5_users_app/config/routes.rb
526
- - spec/fixtures/rails5_users_app/create_app
527
539
  - spec/fixtures/rails5_users_app/db/migrate/20190728211408_create_users.rb
528
540
  - spec/fixtures/rails5_users_app/db/schema.rb
529
- - spec/fixtures/rails5_users_app/docker-compose.yml
530
541
  - spec/fixtures/rails5_users_app/features/api_users.feature
531
542
  - spec/fixtures/rails5_users_app/features/support/env.rb
532
543
  - spec/fixtures/rails5_users_app/features/support/hooks.rb
@@ -543,9 +554,6 @@ files:
543
554
  - spec/fixtures/rails6_users_app/.dockerignore
544
555
  - spec/fixtures/rails6_users_app/.gitignore
545
556
  - spec/fixtures/rails6_users_app/.rspec
546
- - spec/fixtures/rails6_users_app/.ruby-version
547
- - spec/fixtures/rails6_users_app/Dockerfile
548
- - spec/fixtures/rails6_users_app/Dockerfile.pg
549
557
  - spec/fixtures/rails6_users_app/Gemfile
550
558
  - spec/fixtures/rails6_users_app/Rakefile
551
559
  - spec/fixtures/rails6_users_app/app/controllers/api/users_controller.rb
@@ -594,10 +602,8 @@ files:
594
602
  - spec/fixtures/rails6_users_app/config/initializers/wrap_parameters.rb
595
603
  - spec/fixtures/rails6_users_app/config/locales/en.yml
596
604
  - spec/fixtures/rails6_users_app/config/routes.rb
597
- - spec/fixtures/rails6_users_app/create_app
598
605
  - spec/fixtures/rails6_users_app/db/migrate/20190728211408_create_users.rb
599
606
  - spec/fixtures/rails6_users_app/db/schema.rb
600
- - spec/fixtures/rails6_users_app/docker-compose.yml
601
607
  - spec/fixtures/rails6_users_app/features/api_users.feature
602
608
  - spec/fixtures/rails6_users_app/features/support/env.rb
603
609
  - spec/fixtures/rails6_users_app/features/support/hooks.rb
@@ -620,9 +626,6 @@ files:
620
626
  - spec/fixtures/rails7_users_app/.gitattributes
621
627
  - spec/fixtures/rails7_users_app/.gitignore
622
628
  - spec/fixtures/rails7_users_app/.rspec
623
- - spec/fixtures/rails7_users_app/.ruby-version
624
- - spec/fixtures/rails7_users_app/Dockerfile
625
- - spec/fixtures/rails7_users_app/Dockerfile.pg
626
629
  - spec/fixtures/rails7_users_app/Gemfile
627
630
  - spec/fixtures/rails7_users_app/README.md
628
631
  - spec/fixtures/rails7_users_app/Rakefile
@@ -673,12 +676,10 @@ files:
673
676
  - spec/fixtures/rails7_users_app/config/puma.rb
674
677
  - spec/fixtures/rails7_users_app/config/routes.rb
675
678
  - spec/fixtures/rails7_users_app/config/storage.yml
676
- - spec/fixtures/rails7_users_app/create_app
677
679
  - spec/fixtures/rails7_users_app/db/migrate/20220328093141_create_instances.rb
678
680
  - spec/fixtures/rails7_users_app/db/migrate/20220328093154_create_instructors.rb
679
681
  - spec/fixtures/rails7_users_app/db/schema.rb
680
682
  - spec/fixtures/rails7_users_app/db/seeds.rb
681
- - spec/fixtures/rails7_users_app/docker-compose.yml
682
683
  - spec/fixtures/rails7_users_app/lib/assets/.keep
683
684
  - spec/fixtures/rails7_users_app/lib/tasks/.keep
684
685
  - spec/fixtures/rails7_users_app/log/.keep
data/Dockerfile.appmap DELETED
@@ -1,5 +0,0 @@
1
- FROM alpine
2
- ARG GEM_VERSION
3
-
4
- RUN mkdir /pkg
5
- COPY pkg/appmap-${GEM_VERSION}.gem /pkg/appmap.gem
@@ -1,32 +0,0 @@
1
- ARG GEM_VERSION
2
- ARG RUBY_VERSION
3
-
4
- FROM appmap:${GEM_VERSION} as appmap
5
-
6
- FROM ruby:${RUBY_VERSION}
7
- RUN apt-get update && apt-get install -y vim less
8
-
9
- RUN mkdir /app
10
- WORKDIR /app
11
-
12
- RUN gem install -N bundler
13
-
14
- COPY Gemfile .
15
-
16
- RUN bundle
17
- RUN bundle binstubs rack
18
-
19
- COPY . .
20
-
21
- COPY --from=appmap /pkg/appmap.gem /tmp/
22
- RUN gem install /tmp/appmap.gem && \
23
- bundle update --local appmap && \
24
- bundle binstubs appmap --force
25
-
26
- EXPOSE 9292
27
-
28
- ENV GLI_DEBUG=true
29
-
30
- ENTRYPOINT [ "./bin/appmap", "record", "-o", "tmp/appmap.json" ]
31
-
32
- HEALTHCHECK --interval=1s --retries=10 CMD curl --fail http://localhost:9292/health || exit 1
@@ -1,9 +0,0 @@
1
- version: "3"
2
- services:
3
- app:
4
- build:
5
- context: .
6
- dockerfile: Dockerfile
7
- image: rack-users-app:${RUBY_VERSION}
8
- ports:
9
- - "9292"
@@ -1,29 +0,0 @@
1
- ARG GEM_VERSION
2
- ARG RUBY_VERSION
3
-
4
- FROM appmap:${GEM_VERSION} as appmap
5
-
6
- FROM ruby:${RUBY_VERSION}
7
- RUN apt-get update && apt-get install -y vim less
8
- RUN apt-get install -y postgresql-client
9
-
10
- RUN mkdir /app
11
- WORKDIR /app
12
-
13
- RUN gem install -N bundler
14
-
15
- COPY Gemfile .
16
-
17
- RUN bundle
18
- RUN bundle binstubs bundler rspec-core --force
19
-
20
- COPY . .
21
-
22
- COPY --from=appmap /pkg/appmap.gem /tmp/
23
- RUN gem install /tmp/appmap.gem && \
24
- bundle update --local appmap && \
25
- bundle binstubs appmap --force
26
-
27
- EXPOSE 3000
28
-
29
- HEALTHCHECK --interval=1s --retries=10 CMD curl --fail http://localhost:3000/health || exit 1
@@ -1,18 +0,0 @@
1
- default: &default
2
- host: <%= ENV['PGHOST'] || 'pg' %>
3
- port: <%= ENV['PGPORT'] || 5432 %>
4
- user: postgres
5
- adapter: postgresql
6
- encoding: unicode
7
- # For details on connection pooling, see Rails configuration guide
8
- # http://guides.rubyonrails.org/configuring.html#database-pooling
9
- pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
10
-
11
- development:
12
- <<: *default
13
- database: app_development
14
- test:
15
- <<: *default
16
- database: app_test
17
- production:
18
- <<: *default
@@ -1,33 +0,0 @@
1
- #!/usr/bin/env bash
2
- set -ex
3
-
4
- # Just checking for a healthy container isn't enough, apparently. If
5
- # we don't wait here, sometimes the database is inaccessible.
6
- for i in {1..10}; do
7
- psql -h pg -U postgres postgres -c 'select 1' >/dev/null 2>&1 && break
8
- printf ' .'
9
- sleep 1
10
- done
11
- echo
12
- out="$(psql -h pg -U postgres postgres -c 'select 1' 2>&1)"
13
- if [[ $? != 0 ]]; then
14
- echo "Postgres didn't start in time:"
15
- echo "$out"
16
- exit 1
17
- fi
18
-
19
- # Required for migrations
20
- export ORM_MODULE=sequel
21
-
22
- set +e
23
- psql -h pg -U postgres -c "drop database if exists app_development"
24
- psql -h pg -U postgres -c "drop database if exists app_test"
25
- set -e
26
-
27
- psql -h pg -U postgres -c "create database app_development"
28
- psql -h pg -U postgres -c "create database app_test"
29
-
30
- env RAILS_ENV=development bundle exec rake -t db:migrate
31
- env RAILS_ENV=test bundle exec rake -t db:migrate
32
-
33
- echo "INSERT INTO users ( login ) VALUES ( 'admin' ) " | psql -h pg -U postgres app_development
@@ -1,31 +0,0 @@
1
- version: "3"
2
- services:
3
- pg:
4
- build:
5
- context: .
6
- dockerfile: Dockerfile.pg
7
- ports:
8
- - "5432"
9
- environment:
10
- POSTGRES_HOST_AUTH_METHOD: trust
11
-
12
- app:
13
- build:
14
- context: .
15
- dockerfile: Dockerfile
16
- image: rails5-app:${RUBY_VERSION}
17
- command:
18
- [ "./bin/rails", "server", "-b", "0.0.0.0", "webrick" ]
19
- environment:
20
- RAILS_ENV:
21
- ORM_MODULE:
22
- PGHOST: pg
23
- PGPORT: '5432'
24
- DATABASE_URL: postgres://postgres@pg
25
- APPMAP:
26
- volumes:
27
- - .:/src/app
28
- ports:
29
- - "3000"
30
- links:
31
- - pg:pg
@@ -1 +0,0 @@
1
- 2.6.2
@@ -1,44 +0,0 @@
1
- ARG GEM_VERSION
2
- ARG RUBY_VERSION
3
-
4
- FROM appmap:${GEM_VERSION} as appmap
5
- FROM ruby:${RUBY_VERSION}
6
-
7
- SHELL ["/bin/bash", "-c"]
8
-
9
- RUN apt-get update && apt-get install -y vim less
10
- RUN apt-get install -y postgresql-client
11
-
12
- RUN curl -fsSL https://fnm.vercel.app/install | bash \
13
- && source /root/.bashrc \
14
- && fnm install --lts \
15
- && echo 'fnm default $(fnm current)' >> ~/.bashrc \
16
- && ln -s $(which node) /usr/local/bin/ \
17
- && ln -s $(which npx) /usr/local/bin/ \
18
- && npm install -g yarn \
19
- && ln -s $(which yarn) /usr/local/bin/
20
-
21
- RUN mkdir /app
22
- WORKDIR /app
23
-
24
- RUN gem install -N bundler
25
-
26
- COPY package.json .
27
-
28
- RUN yarn install
29
-
30
- COPY Gemfile .
31
-
32
- RUN bundle
33
- RUN bundle binstubs bundler rspec-core --force
34
-
35
- COPY . .
36
-
37
- COPY --from=appmap /pkg/appmap.gem /tmp/
38
- RUN gem install /tmp/appmap.gem && \
39
- bundle update --local appmap && \
40
- bundle binstubs appmap --force
41
-
42
- EXPOSE 3000
43
-
44
- HEALTHCHECK --interval=1s --retries=10 CMD curl --fail http://localhost:3000/health || exit 1
@@ -1,3 +0,0 @@
1
- FROM postgres:10
2
-
3
- HEALTHCHECK --interval=1s --retries=10 CMD psql -U postgres -c "select 1" || exit 1
@@ -1,18 +0,0 @@
1
- default: &default
2
- host: <%= ENV['PGHOST'] || 'pg' %>
3
- port: <%= ENV['PGPORT'] || 5432 %>
4
- user: postgres
5
- adapter: postgresql
6
- encoding: unicode
7
- # For details on connection pooling, see Rails configuration guide
8
- # http://guides.rubyonrails.org/configuring.html#database-pooling
9
- pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
10
-
11
- development:
12
- <<: *default
13
- database: app_development
14
- test:
15
- <<: *default
16
- database: app_test
17
- production:
18
- <<: *default