satorix-rails 0.0.1 → 1.0.11
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/.gitlab-ci.yml +31 -0
- data/.ruby-version +1 -0
- data/Gemfile +2 -0
- data/Procfile +4 -0
- data/README.md +116 -1
- data/Rakefile +2 -2
- data/lib/rails/generators/satorix/custom_ci_job_generator.rb +27 -0
- data/lib/rails/generators/satorix/install_generator.rb +32 -0
- data/lib/rails/generators/templates/custom_ci_job/satorix/CI/deploy/mock_deploy.rb +37 -0
- data/lib/rails/generators/templates/custom_ci_job/satorix/CI/test/bare_bones.rb +25 -0
- data/lib/rails/generators/templates/custom_ci_job/satorix/CI/test/info.rb +96 -0
- data/lib/rails/generators/templates/custom_ci_job/satorix/custom.rb +50 -0
- data/lib/rails/generators/templates/install/.gitlab-ci.yml +132 -0
- data/lib/rails/generators/templates/install/Procfile +6 -0
- data/lib/rails/generators/templates/install/config/passenger_standalone/includes/authentication.erb +14 -0
- data/lib/rails/generators/templates/install/config/passenger_standalone/includes/htpasswd +1 -0
- data/lib/rails/generators/templates/install/config/passenger_standalone/includes/page_level_redirects.erb +16 -0
- data/lib/rails/generators/templates/install/config/passenger_standalone/includes/proxy_configuration.erb +27 -0
- data/lib/rails/generators/templates/install/config/passenger_standalone/nginx.conf.erb +139 -0
- data/lib/satorix/rails/version.rb +3 -1
- data/lib/satorix/rails.rb +1 -7
- data/satorix/CI/deploy/ie_gem_server.rb +80 -0
- data/satorix/custom.rb +21 -0
- data/satorix-rails.gemspec +16 -14
- metadata +38 -8
- data/.travis.yml +0 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a5dbf0b5018c9ce918066276a1dba71c041a7a2f
|
4
|
+
data.tar.gz: 3d9c9065c8f8d85945f8f5a81be09c295f25d9fc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2b8e13947ba20ba173d173af8097bfcd602edce3f5ceac950627baf9489b5fabff1376f3da52811a8787438fad2b997177661427486b31dbb6e96a85ca3b4dd3
|
7
|
+
data.tar.gz: 50872269ddd8cc9f68f35ac4458da9c87643270d21abc68a7f466faebcaa2385495a3ffa377d480d99deaf62169dfefa9462e275df66e8a6c5fbe54f0feb6d8e
|
data/.gitlab-ci.yml
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
image: 'satorix/rails'
|
2
|
+
|
3
|
+
|
4
|
+
.satorix: &satorix
|
5
|
+
script:
|
6
|
+
- bundle # This generates a Gemfile.lock, to make the buildpacks happy
|
7
|
+
- gem install satorix --source https://gems.iexposure.com --no-document
|
8
|
+
- satorix
|
9
|
+
|
10
|
+
|
11
|
+
cache:
|
12
|
+
key: "$CI_PROJECT_ID"
|
13
|
+
paths:
|
14
|
+
- 'tmp/satorix/cache' # To cache buildpack gems between runs.
|
15
|
+
|
16
|
+
|
17
|
+
rspec:
|
18
|
+
before_script:
|
19
|
+
- sed -i -e 's/add_development_dependency/add_dependency/g' satorix-rails.gemspec # To avoid an application dependency, but still be available for CI
|
20
|
+
<<: *satorix
|
21
|
+
|
22
|
+
|
23
|
+
# This is a custom job, defined at satorix/CI/deploy/ie_gem_server.rb
|
24
|
+
deploy_to_ie_gem_server:
|
25
|
+
environment:
|
26
|
+
name: $CI_COMMIT_REF_NAME
|
27
|
+
url: 'http://gems.iexposure.com/gems/satorix-rails'
|
28
|
+
stage: deploy
|
29
|
+
only:
|
30
|
+
- master
|
31
|
+
<<: *satorix
|
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
ruby-2.4.1
|
data/Gemfile
CHANGED
data/Procfile
ADDED
data/README.md
CHANGED
@@ -1,3 +1,118 @@
|
|
1
|
-
#
|
1
|
+
# satorix-rails
|
2
2
|
|
3
3
|
By [Internet Exposure](https://www.iexposure.com/)
|
4
|
+
|
5
|
+
[](http://gitlab.iexposure.com/satorix/satorix-rails/pipelines)
|
6
|
+
[](http://gitlab.iexposure.com/satorix/satorix-rails/pipelines)
|
7
|
+
|
8
|
+
|
9
|
+
[Satorix](http://gitlab.iexposure.com/satorix/satorix) is a full-featured CI/CD pipeline developed by Internet Exposure.
|
10
|
+
|
11
|
+
The satorix-rails gem provides a streamlined mechanism for a 12-factor capable Rails application to interact with the Satorix ecosystem.
|
12
|
+
|
13
|
+
|
14
|
+
## Getting Started
|
15
|
+
|
16
|
+
Add Satorix to your Rails application by including it in your Gemfile with:
|
17
|
+
|
18
|
+
```ruby
|
19
|
+
source 'https://gems.iexposure.com' do
|
20
|
+
gem 'satorix-rails'
|
21
|
+
end
|
22
|
+
```
|
23
|
+
|
24
|
+
Run the bundle command to install it.
|
25
|
+
|
26
|
+
Next, run the generator from a terminal at the root of your application:
|
27
|
+
|
28
|
+
```console
|
29
|
+
$ rails g satorix:install
|
30
|
+
```
|
31
|
+
|
32
|
+
Congratulations, your application is now suitable for deployment into Satorix.
|
33
|
+
|
34
|
+
# Logging in Rails 4 and below
|
35
|
+
|
36
|
+
If you are using Rails version 4 or below, you will need to take an additional step so that your application logs correctly.
|
37
|
+
|
38
|
+
You will need to either:
|
39
|
+
|
40
|
+
* add `gem 'rails_12factor', group: :production` to your Gemfile
|
41
|
+
* Set `config.logger = Logger.new(STDOUT)` in `config/environments/production.rb`
|
42
|
+
|
43
|
+
|
44
|
+
## What's Included
|
45
|
+
|
46
|
+
|
47
|
+
## Environment Variables
|
48
|
+
|
49
|
+
You can configure your application on a per-environment basis using environment variables.
|
50
|
+
|
51
|
+
The following environment variables are used by the generated files:
|
52
|
+
|
53
|
+
Using the Satorix Dashboard? You can relax, all of these variables are automatically configured for you.
|
54
|
+
|
55
|
+
##### SATORIX_AUTHENTICATION_USER_NAMES_AND_PASSWORDS
|
56
|
+
|
57
|
+
Optional
|
58
|
+
|
59
|
+
Hashed usernames:passwords, newline separated
|
60
|
+
|
61
|
+
##### SATORIX_AUTHENTICATION_ALLOWED_IPS
|
62
|
+
|
63
|
+
Optional
|
64
|
+
|
65
|
+
Valid settings:
|
66
|
+
|
67
|
+
* all (`all`)
|
68
|
+
* single IP (`192.168.101.2`)
|
69
|
+
* single IP range (`192.168.101.0/24`)
|
70
|
+
* multiple IPs/ranges (`192.168.101.3 192.168.1.4`)
|
71
|
+
|
72
|
+
##### SATORIX_CANONICAL_URI_HOST
|
73
|
+
|
74
|
+
Optional
|
75
|
+
|
76
|
+
If specified, t
|
77
|
+
|
78
|
+
##### SATORIX_CANONICAL_URI_PROTOCOL
|
79
|
+
|
80
|
+
Optional
|
81
|
+
|
82
|
+
##### SATORIX_PROXY_IPS
|
83
|
+
|
84
|
+
was NGINX_ADDITIONAL_REAL_IPS
|
85
|
+
|
86
|
+
Used to define proxy IP addresses, for services like CloudFlare.
|
87
|
+
|
88
|
+
|
89
|
+
## Contributing
|
90
|
+
|
91
|
+
Please coordinate contributions using the [official issue tracker](http://gitlab.iexposure.com/satorix/satorix-rails/issues).
|
92
|
+
|
93
|
+
|
94
|
+
## Testing
|
95
|
+
|
96
|
+
This application is tested using [rspec](http://rspec.info/).
|
97
|
+
|
98
|
+
You can run the same tests that run during CI with:
|
99
|
+
|
100
|
+
```
|
101
|
+
bundle exec rspec spec
|
102
|
+
```
|
103
|
+
|
104
|
+
|
105
|
+
## CI/CD
|
106
|
+
|
107
|
+
Satorix is used to provide continuous integration and continuous deployment for this application.
|
108
|
+
|
109
|
+
CI is run against every push.
|
110
|
+
|
111
|
+
CD is used to build and publish the gem for the master branch.
|
112
|
+
|
113
|
+
|
114
|
+
|
115
|
+
## License
|
116
|
+
|
117
|
+
|
118
|
+
The Satorix gem is released under the terms described in the [LICENSE file](LICENSE).
|
data/Rakefile
CHANGED
@@ -0,0 +1,27 @@
|
|
1
|
+
module Satorix
|
2
|
+
module Generators
|
3
|
+
class CustomCiJobGenerator < ::Rails::Generators::Base
|
4
|
+
|
5
|
+
source_root File.expand_path('../../templates', __FILE__)
|
6
|
+
|
7
|
+
desc 'Adds Satorix custom CI job functionality and examples to your application.'
|
8
|
+
|
9
|
+
|
10
|
+
def install_satorix
|
11
|
+
template 'custom_ci_job/satorix/custom.rb', 'satorix/custom.rb'
|
12
|
+
template 'custom_ci_job/satorix/CI/deploy/mock_deploy.rb', 'satorix/CI/deploy/mock_deploy.rb'
|
13
|
+
template 'custom_ci_job/satorix/CI/test/bare_bones.rb', 'satorix/CI/test/bare_bones.rb'
|
14
|
+
template 'custom_ci_job/satorix/CI/test/info.rb', 'satorix/CI/test/info.rb'
|
15
|
+
|
16
|
+
say ''
|
17
|
+
say 'Satorix custom CI job examples have been added to your project.'
|
18
|
+
say "Don't forget to add your new jobs to the gitlab-ci.yml file."
|
19
|
+
say ''
|
20
|
+
end
|
21
|
+
|
22
|
+
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
|
@@ -0,0 +1,32 @@
|
|
1
|
+
module Satorix
|
2
|
+
module Generators
|
3
|
+
class InstallGenerator < ::Rails::Generators::Base
|
4
|
+
|
5
|
+
source_root File.expand_path('../../templates', __FILE__)
|
6
|
+
|
7
|
+
desc 'Generators to prepare a Rails application for the Satorix ecosystem.'
|
8
|
+
|
9
|
+
|
10
|
+
def install_satorix
|
11
|
+
template 'install/Procfile', 'Procfile'
|
12
|
+
template 'install/.gitlab-ci.yml', '.gitlab-ci.yml'
|
13
|
+
|
14
|
+
template 'install/config/passenger_standalone/nginx.conf.erb', 'config/passenger_standalone/nginx.conf.erb'
|
15
|
+
|
16
|
+
template 'install/config/passenger_standalone/includes/htpasswd', 'config/passenger_standalone/includes/htpasswd'
|
17
|
+
template 'install/config/passenger_standalone/includes/authentication.erb', 'config/passenger_standalone/includes/authentication.erb'
|
18
|
+
template 'install/config/passenger_standalone/includes/page_level_redirects.erb', 'config/passenger_standalone/includes/page_level_redirects.erb'
|
19
|
+
template 'install/config/passenger_standalone/includes/proxy_configuration.erb', 'config/passenger_standalone/includes/proxy_configuration.erb'
|
20
|
+
|
21
|
+
say ''
|
22
|
+
say 'Satorix installation complete!', "\e[32m"
|
23
|
+
say 'For additional configuration information, please see http://gitlab.iexposure.com/satorix/satorix'
|
24
|
+
say ''
|
25
|
+
end
|
26
|
+
|
27
|
+
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
|
@@ -0,0 +1,37 @@
|
|
1
|
+
module Satorix
|
2
|
+
module CI
|
3
|
+
module Deploy
|
4
|
+
module MockDeploy
|
5
|
+
|
6
|
+
|
7
|
+
include Satorix::Shared::Console
|
8
|
+
|
9
|
+
|
10
|
+
extend self
|
11
|
+
|
12
|
+
|
13
|
+
def go
|
14
|
+
log_bench('Atomic batteries to power...') { batnap }
|
15
|
+
log_bench('Turbines to speed...') { turbines_to_speed }
|
16
|
+
log_bench('Moving out...') { batnap }
|
17
|
+
end
|
18
|
+
|
19
|
+
|
20
|
+
private ########################################################################################################
|
21
|
+
|
22
|
+
|
23
|
+
def turbines_to_speed
|
24
|
+
batnap
|
25
|
+
puts 'Roger. Ready to move out.'
|
26
|
+
end
|
27
|
+
|
28
|
+
|
29
|
+
def batnap
|
30
|
+
sleep(rand(6))
|
31
|
+
end
|
32
|
+
|
33
|
+
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
module Satorix
|
2
|
+
module CI
|
3
|
+
module Test
|
4
|
+
|
5
|
+
# This is the simplest possible implementation of a custom job.
|
6
|
+
module BareBones
|
7
|
+
|
8
|
+
|
9
|
+
extend self
|
10
|
+
|
11
|
+
# go() is the method that will be called during the CI run.
|
12
|
+
# You can add your own logic to do whatever you want.
|
13
|
+
def go
|
14
|
+
# Uncomment the line below if you want to execute in the context of the app's buildpack.
|
15
|
+
# Satorix::CI::Test::Shared::Buildpack.go
|
16
|
+
puts "\n\nRunning BareBones#go..."
|
17
|
+
end
|
18
|
+
|
19
|
+
|
20
|
+
end
|
21
|
+
|
22
|
+
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,96 @@
|
|
1
|
+
module Satorix
|
2
|
+
module CI
|
3
|
+
module Test
|
4
|
+
module Info
|
5
|
+
|
6
|
+
|
7
|
+
include Satorix::Shared::Console
|
8
|
+
|
9
|
+
|
10
|
+
extend self
|
11
|
+
|
12
|
+
# go() is the method that will be called during the CI run.
|
13
|
+
# You can add your own logic to do whatever you want.
|
14
|
+
def go
|
15
|
+
# Uncomment the line below if you want to execute in the context of the app's buildpack.
|
16
|
+
# Satorix::CI::Test::Shared::Buildpack.go
|
17
|
+
|
18
|
+
log_bench('Describing logging...') do
|
19
|
+
describe_log
|
20
|
+
describe_log_error
|
21
|
+
describe_log_error_and_abort
|
22
|
+
end
|
23
|
+
|
24
|
+
log_bench('Describing console commands...') do
|
25
|
+
describe_run_command_string
|
26
|
+
describe_run_command_array
|
27
|
+
describe_run_command_filtered
|
28
|
+
describe_run_command_quiet
|
29
|
+
describe_run_command_with_error
|
30
|
+
end
|
31
|
+
|
32
|
+
log_bench('Describing environment variables...') { describe_environment_variables }
|
33
|
+
end
|
34
|
+
|
35
|
+
|
36
|
+
private ########################################################################################################
|
37
|
+
|
38
|
+
|
39
|
+
def describe_environment_variables
|
40
|
+
puts "Remember, #{ ENV['GITLAB_USER_EMAIL'] }, that you have access to all of the environment variables ",
|
41
|
+
' described at https://docs.gitlab.com/ce/ci/variables/#predefined-variables-environment-variables'
|
42
|
+
end
|
43
|
+
|
44
|
+
|
45
|
+
def describe_log
|
46
|
+
log 'The log() method writes a message to the log'
|
47
|
+
colors.keys.each { |color| log "You can provide an optional color, like :#{ color }", color }
|
48
|
+
end
|
49
|
+
|
50
|
+
|
51
|
+
def describe_log_error
|
52
|
+
log_error 'The log_error() method writes an error to the log'
|
53
|
+
end
|
54
|
+
|
55
|
+
|
56
|
+
def describe_log_error_and_abort
|
57
|
+
log_error 'The log_error_and_abort() method writes an error to the log and aborts the job'
|
58
|
+
rescue SystemExit => e
|
59
|
+
puts 'Rescuing from the error, to continue the tutorial.',
|
60
|
+
e.inspect
|
61
|
+
end
|
62
|
+
|
63
|
+
|
64
|
+
def describe_run_command_string
|
65
|
+
run_command "echo 'We can safely run string console commands with the run_command() method'"
|
66
|
+
end
|
67
|
+
|
68
|
+
|
69
|
+
def describe_run_command_array
|
70
|
+
run_command ['echo', "'We can safely run array console commands with the run_command() method'"]
|
71
|
+
end
|
72
|
+
|
73
|
+
|
74
|
+
def describe_run_command_quiet
|
75
|
+
run_command "echo 'This will not be displayed'", quiet: true
|
76
|
+
end
|
77
|
+
|
78
|
+
|
79
|
+
def describe_run_command_filtered
|
80
|
+
run_command "echo 'You can filter secrets, like 1234 and 5678 (unless you explicitly display them)'", filtered_text: %w(1234 5678)
|
81
|
+
end
|
82
|
+
|
83
|
+
|
84
|
+
def describe_run_command_with_error
|
85
|
+
run_command 'false'
|
86
|
+
rescue SystemExit
|
87
|
+
puts 'Commands that exit with a non-zero return code abort operation, unless rescued.',
|
88
|
+
'Rescuing from the error, to continue the tutorial.',
|
89
|
+
e.inspect
|
90
|
+
end
|
91
|
+
|
92
|
+
|
93
|
+
end
|
94
|
+
end
|
95
|
+
end
|
96
|
+
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
module Satorix
|
2
|
+
module Custom
|
3
|
+
|
4
|
+
# Ensure the files required by the available_jobs method are available.
|
5
|
+
require_relative 'CI/deploy/mock_deploy.rb'
|
6
|
+
require_relative 'CI/test/bare_bones.rb'
|
7
|
+
require_relative 'CI/test/info.rb'
|
8
|
+
|
9
|
+
|
10
|
+
extend self
|
11
|
+
|
12
|
+
|
13
|
+
# Define the custom jobs to be added to the application's Ci pipeline.
|
14
|
+
#
|
15
|
+
# The first tier describes the stage. Default stages are build, test, and deploy.
|
16
|
+
# If desired, you can define your own custom stages in your gitlab-ci.yml file.
|
17
|
+
# For more information about GitLab stages, please refer to https://docs.gitlab.com/ce/ci/yaml/#stages
|
18
|
+
#
|
19
|
+
# The second tier describes the jobs available within each tier, and the class they map to.
|
20
|
+
# The key should be the actual job name to be used in the gitlab-ci.yml file.
|
21
|
+
# The value should be a Ruby class or module with a go() method.
|
22
|
+
#
|
23
|
+
# Example:
|
24
|
+
#
|
25
|
+
# The available_jobs method below defines three new jobs - one for the deploy stage and
|
26
|
+
# two for the test stage. The deploy job is named 'mock_deploy'.
|
27
|
+
# The test jobs are named 'bare_bones_example' and 'info'.
|
28
|
+
#
|
29
|
+
# In this example, the Satorix::CI::Test::Info#go method
|
30
|
+
# will be called by an entry in gitlab-ci.yml that looks like:
|
31
|
+
#
|
32
|
+
# display_info:
|
33
|
+
# stage: test
|
34
|
+
# <<: *satorix
|
35
|
+
#
|
36
|
+
def available_jobs
|
37
|
+
{
|
38
|
+
deploy: {
|
39
|
+
mock_deploy: Satorix::CI::Deploy::MockDeploy
|
40
|
+
},
|
41
|
+
test: {
|
42
|
+
bare_bones_example: Satorix::CI::Test::BareBones,
|
43
|
+
display_info: Satorix::CI::Test::Info
|
44
|
+
}
|
45
|
+
}
|
46
|
+
end
|
47
|
+
|
48
|
+
|
49
|
+
end
|
50
|
+
end
|
@@ -0,0 +1,132 @@
|
|
1
|
+
# We are using the Satorix Rails CI image from https://hub.docker.com/r/satorix/rails/
|
2
|
+
image: 'satorix/rails'
|
3
|
+
|
4
|
+
|
5
|
+
# Global caching directives.
|
6
|
+
cache:
|
7
|
+
key: "$CI_PROJECT_ID"
|
8
|
+
paths:
|
9
|
+
- 'tmp/satorix/cache' # To cache buildpack gems between runs.
|
10
|
+
|
11
|
+
|
12
|
+
.satorix: &satorix
|
13
|
+
script:
|
14
|
+
- gem install satorix --source https://gems.iexposure.com --no-document
|
15
|
+
- satorix
|
16
|
+
|
17
|
+
|
18
|
+
###############################################################################
|
19
|
+
#
|
20
|
+
# Below are resources that will be available as part of the CI pipeline.
|
21
|
+
# Uncomment the resources matching the testing requirements of your application.
|
22
|
+
# Feel free to delete unused/unwanted resource entries.
|
23
|
+
#
|
24
|
+
###############################################################################
|
25
|
+
|
26
|
+
|
27
|
+
# Configure postgresql environment variables (https://hub.docker.com/r/_/postgres/)
|
28
|
+
# These defaults should work well for all implementations.
|
29
|
+
.use_postgres: &use_postgres
|
30
|
+
services:
|
31
|
+
- postgres:9.5
|
32
|
+
variables:
|
33
|
+
DB_HOST: postgres
|
34
|
+
POSTGRES_DB: test
|
35
|
+
POSTGRES_PASSWORD: password
|
36
|
+
POSTGRES_USER: root
|
37
|
+
|
38
|
+
|
39
|
+
## https://github.com/flynn/flynn/issues/3505
|
40
|
+
## https://hub.docker.com/r/_/mariadb/
|
41
|
+
## These defaults should work well for all implementations.
|
42
|
+
#.use_mariadb: &use_mariadb
|
43
|
+
# services:
|
44
|
+
# - mariadb:10.1
|
45
|
+
# variables:
|
46
|
+
# DB_HOST: mariadb
|
47
|
+
# MYSQL_DATABASE: test
|
48
|
+
# MYSQL_ROOT_PASSWORD: password # The default user is: root
|
49
|
+
#
|
50
|
+
|
51
|
+
|
52
|
+
## https://github.com/flynn/flynn/issues/3505
|
53
|
+
## https://hub.docker.com/r/_/mysql/
|
54
|
+
## These defaults should work well for all implementations.
|
55
|
+
#.use_mysql: &use_mysql
|
56
|
+
# services:
|
57
|
+
# - mysql:5.7
|
58
|
+
# variables:
|
59
|
+
# DB_HOST: mysql
|
60
|
+
# MYSQL_DATABASE: test
|
61
|
+
# MYSQL_ROOT_PASSWORD: password # The default user is: root
|
62
|
+
|
63
|
+
|
64
|
+
###############################################################################
|
65
|
+
#
|
66
|
+
# Below are jobs that will run as part of the CI pipeline.
|
67
|
+
# Uncomment the jobs you want to use for your application.
|
68
|
+
# Feel free to delete unused/unwanted job entries.
|
69
|
+
#
|
70
|
+
###############################################################################
|
71
|
+
|
72
|
+
|
73
|
+
## Brakeman
|
74
|
+
## Static analysis security scanner for Ruby on Rails
|
75
|
+
## http://brakemanscanner.org/
|
76
|
+
#brakeman:
|
77
|
+
# variables:
|
78
|
+
# SKIP_BUILDPACK: 'true'
|
79
|
+
# <<: *satorix
|
80
|
+
|
81
|
+
|
82
|
+
## bundler-audit
|
83
|
+
## Patch-level verification for Bundler
|
84
|
+
## https://github.com/rubysec/bundler-audit
|
85
|
+
#bundler_audit:
|
86
|
+
# variables:
|
87
|
+
# SKIP_BUILDPACK: 'true'
|
88
|
+
# <<: *satorix
|
89
|
+
|
90
|
+
|
91
|
+
## Cucumber
|
92
|
+
## Executes executable specifications written in plain language
|
93
|
+
## https://github.com/cucumber/cucumber
|
94
|
+
#cucumber:
|
95
|
+
# <<: *use_postgres
|
96
|
+
# <<: *satorix
|
97
|
+
|
98
|
+
|
99
|
+
## Rails test
|
100
|
+
## Built-in mechanisms in Rails for testing your application
|
101
|
+
## http://guides.rubyonrails.org/testing.html
|
102
|
+
#rails_test:
|
103
|
+
# <<: *use_postgres
|
104
|
+
# <<: *satorix
|
105
|
+
|
106
|
+
|
107
|
+
## RSpec
|
108
|
+
## Behaviour Driven Development for Ruby
|
109
|
+
## http://rspec.info/
|
110
|
+
#rspec:
|
111
|
+
# <<: *use_postgres
|
112
|
+
# <<: *satorix
|
113
|
+
|
114
|
+
|
115
|
+
## RuboCop
|
116
|
+
## A Ruby static code analyzer, based on the community Ruby style guide.
|
117
|
+
## https://github.com/bbatsov/rubocop
|
118
|
+
#rubocop:
|
119
|
+
# variables:
|
120
|
+
# SKIP_BUILDPACK: 'true'
|
121
|
+
# <<: *satorix
|
122
|
+
|
123
|
+
|
124
|
+
deploy_with_flynn:
|
125
|
+
environment:
|
126
|
+
name: $CI_COMMIT_REF_NAME
|
127
|
+
url: "http://$CI_PROJECT_NAME.$CI_COMMIT_REF_SLUG.$SATORIX_HOSTING_NAMESPACE"
|
128
|
+
stage: deploy
|
129
|
+
only:
|
130
|
+
- staging
|
131
|
+
- production
|
132
|
+
<<: *satorix
|
@@ -0,0 +1,6 @@
|
|
1
|
+
# This Procfile defines the types of process that Flynn will run.
|
2
|
+
# For more information, please see the documentation at http://gitlab.iexposure.com/satorix/satorix
|
3
|
+
|
4
|
+
web: bundle exec passenger start -p $PORT --nginx-config-template config/passenger_standalone/nginx.conf.erb --max-pool-size 3
|
5
|
+
# worker: rake jobs:work
|
6
|
+
# clock: bundle exec clockwork config/clock.rb
|
data/lib/rails/generators/templates/install/config/passenger_standalone/includes/authentication.erb
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
|
2
|
+
# Authentication
|
3
|
+
#
|
4
|
+
# Allow listed networks to access without auth, otherwise require password
|
5
|
+
|
6
|
+
satisfy any;
|
7
|
+
<%% ENV['SATORIX_AUTHENTICATION_ALLOWED_IPS'].to_s.split(' ').each do |target| %>
|
8
|
+
allow <%%= target %>;
|
9
|
+
<%% end %>
|
10
|
+
deny all;
|
11
|
+
auth_basic "Please Log In";
|
12
|
+
auth_basic_user_file /app/config/passenger_standalone/includes/htpasswd;
|
13
|
+
|
14
|
+
# End Authentication
|
@@ -0,0 +1 @@
|
|
1
|
+
iestaging:$apr1$b4UNgid/$jVoc0rRDzUfmldUp9.DK8.
|
@@ -0,0 +1,16 @@
|
|
1
|
+
|
2
|
+
# Page-level Redirects
|
3
|
+
#
|
4
|
+
# Define your own custom page-level redirects below.
|
5
|
+
#
|
6
|
+
# Examples:
|
7
|
+
# Standard single page redirects:
|
8
|
+
# location = /old-page-1 { return 301 $scheme://$server_name/new-page-1; }
|
9
|
+
# location = /old-page-2 { return 301 $scheme://$server_name/new-page-2; }
|
10
|
+
# Do not work:
|
11
|
+
# # Redirects to port 8080
|
12
|
+
# location = /asdf2 { return 301 /process; }
|
13
|
+
|
14
|
+
|
15
|
+
|
16
|
+
# End Page-level Redirects
|
@@ -0,0 +1,27 @@
|
|
1
|
+
|
2
|
+
# Proxy Configuration
|
3
|
+
#
|
4
|
+
# Used to configure settings related to Flynn's interaction with proxies.
|
5
|
+
# Add your custom proxy configuration details below.
|
6
|
+
|
7
|
+
<%% if ENV['SATORIX_PROXY_IPS'] %>
|
8
|
+
# Provide additional proxy IPS, as described at http://nginx.org/en/docs/http/ngx_http_realip_module.html.
|
9
|
+
#
|
10
|
+
# This is particularity useful for services like CloudFlare, using the example at:
|
11
|
+
# https://support.cloudflare.com/hc/en-us/articles/200170706-How-do-I-restore-original-visitor-IP-with-Nginx-
|
12
|
+
#
|
13
|
+
# If required, this variable should be populated with a space-separated list of proxy IPs. Example:
|
14
|
+
# 103.21.244.0/22 103.22.200.0/22 103.31.4.0/22 104.16.0.0/12 108.162.192.0/18 2c0f:f248::/32
|
15
|
+
|
16
|
+
real_ip_recursive on;
|
17
|
+
|
18
|
+
<%% ENV['SATORIX_PROXY_IPS'].to_s.split(' ').each do |real_ip| %>
|
19
|
+
set_real_ip_from <%%= real_ip %>;
|
20
|
+
<%% end %>
|
21
|
+
<%% end %>
|
22
|
+
|
23
|
+
# Use the internal Flynn network set X-Forwarded-For header for access IPs.
|
24
|
+
set_real_ip_from 100.100.0.0/16;
|
25
|
+
real_ip_header X-Forwarded-For;
|
26
|
+
|
27
|
+
# End Proxy Configuration
|
@@ -0,0 +1,139 @@
|
|
1
|
+
# passenger start --nginx-config-template config/passenger_standalone/nginx.conf.erb --debug-nginx-config
|
2
|
+
|
3
|
+
|
4
|
+
##########################################################################
|
5
|
+
# Passenger Standalone is built on the same technology that powers
|
6
|
+
# Passenger for Nginx, so any configuration option supported by Passenger
|
7
|
+
# for Nginx can be applied to Passenger Standalone as well. You can do
|
8
|
+
# this by direct editing the Nginx configuration template that is used by
|
9
|
+
# Passenger Standalone.
|
10
|
+
#
|
11
|
+
# This file is the original template. DO NOT EDIT THIS FILE DIRECTLY.
|
12
|
+
# Instead, make a copy of this file and pass the `--nginx-config-template`
|
13
|
+
# parameter to Passenger Standalone.
|
14
|
+
#
|
15
|
+
# Learn more about using the Nginx configuration template at:
|
16
|
+
# https://www.phusionpassenger.com/library/config/standalone/intro.html#nginx-configuration-template
|
17
|
+
#
|
18
|
+
# *** NOTE ***
|
19
|
+
# If you customize the template file, make sure you keep an eye on the
|
20
|
+
# original template file and merge any changes. New Phusion Passenger
|
21
|
+
# features may require changes to the template file.
|
22
|
+
##############################################################
|
23
|
+
|
24
|
+
<%%
|
25
|
+
def include_passenger_custom_template(template)
|
26
|
+
ERB.new(File.read( File.join( File.dirname(__FILE__), 'includes', template ) )).result(binding)
|
27
|
+
end
|
28
|
+
|
29
|
+
def use_canonical?
|
30
|
+
!canonical_domain.nil? &&
|
31
|
+
!canonical_domain.empty? &&
|
32
|
+
!canonical_domain_protocol.nil? &&
|
33
|
+
!canonical_domain_protocol.empty?
|
34
|
+
end
|
35
|
+
|
36
|
+
def canonical_domain
|
37
|
+
ENV['SATORIX_CANONICAL_URI_HOST']
|
38
|
+
end
|
39
|
+
|
40
|
+
def canonical_domain_protocol
|
41
|
+
ENV['SATORIX_CANONICAL_URI_PROTOCOL']
|
42
|
+
end
|
43
|
+
|
44
|
+
def canonical_uri
|
45
|
+
"#{ canonical_domain_protocol }://#{ canonical_domain }" if use_canonical?
|
46
|
+
end
|
47
|
+
%>
|
48
|
+
|
49
|
+
<%%= include_passenger_internal_template('global.erb') %>
|
50
|
+
|
51
|
+
worker_processes 1;
|
52
|
+
events {
|
53
|
+
worker_connections 4096;
|
54
|
+
}
|
55
|
+
|
56
|
+
http {
|
57
|
+
<%%= include_passenger_internal_template('http.erb', 4) %>
|
58
|
+
|
59
|
+
### BEGIN your own configuration options ###
|
60
|
+
# This is a good place to put your own config
|
61
|
+
# options. Note that your options must not
|
62
|
+
# conflict with the ones Passenger already sets.
|
63
|
+
# Learn more at:
|
64
|
+
# https://www.phusionpassenger.com/library/config/standalone/intro.html#nginx-configuration-template
|
65
|
+
|
66
|
+
### END your own configuration options ###
|
67
|
+
|
68
|
+
default_type application/octet-stream;
|
69
|
+
types_hash_max_size 2048;
|
70
|
+
server_names_hash_bucket_size 96;
|
71
|
+
client_max_body_size 1024m;
|
72
|
+
access_log off;
|
73
|
+
keepalive_timeout 60;
|
74
|
+
underscores_in_headers on;
|
75
|
+
gzip on;
|
76
|
+
gzip_comp_level 3;
|
77
|
+
gzip_min_length 150;
|
78
|
+
gzip_proxied any;
|
79
|
+
gzip_types text/plain text/css text/json text/javascript
|
80
|
+
application/javascript application/x-javascript application/json
|
81
|
+
application/rss+xml application/vnd.ms-fontobject application/x-font-ttf
|
82
|
+
application/xml font/opentype image/svg+xml text/xml;
|
83
|
+
|
84
|
+
<%% if @app_finder.multi_mode? %>
|
85
|
+
# Default server entry for mass deployment mode.
|
86
|
+
server {
|
87
|
+
<%%= include_passenger_internal_template('mass_deployment_default_server.erb', 12) %>
|
88
|
+
}
|
89
|
+
<%% end %>
|
90
|
+
|
91
|
+
<%% @apps.each do |app| %>
|
92
|
+
|
93
|
+
<%% if use_canonical? %>
|
94
|
+
# Redirect all requests to the canonical domain.
|
95
|
+
server {
|
96
|
+
server_name <%%= app[:server_names].join(' ') %>;
|
97
|
+
listen <%%= nginx_listen_address(app) %> default_server;
|
98
|
+
|
99
|
+
return 301 <%%= canonical_uri %>$request_uri;
|
100
|
+
}
|
101
|
+
<%% else %>
|
102
|
+
# No canonical domain defined, passing all requests to the main server block.
|
103
|
+
<%% end %>
|
104
|
+
|
105
|
+
# Main server block.
|
106
|
+
server {
|
107
|
+
<%% app[:server_names] = [canonical_domain] if use_canonical? %>
|
108
|
+
<%%= include_passenger_internal_template('server.erb', 8, true, binding) %>
|
109
|
+
<%%= include_passenger_internal_template('rails_asset_pipeline.erb', 8, false) %>
|
110
|
+
|
111
|
+
<%%= include_passenger_custom_template('page_level_redirects.erb') %>
|
112
|
+
<%%= include_passenger_custom_template('proxy_configuration.erb') %>
|
113
|
+
<%%= include_passenger_custom_template('authentication.erb') %>
|
114
|
+
|
115
|
+
### BEGIN your own configuration options ###
|
116
|
+
# This is a good place to put your own config options.
|
117
|
+
# Note that your options must not conflict with the ones Passenger already sets.
|
118
|
+
#
|
119
|
+
# Learn more at:
|
120
|
+
# https://www.phusionpassenger.com/library/config/standalone/intro.html#nginx-configuration-template
|
121
|
+
#
|
122
|
+
# You can use the include_passenger_custom_template to method include your own custom template.
|
123
|
+
# This will help you compartmentalize your configurations, to help organize your settings.
|
124
|
+
#
|
125
|
+
# Example:
|
126
|
+
#
|
127
|
+
# Create a new file for your new logic ( /config/passenger_standalone/includes/my_new_logic.erb )
|
128
|
+
# Add your custom logic to your newly created file.
|
129
|
+
# Add your file to the area below, in an ERB block ( include_passenger_custom_template('my_new_logic.erb') )
|
130
|
+
|
131
|
+
|
132
|
+
### END your own configuration options ###
|
133
|
+
}
|
134
|
+
|
135
|
+
passenger_pre_start <%%= listen_url(app) %>;
|
136
|
+
<%% end %>
|
137
|
+
|
138
|
+
<%%= include_passenger_internal_template('footer.erb', 4) %>
|
139
|
+
}
|
data/lib/satorix/rails.rb
CHANGED
@@ -0,0 +1,80 @@
|
|
1
|
+
module Satorix
|
2
|
+
module CI
|
3
|
+
module Deploy
|
4
|
+
module IeGemServer
|
5
|
+
|
6
|
+
|
7
|
+
require 'fileutils'
|
8
|
+
|
9
|
+
|
10
|
+
include Satorix::Shared::Console
|
11
|
+
|
12
|
+
|
13
|
+
extend self
|
14
|
+
|
15
|
+
|
16
|
+
def go
|
17
|
+
log_bench('Installing the geminabox gem...') { install_geminabox_gem }
|
18
|
+
log_bench('Preparing gem build directory...') { prepare_gem_build_directory }
|
19
|
+
log_bench('Building gem...') { build_gem }
|
20
|
+
built_gems.each { |gem| log_bench("Publishing #{ File.basename gem }...") { publish_gem gem } }
|
21
|
+
end
|
22
|
+
|
23
|
+
|
24
|
+
private ########################################################################################################
|
25
|
+
|
26
|
+
|
27
|
+
def build_gem
|
28
|
+
run_command 'rake build'
|
29
|
+
end
|
30
|
+
|
31
|
+
|
32
|
+
def built_gems
|
33
|
+
Dir.glob(File.join(gem_build_directory, '*.gem')).select { |e| File.file? e }
|
34
|
+
end
|
35
|
+
|
36
|
+
|
37
|
+
def gem_build_directory
|
38
|
+
File.join Satorix.app_root, 'pkg'
|
39
|
+
end
|
40
|
+
|
41
|
+
|
42
|
+
def ie_gem_server_host
|
43
|
+
"https://#{ ie_gem_server_user_name }:#{ ie_gem_server_password }@gems.iexposure.com"
|
44
|
+
end
|
45
|
+
|
46
|
+
|
47
|
+
def ie_gem_server_password
|
48
|
+
ENV['SATORIX_CI_IE_GEM_SERVER_PASSWORD']
|
49
|
+
end
|
50
|
+
|
51
|
+
|
52
|
+
def ie_gem_server_user_name
|
53
|
+
ENV['SATORIX_CI_IE_GEM_SERVER_USER_NAME']
|
54
|
+
end
|
55
|
+
|
56
|
+
|
57
|
+
def install_geminabox_gem
|
58
|
+
run_command 'gem install geminabox --source https://gems.iexposure.com --no-document'
|
59
|
+
end
|
60
|
+
|
61
|
+
|
62
|
+
def prepare_gem_build_directory
|
63
|
+
run_command "rm -rf #{ gem_build_directory }"
|
64
|
+
FileUtils.mkdir_p gem_build_directory
|
65
|
+
end
|
66
|
+
|
67
|
+
|
68
|
+
def publish_gem(gem)
|
69
|
+
run_command "gem inabox #{ gem } --host #{ ie_gem_server_host }",
|
70
|
+
filtered_text: [ie_gem_server_user_name, ie_gem_server_password]
|
71
|
+
rescue RuntimeError
|
72
|
+
# To prevent the display of an ugly stacktrace.
|
73
|
+
abort "\nGem was not published!"
|
74
|
+
end
|
75
|
+
|
76
|
+
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
data/satorix/custom.rb
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
module Satorix
|
2
|
+
module Custom
|
3
|
+
|
4
|
+
|
5
|
+
require_relative 'CI/deploy/ie_gem_server.rb'
|
6
|
+
|
7
|
+
|
8
|
+
extend self
|
9
|
+
|
10
|
+
|
11
|
+
def available_jobs
|
12
|
+
{
|
13
|
+
deploy: {
|
14
|
+
deploy_to_ie_gem_server: Satorix::CI::Deploy::IeGemServer
|
15
|
+
}
|
16
|
+
}
|
17
|
+
end
|
18
|
+
|
19
|
+
|
20
|
+
end
|
21
|
+
end
|
data/satorix-rails.gemspec
CHANGED
@@ -4,14 +4,14 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
4
|
require 'satorix/rails/version'
|
5
5
|
|
6
6
|
Gem::Specification.new do |spec|
|
7
|
-
spec.name
|
8
|
-
spec.version
|
9
|
-
spec.authors
|
10
|
-
spec.email
|
7
|
+
spec.name = 'satorix-rails'
|
8
|
+
spec.version = Satorix::Rails::Version::VERSION
|
9
|
+
spec.authors = ['Internet Exposure']
|
10
|
+
spec.email = ['info@satorix.com']
|
11
11
|
|
12
|
-
spec.summary
|
13
|
-
spec.description
|
14
|
-
spec.homepage
|
12
|
+
spec.summary = 'Satorix in Rails'
|
13
|
+
spec.description = 'The satorix-rails gem provides a streamlined mechanism for a Rails application to interact with the Satorix ecosystem.'
|
14
|
+
spec.homepage = 'https://www.satorix.com'
|
15
15
|
|
16
16
|
# Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
|
17
17
|
# to allow pushing to a single host or delete this section to allow pushing to any host.
|
@@ -21,14 +21,16 @@ Gem::Specification.new do |spec|
|
|
21
21
|
raise 'RubyGems 2.0 or newer is required to protect against public gem pushes.'
|
22
22
|
end
|
23
23
|
|
24
|
-
spec.files
|
24
|
+
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
25
25
|
f.match(%r{^(test|spec|features)/})
|
26
26
|
end
|
27
|
-
spec.bindir
|
28
|
-
spec.executables
|
29
|
-
spec.require_paths = [
|
27
|
+
spec.bindir = 'exe'
|
28
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
29
|
+
spec.require_paths = ['lib']
|
30
30
|
|
31
|
-
spec.
|
32
|
-
|
33
|
-
spec.add_development_dependency
|
31
|
+
spec.add_dependency 'passenger'
|
32
|
+
|
33
|
+
spec.add_development_dependency 'bundler', '~> 1.13'
|
34
|
+
spec.add_development_dependency 'rake', '~> 10.0'
|
35
|
+
spec.add_development_dependency 'rspec', '~> 3.0'
|
34
36
|
end
|
metadata
CHANGED
@@ -1,16 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: satorix-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 1.0.11
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
|
-
-
|
8
|
-
- Bret Baptist
|
7
|
+
- Internet Exposure
|
9
8
|
autorequire:
|
10
9
|
bindir: exe
|
11
10
|
cert_chain: []
|
12
|
-
date:
|
11
|
+
date: 2017-08-16 00:00:00.000000000 Z
|
13
12
|
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: passenger
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
14
27
|
- !ruby/object:Gem::Dependency
|
15
28
|
name: bundler
|
16
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -56,23 +69,40 @@ dependencies:
|
|
56
69
|
description: The satorix-rails gem provides a streamlined mechanism for a Rails application
|
57
70
|
to interact with the Satorix ecosystem.
|
58
71
|
email:
|
59
|
-
- satorix
|
72
|
+
- info@satorix.com
|
60
73
|
executables: []
|
61
74
|
extensions: []
|
62
75
|
extra_rdoc_files: []
|
63
76
|
files:
|
64
77
|
- ".gitignore"
|
78
|
+
- ".gitlab-ci.yml"
|
65
79
|
- ".rspec"
|
66
|
-
- ".
|
80
|
+
- ".ruby-version"
|
67
81
|
- Gemfile
|
82
|
+
- Procfile
|
68
83
|
- README.md
|
69
84
|
- Rakefile
|
70
85
|
- bin/console
|
71
86
|
- bin/setup
|
87
|
+
- lib/rails/generators/satorix/custom_ci_job_generator.rb
|
88
|
+
- lib/rails/generators/satorix/install_generator.rb
|
89
|
+
- lib/rails/generators/templates/custom_ci_job/satorix/CI/deploy/mock_deploy.rb
|
90
|
+
- lib/rails/generators/templates/custom_ci_job/satorix/CI/test/bare_bones.rb
|
91
|
+
- lib/rails/generators/templates/custom_ci_job/satorix/CI/test/info.rb
|
92
|
+
- lib/rails/generators/templates/custom_ci_job/satorix/custom.rb
|
93
|
+
- lib/rails/generators/templates/install/.gitlab-ci.yml
|
94
|
+
- lib/rails/generators/templates/install/Procfile
|
95
|
+
- lib/rails/generators/templates/install/config/passenger_standalone/includes/authentication.erb
|
96
|
+
- lib/rails/generators/templates/install/config/passenger_standalone/includes/htpasswd
|
97
|
+
- lib/rails/generators/templates/install/config/passenger_standalone/includes/page_level_redirects.erb
|
98
|
+
- lib/rails/generators/templates/install/config/passenger_standalone/includes/proxy_configuration.erb
|
99
|
+
- lib/rails/generators/templates/install/config/passenger_standalone/nginx.conf.erb
|
72
100
|
- lib/satorix/rails.rb
|
73
101
|
- lib/satorix/rails/version.rb
|
74
102
|
- satorix-rails.gemspec
|
75
|
-
|
103
|
+
- satorix/CI/deploy/ie_gem_server.rb
|
104
|
+
- satorix/custom.rb
|
105
|
+
homepage: https://www.satorix.com
|
76
106
|
licenses: []
|
77
107
|
metadata:
|
78
108
|
allowed_push_host: https://rubygems.org
|
@@ -92,7 +122,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
92
122
|
version: '0'
|
93
123
|
requirements: []
|
94
124
|
rubyforge_project:
|
95
|
-
rubygems_version: 2.
|
125
|
+
rubygems_version: 2.6.11
|
96
126
|
signing_key:
|
97
127
|
specification_version: 4
|
98
128
|
summary: Satorix in Rails
|