skywalking 0.0.0.alpha
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 +7 -0
- data/.asf.yaml +40 -0
- data/.rspec +3 -0
- data/.rubocop.yml +236 -0
- data/CHANGELOG.md +15 -0
- data/CODE_OF_CONDUCT.md +132 -0
- data/LICENSE +201 -0
- data/NOTICE +5 -0
- data/README.md +18 -0
- data/Rakefile +23 -0
- data/docs/How-to-release.md +179 -0
- data/examples/rails-demo/.dockerignore +47 -0
- data/examples/rails-demo/.gitattributes +9 -0
- data/examples/rails-demo/.gitignore +34 -0
- data/examples/rails-demo/.kamal/hooks/docker-setup.sample +3 -0
- data/examples/rails-demo/.kamal/hooks/post-deploy.sample +14 -0
- data/examples/rails-demo/.kamal/hooks/post-proxy-reboot.sample +3 -0
- data/examples/rails-demo/.kamal/hooks/pre-build.sample +51 -0
- data/examples/rails-demo/.kamal/hooks/pre-connect.sample +47 -0
- data/examples/rails-demo/.kamal/hooks/pre-deploy.sample +109 -0
- data/examples/rails-demo/.kamal/hooks/pre-proxy-reboot.sample +3 -0
- data/examples/rails-demo/.kamal/secrets +17 -0
- data/examples/rails-demo/.rubocop.yml +8 -0
- data/examples/rails-demo/.ruby-version +1 -0
- data/examples/rails-demo/Dockerfile +72 -0
- data/examples/rails-demo/Gemfile +64 -0
- data/examples/rails-demo/README.md +24 -0
- data/examples/rails-demo/Rakefile +6 -0
- data/examples/rails-demo/app/assets/images/.keep +0 -0
- data/examples/rails-demo/app/assets/stylesheets/application.css +10 -0
- data/examples/rails-demo/app/controllers/application_controller.rb +4 -0
- data/examples/rails-demo/app/controllers/concerns/.keep +0 -0
- data/examples/rails-demo/app/helpers/application_helper.rb +2 -0
- data/examples/rails-demo/app/javascript/application.js +3 -0
- data/examples/rails-demo/app/javascript/controllers/application.js +9 -0
- data/examples/rails-demo/app/javascript/controllers/hello_controller.js +7 -0
- data/examples/rails-demo/app/javascript/controllers/index.js +4 -0
- data/examples/rails-demo/app/jobs/application_job.rb +7 -0
- data/examples/rails-demo/app/mailers/application_mailer.rb +4 -0
- data/examples/rails-demo/app/models/application_record.rb +3 -0
- data/examples/rails-demo/app/models/concerns/.keep +0 -0
- data/examples/rails-demo/app/views/layouts/application.html.erb +28 -0
- data/examples/rails-demo/app/views/layouts/mailer.html.erb +13 -0
- data/examples/rails-demo/app/views/layouts/mailer.text.erb +1 -0
- data/examples/rails-demo/app/views/pwa/manifest.json.erb +22 -0
- data/examples/rails-demo/app/views/pwa/service-worker.js +26 -0
- data/examples/rails-demo/bin/brakeman +7 -0
- data/examples/rails-demo/bin/bundle +109 -0
- data/examples/rails-demo/bin/dev +2 -0
- data/examples/rails-demo/bin/docker-entrypoint +14 -0
- data/examples/rails-demo/bin/importmap +4 -0
- data/examples/rails-demo/bin/jobs +6 -0
- data/examples/rails-demo/bin/kamal +27 -0
- data/examples/rails-demo/bin/rails +4 -0
- data/examples/rails-demo/bin/rake +4 -0
- data/examples/rails-demo/bin/rubocop +8 -0
- data/examples/rails-demo/bin/setup +34 -0
- data/examples/rails-demo/bin/thrust +5 -0
- data/examples/rails-demo/config/application.rb +27 -0
- data/examples/rails-demo/config/boot.rb +4 -0
- data/examples/rails-demo/config/cable.yml +17 -0
- data/examples/rails-demo/config/cache.yml +16 -0
- data/examples/rails-demo/config/credentials.yml.enc +1 -0
- data/examples/rails-demo/config/database.yml +41 -0
- data/examples/rails-demo/config/deploy.yml +116 -0
- data/examples/rails-demo/config/environment.rb +5 -0
- data/examples/rails-demo/config/environments/development.rb +72 -0
- data/examples/rails-demo/config/environments/production.rb +90 -0
- data/examples/rails-demo/config/environments/test.rb +53 -0
- data/examples/rails-demo/config/importmap.rb +7 -0
- data/examples/rails-demo/config/initializers/assets.rb +7 -0
- data/examples/rails-demo/config/initializers/content_security_policy.rb +25 -0
- data/examples/rails-demo/config/initializers/filter_parameter_logging.rb +8 -0
- data/examples/rails-demo/config/initializers/inflections.rb +16 -0
- data/examples/rails-demo/config/initializers/skywalking_ruby.rb +18 -0
- data/examples/rails-demo/config/locales/en.yml +31 -0
- data/examples/rails-demo/config/puma.rb +41 -0
- data/examples/rails-demo/config/queue.yml +18 -0
- data/examples/rails-demo/config/recurring.yml +10 -0
- data/examples/rails-demo/config/routes.rb +14 -0
- data/examples/rails-demo/config/storage.yml +34 -0
- data/examples/rails-demo/config.ru +6 -0
- data/examples/rails-demo/db/cable_schema.rb +11 -0
- data/examples/rails-demo/db/cache_schema.rb +14 -0
- data/examples/rails-demo/db/queue_schema.rb +129 -0
- data/examples/rails-demo/db/seeds.rb +9 -0
- data/examples/rails-demo/lib/tasks/.keep +0 -0
- data/examples/rails-demo/log/.keep +0 -0
- data/examples/rails-demo/public/400.html +114 -0
- data/examples/rails-demo/public/404.html +114 -0
- data/examples/rails-demo/public/406-unsupported-browser.html +114 -0
- data/examples/rails-demo/public/422.html +114 -0
- data/examples/rails-demo/public/500.html +114 -0
- data/examples/rails-demo/public/icon.png +0 -0
- data/examples/rails-demo/public/icon.svg +3 -0
- data/examples/rails-demo/public/robots.txt +1 -0
- data/examples/rails-demo/script/.keep +0 -0
- data/examples/rails-demo/storage/.keep +0 -0
- data/examples/rails-demo/test/application_system_test_case.rb +5 -0
- data/examples/rails-demo/test/controllers/.keep +0 -0
- data/examples/rails-demo/test/fixtures/files/.keep +0 -0
- data/examples/rails-demo/test/helpers/.keep +0 -0
- data/examples/rails-demo/test/integration/.keep +0 -0
- data/examples/rails-demo/test/mailers/.keep +0 -0
- data/examples/rails-demo/test/models/.keep +0 -0
- data/examples/rails-demo/test/system/.keep +0 -0
- data/examples/rails-demo/test/test_helper.rb +15 -0
- data/examples/rails-demo/tmp/.keep +0 -0
- data/examples/rails-demo/tmp/pids/.keep +0 -0
- data/examples/rails-demo/tmp/storage/.keep +0 -0
- data/examples/rails-demo/vendor/.keep +0 -0
- data/examples/rails-demo/vendor/javascript/.keep +0 -0
- data/examples/sinatra-demo/sinatra-demo.rb +32 -0
- data/lib/skywalking/agent.rb +98 -0
- data/lib/skywalking/configuration.rb +255 -0
- data/lib/skywalking/environment.rb +50 -0
- data/lib/skywalking/log/logger.rb +53 -0
- data/lib/skywalking/plugins/redis5.rb +70 -0
- data/lib/skywalking/plugins/sinatra.rb +55 -0
- data/lib/skywalking/plugins_manager.rb +84 -0
- data/lib/skywalking/proto/asyncprofiler/AsyncProfiler_pb.rb +23 -0
- data/lib/skywalking/proto/asyncprofiler/AsyncProfiler_services_pb.rb +45 -0
- data/lib/skywalking/proto/browser/BrowserPerfCompat_pb.rb +15 -0
- data/lib/skywalking/proto/browser/BrowserPerfCompat_services_pb.rb +42 -0
- data/lib/skywalking/proto/browser/BrowserPerf_pb.rb +21 -0
- data/lib/skywalking/proto/browser/BrowserPerf_services_pb.rb +46 -0
- data/lib/skywalking/proto/common/Command_pb.rb +20 -0
- data/lib/skywalking/proto/common/Common_pb.rb +21 -0
- data/lib/skywalking/proto/ebpf/accesslog_pb.rb +58 -0
- data/lib/skywalking/proto/ebpf/accesslog_services_pb.rb +42 -0
- data/lib/skywalking/proto/event/Event_pb.rb +21 -0
- data/lib/skywalking/proto/event/Event_services_pb.rb +45 -0
- data/lib/skywalking/proto/language-agent/CLRMetricCompat_pb.rb +15 -0
- data/lib/skywalking/proto/language-agent/CLRMetricCompat_services_pb.rb +38 -0
- data/lib/skywalking/proto/language-agent/CLRMetric_pb.rb +23 -0
- data/lib/skywalking/proto/language-agent/CLRMetric_services_pb.rb +42 -0
- data/lib/skywalking/proto/language-agent/ConfigurationDiscoveryService_pb.rb +19 -0
- data/lib/skywalking/proto/language-agent/ConfigurationDiscoveryService_services_pb.rb +51 -0
- data/lib/skywalking/proto/language-agent/JVMMetricCompat_pb.rb +15 -0
- data/lib/skywalking/proto/language-agent/JVMMetricCompat_services_pb.rb +39 -0
- data/lib/skywalking/proto/language-agent/JVMMetric_pb.rb +28 -0
- data/lib/skywalking/proto/language-agent/JVMMetric_services_pb.rb +43 -0
- data/lib/skywalking/proto/language-agent/MeterCompat_pb.rb +15 -0
- data/lib/skywalking/proto/language-agent/MeterCompat_services_pb.rb +39 -0
- data/lib/skywalking/proto/language-agent/Meter_pb.rb +24 -0
- data/lib/skywalking/proto/language-agent/Meter_services_pb.rb +48 -0
- data/lib/skywalking/proto/language-agent/TracingCompat_pb.rb +15 -0
- data/lib/skywalking/proto/language-agent/TracingCompat_services_pb.rb +48 -0
- data/lib/skywalking/proto/language-agent/Tracing_pb.rb +31 -0
- data/lib/skywalking/proto/language-agent/Tracing_services_pb.rb +71 -0
- data/lib/skywalking/proto/logging/Logging_pb.rb +26 -0
- data/lib/skywalking/proto/logging/Logging_services_pb.rb +46 -0
- data/lib/skywalking/proto/management/ManagementCompat_pb.rb +15 -0
- data/lib/skywalking/proto/management/ManagementCompat_services_pb.rb +44 -0
- data/lib/skywalking/proto/management/Management_pb.rb +21 -0
- data/lib/skywalking/proto/management/Management_services_pb.rb +48 -0
- data/lib/skywalking/proto/profile/ProfileCompat_pb.rb +15 -0
- data/lib/skywalking/proto/profile/ProfileCompat_services_pb.rb +43 -0
- data/lib/skywalking/proto/profile/Profile_pb.rb +22 -0
- data/lib/skywalking/proto/profile/Profile_services_pb.rb +47 -0
- data/lib/skywalking/proto/service-mesh-probe/service-mesh_pb.rb +25 -0
- data/lib/skywalking/proto/service-mesh-probe/service-mesh_services_pb.rb +43 -0
- data/lib/skywalking/reporter/buffer_trigger.rb +108 -0
- data/lib/skywalking/reporter/client/grpc_client.rb +114 -0
- data/lib/skywalking/reporter/client/proto.rb +29 -0
- data/lib/skywalking/reporter/grpc.rb +46 -0
- data/lib/skywalking/reporter/protocol.rb +28 -0
- data/lib/skywalking/reporter/report.rb +82 -0
- data/lib/skywalking/reporter/scheduler.rb +158 -0
- data/lib/skywalking/tracing/carrier.rb +121 -0
- data/lib/skywalking/tracing/carrier_item.rb +27 -0
- data/lib/skywalking/tracing/constants.rb +49 -0
- data/lib/skywalking/tracing/entry_span.rb +48 -0
- data/lib/skywalking/tracing/exit_span.rb +53 -0
- data/lib/skywalking/tracing/ignored_context.rb +34 -0
- data/lib/skywalking/tracing/noop_span.rb +32 -0
- data/lib/skywalking/tracing/segment.rb +57 -0
- data/lib/skywalking/tracing/span.rb +111 -0
- data/lib/skywalking/tracing/span_context.rb +242 -0
- data/lib/skywalking/tracing/tag.rb +49 -0
- data/lib/skywalking/utils/id_gen.rb +30 -0
- data/lib/skywalking/version.rb +18 -0
- data/lib/skywalking.rb +36 -0
- metadata +340 -0
@@ -0,0 +1,179 @@
|
|
1
|
+
# Apache SkyWalking Ruby Release Guide
|
2
|
+
|
3
|
+
This documentation guides the release manager to release the SkyWalking Ruby in the Apache Way, and also helps people to check the release for voting.
|
4
|
+
|
5
|
+
## Prerequisites
|
6
|
+
|
7
|
+
1. Close (if finished, or move to next milestone otherwise) all issues in the current milestone from [skywalking-ruby](https://github.com/apache/skywalking-ruby/milestones) and [skywalking](https://github.com/apache/skywalking/milestones), create a new milestone for the next release.
|
8
|
+
1. Update [CHANGELOG.md](../CHANGELOG.md) and `version` in [Version.rb](../lib/skywalking/version.rb).
|
9
|
+
|
10
|
+
|
11
|
+
## Add your GPG public key to Apache svn
|
12
|
+
|
13
|
+
1. Upload your GPG public key to a public GPG site, such as [MIT's site](http://pgp.mit.edu:11371/).
|
14
|
+
|
15
|
+
1. Log in [id.apache.org](https://id.apache.org/) and submit your key fingerprint.
|
16
|
+
|
17
|
+
1. Add your GPG public key into [SkyWalking GPG KEYS](https://dist.apache.org/repos/dist/release/skywalking/KEYS) file, **you can do this only if you are a PMC member**. You can ask a PMC member for help. **DO NOT override the existed `KEYS` file content, only append your key at the end of the file.**
|
18
|
+
|
19
|
+
|
20
|
+
## Build and sign the source code package
|
21
|
+
|
22
|
+
```shell
|
23
|
+
export VERSION=<the version to release>
|
24
|
+
|
25
|
+
git clone --recurse-submodules git@github.com:apache/skywalking-ruby && cd skywalking-ruby
|
26
|
+
git tag -a "v$VERSION" -m "Release Apache SkyWalking-Ruby $VERSION"
|
27
|
+
git push --tags
|
28
|
+
|
29
|
+
```
|
30
|
+
|
31
|
+
## Upload to Apache svn
|
32
|
+
|
33
|
+
```bash
|
34
|
+
svn co https://dist.apache.org/repos/dist/dev/skywalking/ruby/ release/skywalking/ruby
|
35
|
+
mkdir -p release/skywalking/ruby/"$VERSION"
|
36
|
+
cp skywalking-ruby/skywalking*.tgz release/skywalking/ruby/"$VERSION"
|
37
|
+
cp skywalking-ruby/skywalking*.tgz.asc release/skywalking/ruby/"$VERSION"
|
38
|
+
cp skywalking-ruby/skywalking*.tgz.sha512 release/skywalking/ruby/"$VERSION"
|
39
|
+
|
40
|
+
cd release/skywalking && svn add ruby/$VERSION && svn commit ruby -m "Draft Apache SkyWalking-Ruby release $VERSION"
|
41
|
+
```
|
42
|
+
|
43
|
+
## Call for vote in dev@ mailing list
|
44
|
+
|
45
|
+
Call for vote in `dev@skywalking.apache.org`.
|
46
|
+
|
47
|
+
```text
|
48
|
+
Subject: [VOTE] Release Apache SkyWalking Ruby version $VERSION
|
49
|
+
|
50
|
+
Content:
|
51
|
+
|
52
|
+
Hi the SkyWalking Community:
|
53
|
+
This is a call for vote to release Apache SkyWalking Ruby version $VERSION.
|
54
|
+
|
55
|
+
Release notes:
|
56
|
+
|
57
|
+
* https://github.com/apache/skywalking-ruby/blob/v$VERSION/CHANGELOG.md
|
58
|
+
|
59
|
+
Release Candidate:
|
60
|
+
|
61
|
+
* https://dist.apache.org/repos/dist/dev/skywalking/ruby/$VERSION
|
62
|
+
* sha512 checksums
|
63
|
+
- sha512xxxxyyyzzz skywalking-ruby-src-x.x.x.tgz
|
64
|
+
|
65
|
+
Release Tag :
|
66
|
+
|
67
|
+
* (Git Tag) v$VERSION
|
68
|
+
|
69
|
+
Release Commit Hash :
|
70
|
+
|
71
|
+
* https://github.com/apache/skywalking-ruby/tree/<Git Commit Hash>
|
72
|
+
|
73
|
+
Keys to verify the Release Candidate :
|
74
|
+
|
75
|
+
* https://dist.apache.org/repos/dist/release/skywalking/KEYS
|
76
|
+
|
77
|
+
Guide to build the release from source :
|
78
|
+
|
79
|
+
* https://github.com/apache/skywalking-ruby/blob/master/CONTRIBUTING.md#compiling-and-building
|
80
|
+
|
81
|
+
Voting will start now and will remain open for at least 72 hours, all PMC members are required to give their votes.
|
82
|
+
|
83
|
+
[ ] +1 Release this package.
|
84
|
+
[ ] +0 No opinion.
|
85
|
+
[ ] -1 Do not release this package because....
|
86
|
+
|
87
|
+
Thanks.
|
88
|
+
|
89
|
+
[1] https://github.com/apache/skywalking-ruby/blob/master/docs/How-to-release.md#vote-check
|
90
|
+
```
|
91
|
+
|
92
|
+
## Vote Check
|
93
|
+
|
94
|
+
All PMC members and committers should check these before voting +1:
|
95
|
+
|
96
|
+
1. Features test.
|
97
|
+
1. All artifacts in staging repository are published with `.asc`, `.md5`, and `sha` files.
|
98
|
+
1. Source codes and distribution packages (`skywalking-ruby-src-$VERSION.tgz`)
|
99
|
+
are in `https://dist.apache.org/repos/dist/dev/skywalking/ruby/$VERSION` with `.asc`, `.sha512`.
|
100
|
+
1. `LICENSE` and `NOTICE` are in source codes and distribution package.
|
101
|
+
1. Check `shasum -c skywalking-ruby-src-$VERSION.tgz.sha512`.
|
102
|
+
1. Check `gpg --verify skywalking-ruby-src-$VERSION.tgz.asc skywalking-ruby-src-$VERSION.tgz`.
|
103
|
+
1. Build distribution from source code package by following this [the build guide](#build-and-sign-the-source-code-package).
|
104
|
+
1. Licenses check, `make license`.
|
105
|
+
|
106
|
+
Vote result should follow these:
|
107
|
+
|
108
|
+
1. PMC vote is +1 binding, all others is +1 no binding.
|
109
|
+
|
110
|
+
1. Within 72 hours, you get at least 3 (+1 binding), and have more +1 than -1. Vote pass.
|
111
|
+
|
112
|
+
1. **Send the closing vote mail to announce the result**. When count the binding and no binding votes, please list the names of voters. An example like this:
|
113
|
+
|
114
|
+
```
|
115
|
+
[RESULT][VOTE] Release Apache SkyWalking Ruby version $VERSION
|
116
|
+
|
117
|
+
72+ hours passed, we’ve got ($NUMBER) +1 bindings (and ... +1 non-bindings):
|
118
|
+
|
119
|
+
(list names)
|
120
|
+
+1 bindings:
|
121
|
+
xxx
|
122
|
+
...
|
123
|
+
|
124
|
+
+1 non-bindings:
|
125
|
+
xxx
|
126
|
+
...
|
127
|
+
|
128
|
+
Thank you for voting, I’ll continue the release process.
|
129
|
+
```
|
130
|
+
|
131
|
+
## Publish release
|
132
|
+
|
133
|
+
1. Move source codes tar balls and distributions to `https://dist.apache.org/repos/dist/release/skywalking/`, **you can do this only if you are a PMC member**.
|
134
|
+
|
135
|
+
```shell
|
136
|
+
svn mv https://dist.apache.org/repos/dist/dev/skywalking/ruby/"$VERSION" https://dist.apache.org/repos/dist/release/skywalking/ruby/"$VERSION"
|
137
|
+
```
|
138
|
+
|
139
|
+
1. Refer to the previous [PR](https://github.com/apache/skywalking-website/pull/190), update news and links on the website. There are several files need to modify.
|
140
|
+
|
141
|
+
1. Update [Github release page](https://github.com/apache/skywalking-ruby/releases), follow the previous convention.
|
142
|
+
|
143
|
+
1. Publish to rubygems.org, this is optional for Apache releases, but we usually want to do this to let users use it conveniently.
|
144
|
+
|
145
|
+
```shell
|
146
|
+
```
|
147
|
+
|
148
|
+
**NOTE**: please double check before publishing to rubygems.org, it's difficult to unpublish and republish the module at the moment.
|
149
|
+
|
150
|
+
1. Send ANNOUNCE email to `dev@skywalking.apache.org` and `announce@apache.org`, the sender should use his/her Apache email account.
|
151
|
+
|
152
|
+
```
|
153
|
+
Subject: [ANNOUNCEMENT] Apache SkyWalking Ruby $VERSION Released
|
154
|
+
|
155
|
+
Content:
|
156
|
+
|
157
|
+
Hi the SkyWalking Community
|
158
|
+
|
159
|
+
On behalf of the SkyWalking Team, I’m glad to announce that SkyWalking Ruby $VERSION is now released.
|
160
|
+
|
161
|
+
SkyWalking Ruby: The Ruby Agent for Apache SkyWalking, which provides the native tracing abilities for Ruby backend project.
|
162
|
+
|
163
|
+
SkyWalking: APM (application performance monitor) tool for distributed systems, especially designed for microservices, cloud native and container-based (Docker, Kubernetes, Mesos) architectures.
|
164
|
+
|
165
|
+
Download Links: http://skywalking.apache.org/downloads/
|
166
|
+
|
167
|
+
Release Notes : https://github.com/apache/skywalking-ruby/blob/v$VERSION/CHANGELOG.md
|
168
|
+
|
169
|
+
Website: http://skywalking.apache.org/
|
170
|
+
|
171
|
+
SkyWalking Ruby Resources:
|
172
|
+
- Issue: https://github.com/apache/skywalking/issues
|
173
|
+
- Mailing list: dev@skywalking.apache.org
|
174
|
+
- Documents: https://github.com/apache/skywalking-ruby/blob/v$VERSION/README.md
|
175
|
+
|
176
|
+
The Apache SkyWalking Team
|
177
|
+
```
|
178
|
+
|
179
|
+
|
@@ -0,0 +1,47 @@
|
|
1
|
+
# See https://docs.docker.com/engine/reference/builder/#dockerignore-file for more about ignoring files.
|
2
|
+
|
3
|
+
# Ignore git directory.
|
4
|
+
/.git/
|
5
|
+
/.gitignore
|
6
|
+
|
7
|
+
# Ignore bundler config.
|
8
|
+
/.bundle
|
9
|
+
|
10
|
+
# Ignore all environment files.
|
11
|
+
/.env*
|
12
|
+
|
13
|
+
# Ignore all default key files.
|
14
|
+
/config/master.key
|
15
|
+
/config/credentials/*.key
|
16
|
+
|
17
|
+
# Ignore all logfiles and tempfiles.
|
18
|
+
/log/*
|
19
|
+
/tmp/*
|
20
|
+
!/log/.keep
|
21
|
+
!/tmp/.keep
|
22
|
+
|
23
|
+
# Ignore pidfiles, but keep the directory.
|
24
|
+
/tmp/pids/*
|
25
|
+
!/tmp/pids/.keep
|
26
|
+
|
27
|
+
# Ignore storage (uploaded files in development and any SQLite databases).
|
28
|
+
/storage/*
|
29
|
+
!/storage/.keep
|
30
|
+
/tmp/storage/*
|
31
|
+
!/tmp/storage/.keep
|
32
|
+
|
33
|
+
# Ignore assets.
|
34
|
+
/node_modules/
|
35
|
+
/app/assets/builds/*
|
36
|
+
!/app/assets/builds/.keep
|
37
|
+
/public/assets
|
38
|
+
|
39
|
+
# Ignore CI service files.
|
40
|
+
/.github
|
41
|
+
|
42
|
+
# Ignore development files
|
43
|
+
/.devcontainer
|
44
|
+
|
45
|
+
# Ignore Docker-related files
|
46
|
+
/.dockerignore
|
47
|
+
/Dockerfile*
|
@@ -0,0 +1,9 @@
|
|
1
|
+
# See https://git-scm.com/docs/gitattributes for more about git attribute files.
|
2
|
+
|
3
|
+
# Mark the database schema as having been generated.
|
4
|
+
db/schema.rb linguist-generated
|
5
|
+
|
6
|
+
# Mark any vendored files as having been vendored.
|
7
|
+
vendor/* linguist-vendored
|
8
|
+
config/credentials/*.yml.enc diff=rails_credentials
|
9
|
+
config/credentials.yml.enc diff=rails_credentials
|
@@ -0,0 +1,34 @@
|
|
1
|
+
# See https://help.github.com/articles/ignoring-files for more about ignoring files.
|
2
|
+
#
|
3
|
+
# Temporary files generated by your text editor or operating system
|
4
|
+
# belong in git's global ignore instead:
|
5
|
+
# `$XDG_CONFIG_HOME/git/ignore` or `~/.config/git/ignore`
|
6
|
+
|
7
|
+
# Ignore bundler config.
|
8
|
+
/.bundle
|
9
|
+
|
10
|
+
# Ignore all environment files.
|
11
|
+
/.env*
|
12
|
+
|
13
|
+
# Ignore all logfiles and tempfiles.
|
14
|
+
/log/*
|
15
|
+
/tmp/*
|
16
|
+
!/log/.keep
|
17
|
+
!/tmp/.keep
|
18
|
+
|
19
|
+
# Ignore pidfiles, but keep the directory.
|
20
|
+
/tmp/pids/*
|
21
|
+
!/tmp/pids/
|
22
|
+
!/tmp/pids/.keep
|
23
|
+
|
24
|
+
# Ignore storage (uploaded files in development and any SQLite databases).
|
25
|
+
/storage/*
|
26
|
+
!/storage/.keep
|
27
|
+
/tmp/storage/*
|
28
|
+
!/tmp/storage/
|
29
|
+
!/tmp/storage/.keep
|
30
|
+
|
31
|
+
/public/assets
|
32
|
+
|
33
|
+
# Ignore master key for decrypting credentials and more.
|
34
|
+
/config/master.key
|
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/bin/sh
|
2
|
+
|
3
|
+
# A sample post-deploy hook
|
4
|
+
#
|
5
|
+
# These environment variables are available:
|
6
|
+
# KAMAL_RECORDED_AT
|
7
|
+
# KAMAL_PERFORMER
|
8
|
+
# KAMAL_VERSION
|
9
|
+
# KAMAL_HOSTS
|
10
|
+
# KAMAL_ROLE (if set)
|
11
|
+
# KAMAL_DESTINATION (if set)
|
12
|
+
# KAMAL_RUNTIME
|
13
|
+
|
14
|
+
echo "$KAMAL_PERFORMER deployed $KAMAL_VERSION to $KAMAL_DESTINATION in $KAMAL_RUNTIME seconds"
|
@@ -0,0 +1,51 @@
|
|
1
|
+
#!/bin/sh
|
2
|
+
|
3
|
+
# A sample pre-build hook
|
4
|
+
#
|
5
|
+
# Checks:
|
6
|
+
# 1. We have a clean checkout
|
7
|
+
# 2. A remote is configured
|
8
|
+
# 3. The branch has been pushed to the remote
|
9
|
+
# 4. The version we are deploying matches the remote
|
10
|
+
#
|
11
|
+
# These environment variables are available:
|
12
|
+
# KAMAL_RECORDED_AT
|
13
|
+
# KAMAL_PERFORMER
|
14
|
+
# KAMAL_VERSION
|
15
|
+
# KAMAL_HOSTS
|
16
|
+
# KAMAL_ROLE (if set)
|
17
|
+
# KAMAL_DESTINATION (if set)
|
18
|
+
|
19
|
+
if [ -n "$(git status --porcelain)" ]; then
|
20
|
+
echo "Git checkout is not clean, aborting..." >&2
|
21
|
+
git status --porcelain >&2
|
22
|
+
exit 1
|
23
|
+
fi
|
24
|
+
|
25
|
+
first_remote=$(git remote)
|
26
|
+
|
27
|
+
if [ -z "$first_remote" ]; then
|
28
|
+
echo "No git remote set, aborting..." >&2
|
29
|
+
exit 1
|
30
|
+
fi
|
31
|
+
|
32
|
+
current_branch=$(git branch --show-current)
|
33
|
+
|
34
|
+
if [ -z "$current_branch" ]; then
|
35
|
+
echo "Not on a git branch, aborting..." >&2
|
36
|
+
exit 1
|
37
|
+
fi
|
38
|
+
|
39
|
+
remote_head=$(git ls-remote $first_remote --tags $current_branch | cut -f1)
|
40
|
+
|
41
|
+
if [ -z "$remote_head" ]; then
|
42
|
+
echo "Branch not pushed to remote, aborting..." >&2
|
43
|
+
exit 1
|
44
|
+
fi
|
45
|
+
|
46
|
+
if [ "$KAMAL_VERSION" != "$remote_head" ]; then
|
47
|
+
echo "Version ($KAMAL_VERSION) does not match remote HEAD ($remote_head), aborting..." >&2
|
48
|
+
exit 1
|
49
|
+
fi
|
50
|
+
|
51
|
+
exit 0
|
@@ -0,0 +1,47 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
# A sample pre-connect check
|
4
|
+
#
|
5
|
+
# Warms DNS before connecting to hosts in parallel
|
6
|
+
#
|
7
|
+
# These environment variables are available:
|
8
|
+
# KAMAL_RECORDED_AT
|
9
|
+
# KAMAL_PERFORMER
|
10
|
+
# KAMAL_VERSION
|
11
|
+
# KAMAL_HOSTS
|
12
|
+
# KAMAL_ROLE (if set)
|
13
|
+
# KAMAL_DESTINATION (if set)
|
14
|
+
# KAMAL_RUNTIME
|
15
|
+
|
16
|
+
hosts = ENV["KAMAL_HOSTS"].split(",")
|
17
|
+
results = nil
|
18
|
+
max = 3
|
19
|
+
|
20
|
+
elapsed = Benchmark.realtime do
|
21
|
+
results = hosts.map do |host|
|
22
|
+
Thread.new do
|
23
|
+
tries = 1
|
24
|
+
|
25
|
+
begin
|
26
|
+
Socket.getaddrinfo(host, 0, Socket::AF_UNSPEC, Socket::SOCK_STREAM, nil, Socket::AI_CANONNAME)
|
27
|
+
rescue SocketError
|
28
|
+
if tries < max
|
29
|
+
puts "Retrying DNS warmup: #{host}"
|
30
|
+
tries += 1
|
31
|
+
sleep rand
|
32
|
+
retry
|
33
|
+
else
|
34
|
+
puts "DNS warmup failed: #{host}"
|
35
|
+
host
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
tries
|
40
|
+
end
|
41
|
+
end.map(&:value)
|
42
|
+
end
|
43
|
+
|
44
|
+
retries = results.sum - hosts.size
|
45
|
+
nopes = results.count { |r| r == max }
|
46
|
+
|
47
|
+
puts "Prewarmed %d DNS lookups in %.2f sec: %d retries, %d failures" % [ hosts.size, elapsed, retries, nopes ]
|
@@ -0,0 +1,109 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
# A sample pre-deploy hook
|
4
|
+
#
|
5
|
+
# Checks the Github status of the build, waiting for a pending build to complete for up to 720 seconds.
|
6
|
+
#
|
7
|
+
# Fails unless the combined status is "success"
|
8
|
+
#
|
9
|
+
# These environment variables are available:
|
10
|
+
# KAMAL_RECORDED_AT
|
11
|
+
# KAMAL_PERFORMER
|
12
|
+
# KAMAL_VERSION
|
13
|
+
# KAMAL_HOSTS
|
14
|
+
# KAMAL_COMMAND
|
15
|
+
# KAMAL_SUBCOMMAND
|
16
|
+
# KAMAL_ROLE (if set)
|
17
|
+
# KAMAL_DESTINATION (if set)
|
18
|
+
|
19
|
+
# Only check the build status for production deployments
|
20
|
+
if ENV["KAMAL_COMMAND"] == "rollback" || ENV["KAMAL_DESTINATION"] != "production"
|
21
|
+
exit 0
|
22
|
+
end
|
23
|
+
|
24
|
+
require "bundler/inline"
|
25
|
+
|
26
|
+
# true = install gems so this is fast on repeat invocations
|
27
|
+
gemfile(true, quiet: true) do
|
28
|
+
source "https://rubygems.org"
|
29
|
+
|
30
|
+
gem "octokit"
|
31
|
+
gem "faraday-retry"
|
32
|
+
end
|
33
|
+
|
34
|
+
MAX_ATTEMPTS = 72
|
35
|
+
ATTEMPTS_GAP = 10
|
36
|
+
|
37
|
+
def exit_with_error(message)
|
38
|
+
$stderr.puts message
|
39
|
+
exit 1
|
40
|
+
end
|
41
|
+
|
42
|
+
class GithubStatusChecks
|
43
|
+
attr_reader :remote_url, :git_sha, :github_client, :combined_status
|
44
|
+
|
45
|
+
def initialize
|
46
|
+
@remote_url = `git config --get remote.origin.url`.strip.delete_prefix("https://github.com/")
|
47
|
+
@git_sha = `git rev-parse HEAD`.strip
|
48
|
+
@github_client = Octokit::Client.new(access_token: ENV["GITHUB_TOKEN"])
|
49
|
+
refresh!
|
50
|
+
end
|
51
|
+
|
52
|
+
def refresh!
|
53
|
+
@combined_status = github_client.combined_status(remote_url, git_sha)
|
54
|
+
end
|
55
|
+
|
56
|
+
def state
|
57
|
+
combined_status[:state]
|
58
|
+
end
|
59
|
+
|
60
|
+
def first_status_url
|
61
|
+
first_status = combined_status[:statuses].find { |status| status[:state] == state }
|
62
|
+
first_status && first_status[:target_url]
|
63
|
+
end
|
64
|
+
|
65
|
+
def complete_count
|
66
|
+
combined_status[:statuses].count { |status| status[:state] != "pending"}
|
67
|
+
end
|
68
|
+
|
69
|
+
def total_count
|
70
|
+
combined_status[:statuses].count
|
71
|
+
end
|
72
|
+
|
73
|
+
def current_status
|
74
|
+
if total_count > 0
|
75
|
+
"Completed #{complete_count}/#{total_count} checks, see #{first_status_url} ..."
|
76
|
+
else
|
77
|
+
"Build not started..."
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
|
83
|
+
$stdout.sync = true
|
84
|
+
|
85
|
+
puts "Checking build status..."
|
86
|
+
attempts = 0
|
87
|
+
checks = GithubStatusChecks.new
|
88
|
+
|
89
|
+
begin
|
90
|
+
loop do
|
91
|
+
case checks.state
|
92
|
+
when "success"
|
93
|
+
puts "Checks passed, see #{checks.first_status_url}"
|
94
|
+
exit 0
|
95
|
+
when "failure"
|
96
|
+
exit_with_error "Checks failed, see #{checks.first_status_url}"
|
97
|
+
when "pending"
|
98
|
+
attempts += 1
|
99
|
+
end
|
100
|
+
|
101
|
+
exit_with_error "Checks are still pending, gave up after #{MAX_ATTEMPTS * ATTEMPTS_GAP} seconds" if attempts == MAX_ATTEMPTS
|
102
|
+
|
103
|
+
puts checks.current_status
|
104
|
+
sleep(ATTEMPTS_GAP)
|
105
|
+
checks.refresh!
|
106
|
+
end
|
107
|
+
rescue Octokit::NotFound
|
108
|
+
exit_with_error "Build status could not be found"
|
109
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# Secrets defined here are available for reference under registry/password, env/secret, builder/secrets,
|
2
|
+
# and accessories/*/env/secret in config/deploy.yml. All secrets should be pulled from either
|
3
|
+
# password manager, ENV, or a file. DO NOT ENTER RAW CREDENTIALS HERE! This file needs to be safe for git.
|
4
|
+
|
5
|
+
# Example of extracting secrets from 1password (or another compatible pw manager)
|
6
|
+
# SECRETS=$(kamal secrets fetch --adapter 1password --account your-account --from Vault/Item KAMAL_REGISTRY_PASSWORD RAILS_MASTER_KEY)
|
7
|
+
# KAMAL_REGISTRY_PASSWORD=$(kamal secrets extract KAMAL_REGISTRY_PASSWORD ${SECRETS})
|
8
|
+
# RAILS_MASTER_KEY=$(kamal secrets extract RAILS_MASTER_KEY ${SECRETS})
|
9
|
+
|
10
|
+
# Use a GITHUB_TOKEN if private repositories are needed for the image
|
11
|
+
# GITHUB_TOKEN=$(gh config get -h github.com oauth_token)
|
12
|
+
|
13
|
+
# Grab the registry password from ENV
|
14
|
+
KAMAL_REGISTRY_PASSWORD=$KAMAL_REGISTRY_PASSWORD
|
15
|
+
|
16
|
+
# Improve security by using a password manager. Never check config/master.key into git!
|
17
|
+
RAILS_MASTER_KEY=$(cat config/master.key)
|
@@ -0,0 +1 @@
|
|
1
|
+
ruby-3.2.2
|
@@ -0,0 +1,72 @@
|
|
1
|
+
# syntax=docker/dockerfile:1
|
2
|
+
# check=error=true
|
3
|
+
|
4
|
+
# This Dockerfile is designed for production, not development. Use with Kamal or build'n'run by hand:
|
5
|
+
# docker build -t app_demo .
|
6
|
+
# docker run -d -p 80:80 -e RAILS_MASTER_KEY=<value from config/master.key> --name app_demo app_demo
|
7
|
+
|
8
|
+
# For a containerized dev environment, see Dev Containers: https://guides.rubyonrails.org/getting_started_with_devcontainer.html
|
9
|
+
|
10
|
+
# Make sure RUBY_VERSION matches the Ruby version in .ruby-version
|
11
|
+
ARG RUBY_VERSION=3.2.2
|
12
|
+
FROM docker.io/library/ruby:$RUBY_VERSION-slim AS base
|
13
|
+
|
14
|
+
# Rails app lives here
|
15
|
+
WORKDIR /rails
|
16
|
+
|
17
|
+
# Install base packages
|
18
|
+
RUN apt-get update -qq && \
|
19
|
+
apt-get install --no-install-recommends -y curl libjemalloc2 libvips sqlite3 && \
|
20
|
+
rm -rf /var/lib/apt/lists /var/cache/apt/archives
|
21
|
+
|
22
|
+
# Set production environment
|
23
|
+
ENV RAILS_ENV="production" \
|
24
|
+
BUNDLE_DEPLOYMENT="1" \
|
25
|
+
BUNDLE_PATH="/usr/local/bundle" \
|
26
|
+
BUNDLE_WITHOUT="development"
|
27
|
+
|
28
|
+
# Throw-away build stage to reduce size of final image
|
29
|
+
FROM base AS build
|
30
|
+
|
31
|
+
# Install packages needed to build gems
|
32
|
+
RUN apt-get update -qq && \
|
33
|
+
apt-get install --no-install-recommends -y build-essential git pkg-config && \
|
34
|
+
rm -rf /var/lib/apt/lists /var/cache/apt/archives
|
35
|
+
|
36
|
+
# Install application gems
|
37
|
+
COPY Gemfile Gemfile.lock ./
|
38
|
+
RUN bundle install && \
|
39
|
+
rm -rf ~/.bundle/ "${BUNDLE_PATH}"/ruby/*/cache "${BUNDLE_PATH}"/ruby/*/bundler/gems/*/.git && \
|
40
|
+
bundle exec bootsnap precompile --gemfile
|
41
|
+
|
42
|
+
# Copy application code
|
43
|
+
COPY . .
|
44
|
+
|
45
|
+
# Precompile bootsnap code for faster boot times
|
46
|
+
RUN bundle exec bootsnap precompile app/ lib/
|
47
|
+
|
48
|
+
# Precompiling assets for production without requiring secret RAILS_MASTER_KEY
|
49
|
+
RUN SECRET_KEY_BASE_DUMMY=1 ./bin/rails assets:precompile
|
50
|
+
|
51
|
+
|
52
|
+
|
53
|
+
|
54
|
+
# Final stage for app image
|
55
|
+
FROM base
|
56
|
+
|
57
|
+
# Copy built artifacts: gems, application
|
58
|
+
COPY --from=build "${BUNDLE_PATH}" "${BUNDLE_PATH}"
|
59
|
+
COPY --from=build /rails /rails
|
60
|
+
|
61
|
+
# Run and own only the runtime files as a non-root user for security
|
62
|
+
RUN groupadd --system --gid 1000 rails && \
|
63
|
+
useradd rails --uid 1000 --gid 1000 --create-home --shell /bin/bash && \
|
64
|
+
chown -R rails:rails db log storage tmp
|
65
|
+
USER 1000:1000
|
66
|
+
|
67
|
+
# Entrypoint prepares the database.
|
68
|
+
ENTRYPOINT ["/rails/bin/docker-entrypoint"]
|
69
|
+
|
70
|
+
# Start server via Thruster by default, this can be overwritten at runtime
|
71
|
+
EXPOSE 80
|
72
|
+
CMD ["./bin/thrust", "./bin/rails", "server"]
|
@@ -0,0 +1,64 @@
|
|
1
|
+
source "https://rubygems.org"
|
2
|
+
|
3
|
+
# Bundle edge Rails instead: gem "rails", github: "rails/rails", branch: "main"
|
4
|
+
gem "rails", "~> 8.0.0"
|
5
|
+
# The modern asset pipeline for Rails [https://github.com/rails/propshaft]
|
6
|
+
gem "propshaft"
|
7
|
+
# Use sqlite3 as the database for Active Record
|
8
|
+
gem "sqlite3", ">= 2.1"
|
9
|
+
# Use the Puma web server [https://github.com/puma/puma]
|
10
|
+
gem "puma", ">= 5.0"
|
11
|
+
# Use JavaScript with ESM import maps [https://github.com/rails/importmap-rails]
|
12
|
+
gem "importmap-rails"
|
13
|
+
# Hotwire's SPA-like page accelerator [https://turbo.hotwired.dev]
|
14
|
+
gem "turbo-rails"
|
15
|
+
# Hotwire's modest JavaScript framework [https://stimulus.hotwired.dev]
|
16
|
+
gem "stimulus-rails"
|
17
|
+
# Build JSON APIs with ease [https://github.com/rails/jbuilder]
|
18
|
+
gem "jbuilder"
|
19
|
+
gem "async"
|
20
|
+
gem "grpc"
|
21
|
+
# Use Active Model has_secure_password [https://guides.rubyonrails.org/active_model_basics.html#securepassword]
|
22
|
+
# gem "bcrypt", "~> 3.1.7"
|
23
|
+
|
24
|
+
# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
|
25
|
+
gem "tzinfo-data", platforms: %i[ windows jruby ]
|
26
|
+
|
27
|
+
# Use the database-backed adapters for Rails.cache, Active Job, and Action Cable
|
28
|
+
gem "solid_cache"
|
29
|
+
gem "solid_queue"
|
30
|
+
gem "solid_cable"
|
31
|
+
|
32
|
+
# Reduces boot times through caching; required in config/boot.rb
|
33
|
+
gem "bootsnap", require: false
|
34
|
+
|
35
|
+
# Deploy this application anywhere as a Docker container [https://kamal-deploy.org]
|
36
|
+
gem "kamal", require: false
|
37
|
+
|
38
|
+
# Add HTTP asset caching/compression and X-Sendfile acceleration to Puma [https://github.com/basecamp/thruster/]
|
39
|
+
gem "thruster", require: false
|
40
|
+
|
41
|
+
# Use Active Storage variants [https://guides.rubyonrails.org/active_storage_overview.html#transforming-images]
|
42
|
+
# gem "image_processing", "~> 1.2"
|
43
|
+
|
44
|
+
group :development, :test do
|
45
|
+
# See https://guides.rubyonrails.org/debugging_rails_applications.html#debugging-with-the-debug-gem
|
46
|
+
gem "debug", platforms: %i[ mri windows ], require: "debug/prelude"
|
47
|
+
|
48
|
+
# Static analysis for security vulnerabilities [https://brakemanscanner.org/]
|
49
|
+
gem "brakeman", require: false
|
50
|
+
|
51
|
+
# Omakase Ruby styling [https://github.com/rails/rubocop-rails-omakase/]
|
52
|
+
gem "rubocop-rails-omakase", require: false
|
53
|
+
end
|
54
|
+
|
55
|
+
group :development do
|
56
|
+
# Use console on exceptions pages [https://github.com/rails/web-console]
|
57
|
+
gem "web-console"
|
58
|
+
end
|
59
|
+
|
60
|
+
group :test do
|
61
|
+
# Use system testing [https://guides.rubyonrails.org/testing.html#system-testing]
|
62
|
+
gem "capybara"
|
63
|
+
gem "selenium-webdriver"
|
64
|
+
end
|