├── .github └── workflows │ └── ci.yml ├── .gitignore ├── .toys ├── .toys.rb └── build.rb ├── CONTRIB.md ├── Gemfile ├── Gemfile.lock ├── LICENSE ├── README.md ├── app-engine-exec-wrapper ├── Dockerfile ├── README.md ├── cloudbuild.yaml └── execute.sh ├── build-app-engine-exec-wrapper.sh ├── build-ruby-binary-images.sh ├── build-ruby-runtime-images.sh ├── build-ruby-runtime-pipeline.sh ├── integration_test ├── builder_app │ ├── Gemfile │ ├── Gemfile.lock │ ├── app.yaml │ ├── myapp.rb │ ├── runtimes.yaml │ └── test.yaml.in ├── deploy_check │ ├── Gemfile │ ├── Gemfile.lock │ ├── app.rb │ ├── app.yaml │ └── app.yaml.in └── simple_app │ ├── Dockerfile.in │ ├── Gemfile │ ├── Gemfile.lock │ ├── app.yaml │ └── myapp.rb ├── obsolete ├── Dockerfile ├── README.md └── rake_image │ ├── Dockerfile │ └── cloudbuild.yaml ├── release-app-engine-exec-wrapper.sh ├── release-ruby-binary-images.sh ├── release-ruby-runtime-images.sh ├── release-ruby-runtime-pipeline.sh ├── ruby-base ├── Dockerfile-default.in ├── Dockerfile-prebuilt.in ├── README.md ├── cloudbuild.yaml └── structure-test.json ├── ruby-build-tools ├── Dockerfile ├── access_cloud_sql └── cloudbuild.yaml ├── ruby-generate-dockerfile ├── Dockerfile ├── app │ ├── Dockerfile.erb │ ├── app_config.rb │ ├── generate_dockerfile.rb │ └── generate_dockerfile.sh └── cloudbuild.yaml ├── ruby-pipeline ├── ruby-latest.yaml └── ruby-template.yaml.in ├── ruby-prebuilt ├── Dockerfile.in └── cloudbuild.yaml ├── ruby-ubuntu16 ├── Dockerfile.in ├── README.md ├── cloudbuild.yaml ├── files │ ├── .bundle │ │ └── config │ └── .gemrc └── structure-test.json ├── ruby-ubuntu20 ├── Dockerfile.in ├── README.md ├── cloudbuild.yaml ├── files │ ├── .bundle │ │ └── config │ └── .gemrc └── structure-test.json ├── runtime-config.env ├── test ├── app_config │ ├── bad-ruby-version │ │ └── .ruby-version │ ├── gemfile-old │ │ ├── Gemfile │ │ └── Gemfile.lock │ ├── gemfile-rack │ │ ├── config.ru │ │ ├── gems.locked │ │ └── gems.rb │ ├── gemfile-ruby │ │ └── gems.rb │ ├── rails │ │ ├── app │ │ │ └── assets │ │ │ │ └── .gitkeep │ │ └── config │ │ │ └── application.rb │ └── ruby-version │ │ └── .ruby-version ├── app_engine_exec_wrapper │ ├── harness │ │ ├── Dockerfile │ │ └── fake_cloud_sql_proxy.rb │ ├── no_cloudsql │ │ ├── Dockerfile │ │ └── run.rb │ └── simple │ │ ├── Dockerfile │ │ └── run.rb ├── builder_cases │ ├── rack_app │ │ └── app.yaml │ ├── rails4_app │ │ └── app.yaml │ ├── rails5_app │ │ ├── .ruby-version │ │ └── app.yaml │ └── sinatra1_app │ │ ├── .ruby-version │ │ └── app.yaml ├── helper.rb ├── sample_apps │ ├── rack_app │ │ ├── Gemfile │ │ ├── Gemfile.lock │ │ └── config.ru │ ├── rails4_app │ │ ├── .gitignore │ │ ├── Gemfile │ │ ├── Gemfile.lock │ │ ├── Rakefile │ │ ├── app │ │ │ ├── assets │ │ │ │ ├── images │ │ │ │ │ └── .keep │ │ │ │ └── stylesheets │ │ │ │ │ └── application.css │ │ │ ├── controllers │ │ │ │ ├── application_controller.rb │ │ │ │ ├── concerns │ │ │ │ │ └── .keep │ │ │ │ └── home_controller.rb │ │ │ ├── helpers │ │ │ │ └── application_helper.rb │ │ │ ├── mailers │ │ │ │ └── .keep │ │ │ ├── models │ │ │ │ ├── .keep │ │ │ │ └── concerns │ │ │ │ │ └── .keep │ │ │ └── views │ │ │ │ └── layouts │ │ │ │ └── application.html.erb │ │ ├── bin │ │ │ ├── bundle │ │ │ ├── rails │ │ │ ├── rake │ │ │ └── setup │ │ ├── config.ru │ │ ├── config │ │ │ ├── application.rb │ │ │ ├── boot.rb │ │ │ ├── environment.rb │ │ │ ├── environments │ │ │ │ ├── development.rb │ │ │ │ ├── production.rb │ │ │ │ └── test.rb │ │ │ ├── initializers │ │ │ │ ├── assets.rb │ │ │ │ ├── backtrace_silencers.rb │ │ │ │ ├── cookies_serializer.rb │ │ │ │ ├── filter_parameter_logging.rb │ │ │ │ ├── inflections.rb │ │ │ │ ├── mime_types.rb │ │ │ │ ├── session_store.rb │ │ │ │ ├── to_time_preserves_timezone.rb │ │ │ │ └── wrap_parameters.rb │ │ │ ├── locales │ │ │ │ └── en.yml │ │ │ ├── routes.rb │ │ │ └── secrets.yml │ │ ├── db │ │ │ └── seeds.rb │ │ ├── lib │ │ │ ├── assets │ │ │ │ └── .keep │ │ │ └── tasks │ │ │ │ └── .keep │ │ ├── log │ │ │ └── .keep │ │ ├── public │ │ │ ├── 404.html │ │ │ ├── 422.html │ │ │ ├── 500.html │ │ │ ├── favicon.ico │ │ │ └── robots.txt │ │ └── vendor │ │ │ └── assets │ │ │ └── stylesheets │ │ │ └── .keep │ ├── rails5_app │ │ ├── .gitignore │ │ ├── Gemfile │ │ ├── Gemfile.lock │ │ ├── README.md │ │ ├── Rakefile │ │ ├── app │ │ │ ├── assets │ │ │ │ ├── config │ │ │ │ │ └── manifest.js │ │ │ │ ├── images │ │ │ │ │ └── .keep │ │ │ │ ├── javascripts │ │ │ │ │ ├── application.js │ │ │ │ │ ├── cable.js │ │ │ │ │ └── channels │ │ │ │ │ │ └── .keep │ │ │ │ └── stylesheets │ │ │ │ │ └── application.css │ │ │ ├── channels │ │ │ │ └── application_cable │ │ │ │ │ ├── channel.rb │ │ │ │ │ └── connection.rb │ │ │ ├── controllers │ │ │ │ ├── application_controller.rb │ │ │ │ ├── concerns │ │ │ │ │ └── .keep │ │ │ │ └── home_controller.rb │ │ │ ├── helpers │ │ │ │ └── application_helper.rb │ │ │ ├── jobs │ │ │ │ └── application_job.rb │ │ │ ├── mailers │ │ │ │ └── application_mailer.rb │ │ │ ├── models │ │ │ │ ├── application_record.rb │ │ │ │ └── concerns │ │ │ │ │ └── .keep │ │ │ └── views │ │ │ │ └── layouts │ │ │ │ ├── application.html.erb │ │ │ │ ├── mailer.html.erb │ │ │ │ └── mailer.text.erb │ │ ├── bin │ │ │ ├── bundle │ │ │ ├── rails │ │ │ ├── rake │ │ │ ├── setup │ │ │ ├── spring │ │ │ └── update │ │ ├── config.ru │ │ ├── config │ │ │ ├── application.rb │ │ │ ├── boot.rb │ │ │ ├── cable.yml │ │ │ ├── database.yml │ │ │ ├── environment.rb │ │ │ ├── environments │ │ │ │ ├── development.rb │ │ │ │ ├── production.rb │ │ │ │ └── test.rb │ │ │ ├── initializers │ │ │ │ ├── application_controller_renderer.rb │ │ │ │ ├── assets.rb │ │ │ │ ├── backtrace_silencers.rb │ │ │ │ ├── cookies_serializer.rb │ │ │ │ ├── filter_parameter_logging.rb │ │ │ │ ├── inflections.rb │ │ │ │ ├── mime_types.rb │ │ │ │ ├── new_framework_defaults.rb │ │ │ │ ├── session_store.rb │ │ │ │ └── wrap_parameters.rb │ │ │ ├── locales │ │ │ │ └── en.yml │ │ │ ├── puma.rb │ │ │ ├── routes.rb │ │ │ ├── secrets.yml │ │ │ └── spring.rb │ │ ├── db │ │ │ └── seeds.rb │ │ ├── lib │ │ │ ├── assets │ │ │ │ └── .keep │ │ │ └── tasks │ │ │ │ └── .keep │ │ ├── log │ │ │ └── .keep │ │ ├── public │ │ │ ├── 404.html │ │ │ ├── 422.html │ │ │ ├── 500.html │ │ │ ├── apple-touch-icon-precomposed.png │ │ │ ├── apple-touch-icon.png │ │ │ ├── favicon.ico │ │ │ └── robots.txt │ │ ├── test │ │ │ ├── controllers │ │ │ │ └── .keep │ │ │ ├── fixtures │ │ │ │ ├── .keep │ │ │ │ └── files │ │ │ │ │ └── .keep │ │ │ ├── helpers │ │ │ │ └── .keep │ │ │ ├── integration │ │ │ │ └── .keep │ │ │ ├── mailers │ │ │ │ └── .keep │ │ │ ├── models │ │ │ │ └── .keep │ │ │ └── test_helper.rb │ │ ├── tmp │ │ │ └── .keep │ │ └── vendor │ │ │ └── assets │ │ │ ├── javascripts │ │ │ └── .keep │ │ │ └── stylesheets │ │ │ └── .keep │ └── sinatra1_app │ │ ├── Dockerfile.in │ │ ├── Gemfile │ │ ├── Gemfile.lock │ │ ├── app.yaml │ │ └── myapp.rb ├── test_app_config.rb ├── test_app_engine_exec_wrapper.rb ├── test_base_image_sample_apps.rb ├── test_base_image_structure.rb ├── test_base_ruby_versions.rb ├── test_build_tools.rb ├── test_generate_dockerfile.rb ├── test_sample_app_builds.rb └── test_ubuntu_image_structure.rb └── tools └── ci-scripts ├── binary-build.sh ├── deploy_check.sh ├── integration-test.sh └── release.sh /.github/workflows/ci.yml: -------------------------------------------------------------------------------- 1 | name: "CI tests" 2 | 3 | on: 4 | pull_request: 5 | branches: 6 | - master 7 | push: 8 | branches: 9 | - master 10 | workflow_dispatch: 11 | 12 | jobs: 13 | tests: 14 | if: ${{ github.repository == 'GoogleCloudPlatform/ruby-docker' }} 15 | runs-on: ubuntu-latest 16 | steps: 17 | - name: Install Ruby 2.7 18 | uses: ruby/setup-ruby@v1 19 | with: 20 | ruby-version: "2.7" 21 | - name: Checkout repo 22 | uses: actions/checkout@v2 23 | - name: Install dependencies 24 | shell: bash 25 | run: "bundle install && gem install --no-document toys" 26 | - name: Build 27 | shell: bash 28 | run: toys build 29 | - name: Test 30 | shell: bash 31 | run: toys test --faster 32 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | /test/tmp 2 | /tmp 3 | /ruby-base/Dockerfile 4 | /ruby-prebuilt/Dockerfile 5 | /ruby-ubuntu*/Dockerfile 6 | -------------------------------------------------------------------------------- /.toys/.toys.rb: -------------------------------------------------------------------------------- 1 | # Copyright 2022 Google LLC 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | mixin "runtime-params" do 16 | on_include do 17 | File.readlines("#{context_directory}/runtime-config.env").each do |line| 18 | if line =~ /^([A-Z][A-Z0-9_]*)=(.*)$/ 19 | match = Regexp.last_match 20 | name_str = match[1] 21 | name_sym = name_str.downcase.to_sym 22 | value = match[2] 23 | static name_sym, value 24 | ENV[name_str] = value 25 | end 26 | end 27 | all_versions = [] 28 | default_version = nil 29 | File.readlines("#{context_directory}/ruby-pipeline/ruby-latest.yaml").each do |line| 30 | all_versions << Regexp.last_match[1] if line =~ /([\d\.]+)=gcr\.io/ 31 | default_version = Regexp.last_match[1] if line =~ /--default-ruby-version=([\d\.]+)/ 32 | end 33 | all_versions = all_versions.join "," 34 | static :all_prebuilt_ruby_versions, all_versions 35 | static :default_ruby_version, default_version 36 | ENV["ALL_PREBUILT_RUBY_VERSIONS"] = all_versions 37 | ENV["DEFAULT_RUBY_VERSION"] = default_version 38 | end 39 | end 40 | 41 | tool "build" do 42 | desc "Build all images locally" 43 | 44 | flag :project, "--project=PROJECT", default: "gcp-runtimes" 45 | flag :os_name, "--os-name=NAME", default: "ubuntu20" 46 | flag :use_local_prebuilt 47 | 48 | include :exec, e: true 49 | include "runtime-params" 50 | 51 | def run 52 | cmd = [ 53 | "build", "os-image", 54 | "--os-name", os_name, 55 | "--bundler2-version", bundler2_version, 56 | "--nodejs-version", nodejs_version, 57 | "--ssl10-version", ssl10_version 58 | ] 59 | exec_tool cmd 60 | exec_tool cmd + ["--use-ssl10-dev"] 61 | if use_local_prebuilt 62 | cmd = ["build", "prebuilt", "--os-name", os_name] + primary_ruby_versions.split(",") 63 | exec_tool cmd 64 | end 65 | cmd = [ 66 | "build", "basic", 67 | "--use-prebuilt-binary", 68 | "--os-name", os_name, 69 | "--ruby-version", basic_ruby_version, 70 | "--bundler1-version", bundler1_version, 71 | "--bundler2-version", bundler2_version 72 | ] 73 | cmd << "--use-local-prebuilt" if use_local_prebuilt 74 | exec_tool cmd 75 | exec_tool [ 76 | "build", "build-tools", 77 | "--gcloud-version", gcloud_version, 78 | "--bundler1-version", bundler1_version, 79 | "--bundler2-version", bundler2_version 80 | ] 81 | cmd = [ 82 | "build", "generate-dockerfile", 83 | "--os-name", os_name, 84 | "--default-ruby-version", default_ruby_version, 85 | "--bundler1-version", bundler1_version, 86 | "--bundler2-version", bundler2_version 87 | ] 88 | if use_local_prebuilt 89 | primary_ruby_versions.split(",").each do |version| 90 | cmd << "--prebuilt-image=#{version}=ruby-prebuilt-#{version}:latest" 91 | end 92 | else 93 | all_prebuilt_ruby_versions.split(",").each do |version| 94 | cmd << "--prebuilt-image=#{version}=gcr.io/#{project}/ruby/#{os_name}/prebuilt/ruby-#{version}:latest" 95 | end 96 | end 97 | exec_tool cmd 98 | exec_tool ["build", "app-engine-exec-wrapper"] 99 | exec_tool ["build", "app-engine-exec-harness"] 100 | end 101 | end 102 | 103 | tool "test" do 104 | desc "Run all tests" 105 | 106 | flag :project, "--project=PROJECT", default: "gcp-runtimes" 107 | flag :os_name, "--os-name=NAME", default: "ubuntu20" 108 | flag :use_local_prebuilt 109 | flag :faster 110 | remaining_args :tests 111 | 112 | include :exec, e: true 113 | include "runtime-params" 114 | 115 | def run 116 | env = { 117 | "PREBUILT_RUBY_IMAGE_TAG" => "latest", 118 | "PREBUILT_RUBY_VERSIONS" => all_prebuilt_ruby_versions, 119 | "PRIMARY_RUBY_VERSIONS" => primary_ruby_versions, 120 | "BUNDLER1_VERSION" => bundler1_version, 121 | "BUNDLER2_VERSION" => bundler2_version, 122 | "TESTING_OS_NAME" => os_name 123 | } 124 | env["USE_LOCAL_PREBUILT"] = "true" if use_local_prebuilt 125 | env["FASTER_TESTS"] = "true" if faster 126 | env["PREBUILT_RUBY_IMAGE_BASE"] = use_local_prebuilt ? "ruby-prebuilt-" : "gcr.io/#{project}/ruby/#{os_name}/prebuilt/ruby-" 127 | cmd = ["_test"] + tests 128 | exec_tool cmd, env: env 129 | end 130 | end 131 | 132 | expand :minitest, name: "_test", files: ["test/test*.rb"] 133 | -------------------------------------------------------------------------------- /CONTRIB.md: -------------------------------------------------------------------------------- 1 | # How to become a contributor and submit your own code 2 | 3 | ## Contributor License Agreements 4 | 5 | We'd love to accept your patches! Before we can take them, we have to jump a couple of legal hurdles. 6 | 7 | Please fill out either the individual or corporate Contributor License Agreement (CLA). 8 | 9 | * If you are an individual writing original source code and you're sure you own the intellectual property, then you'll need to sign an [individual CLA](http://code.google.com/legal/individual-cla-v1.0.html). 10 | * If you work for a company that wants to allow you to contribute your work, then you'll need to sign a [corporate CLA](http://code.google.com/legal/corporate-cla-v1.0.html). 11 | 12 | Follow either of the two links above to access the appropriate CLA and instructions for how to sign and return it. Once we receive it, we'll be able to accept your pull requests. 13 | 14 | ## Contributing A Patch 15 | 16 | 1. Submit an issue describing your proposed change to the repo in question. 17 | 1. The repo owner will respond to your issue promptly. 18 | 1. If your proposed change is accepted, and you haven't already done so, sign a Contributor License Agreement (see details above). 19 | 1. Fork the desired repo, develop and test your code changes. 20 | 1. Submit a pull request. 21 | -------------------------------------------------------------------------------- /Gemfile: -------------------------------------------------------------------------------- 1 | source 'https://rubygems.org' 2 | 3 | gem "minitest", "~> 5.16" 4 | gem "minitest-focus", "~> 1.1" 5 | gem "minitest-rg", "~> 5.2" 6 | -------------------------------------------------------------------------------- /Gemfile.lock: -------------------------------------------------------------------------------- 1 | GEM 2 | remote: https://rubygems.org/ 3 | specs: 4 | minitest (5.16.1) 5 | minitest-focus (1.3.1) 6 | minitest (>= 4, < 6) 7 | minitest-rg (5.2.0) 8 | minitest (~> 5.0) 9 | 10 | PLATFORMS 11 | ruby 12 | 13 | DEPENDENCIES 14 | minitest (~> 5.16) 15 | minitest-focus (~> 1.1) 16 | minitest-rg (~> 5.2) 17 | 18 | BUNDLED WITH 19 | 2.2.33 20 | -------------------------------------------------------------------------------- /app-engine-exec-wrapper/Dockerfile: -------------------------------------------------------------------------------- 1 | # Copyright 2017 Google Inc. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | FROM gcr.io/cloud-builders/docker:latest 16 | 17 | # Install cloud_sql_proxy and share the /cloudsql volume. 18 | RUN mkdir /buildstep \ 19 | && mkdir /cloudsql \ 20 | && curl -s https://dl.google.com/cloudsql/cloud_sql_proxy.linux.amd64 \ 21 | > /buildstep/cloud_sql_proxy \ 22 | && chmod a+x /buildstep/cloud_sql_proxy 23 | VOLUME /cloudsql 24 | 25 | # Starts CloudSQL and runs a given docker image. 26 | COPY execute.sh /buildstep/execute.sh 27 | ENTRYPOINT ["/buildstep/execute.sh"] 28 | -------------------------------------------------------------------------------- /app-engine-exec-wrapper/README.md: -------------------------------------------------------------------------------- 1 | # Executor for App Engine Flexible Environment 2 | 3 | This is a wrapper Docker image that sets up an environment similar to the 4 | [Google App Engine Flexible Environment](https://cloud.google.com/appengine/docs/flexible/), 5 | suitable for running scripts and maintenance tasks provided by an application 6 | deployed to App Engine. In particular, it ensures a suitable Cloud SQL Proxy 7 | is running in the environment. 8 | 9 | Its driving use case is running production database migrations for Ruby on 10 | Rails applications, but it is also useful for Django applications, and we 11 | expect similar uses for other languages and frameworks. 12 | 13 | ## Usage 14 | 15 | This image is deployed to `gcr.io/google-appengine/exec-wrapper`, and is 16 | designed to be run as a step in a 17 | [Cloud Build](https://cloud.google.com/cloud-build/) job. 18 | You must send, as arguments, the path of the deployed application image, any 19 | environment variables to set, any Cloud SQL instances to make available, and 20 | the command to run. Here is an example Cloud Build configuration: 21 | 22 | steps: 23 | - name: "gcr.io/google-appengine/exec-wrapper" 24 | args: ["-i", "gcr.io/my-project/appengine/some-long-name", 25 | "-e", "ENV_VARIABLE_1=value1", "-e", "ENV_2=value2", 26 | "-s", "my-project:us-central1:my_cloudsql_instance", 27 | "--", "bundle", "exec", "rake", "db:migrate"] 28 | 29 | You can find the image path using `gcloud app versions describe`. 30 | 31 | Ruby developers may use the [appengine gem](https://rubygems.org/gems/appengine) 32 | for a convenient Rake-based interface. 33 | 34 | ## Usage for Cloud Run 35 | 36 | This wrapper can also be used for applications deployed to Cloud Run by defining 37 | your image name in the arguments. It would typically be added after your image build and image push steps" 38 | 39 | steps: 40 | ... 41 | - name: "gcr.io/google-appengine/exec-wrapper" 42 | args: ["-i", "gcr.io/my-project/my-image", 43 | ...] 44 | 45 | 46 | If the Cloud Run image is built with [Google Cloud Buildpacks](https://github.com/GoogleCloudPlatform/buildpacks), 47 | you must define an entrypoint. By default you can use the `launcher` entrypoint: 48 | 49 | 50 | steps: 51 | ... 52 | - name: "gcr.io/google-appengine/exec-wrapper" 53 | args: [... 54 | "-r", "launcher", 55 | "--", "bundle", "exec", "rake", "db:migrate"] 56 | 57 | Alternatively, you can define your migration command as an entrypoint in `Procfile`, 58 | and use that instead of a direct command: 59 | 60 | # Procfile 61 | web: bundle exec rails server 62 | migrate: bundle exec rake db:migrate 63 | 64 | # cloudbuild.yaml 65 | steps: 66 | ... 67 | - name: "gcr.io/google-appengine/exec-wrapper" 68 | args: [... 69 | "-r", "migrate"] 70 | 71 | ## Building and testing 72 | 73 | See the main readme in this repository for information on the build, test, and 74 | release processes. 75 | -------------------------------------------------------------------------------- /app-engine-exec-wrapper/cloudbuild.yaml: -------------------------------------------------------------------------------- 1 | steps: 2 | - name: 'gcr.io/cloud-builders/docker:latest' 3 | args: ['build', '-t', '$_OUTPUT_IMAGE', '-f', 'Dockerfile', '.'] 4 | 5 | images: 6 | - '$_OUTPUT_IMAGE' 7 | -------------------------------------------------------------------------------- /app-engine-exec-wrapper/execute.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Copyright 2017 Google Inc. 4 | # 5 | # Licensed under the Apache License, Version 2.0 (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | 17 | 18 | set -e 19 | 20 | IMAGE= 21 | ENV_PARAMS=() 22 | SQL_INSTANCES=() 23 | SQL_TIMEOUT=10 24 | STRICT_ERRORS=true 25 | PRE_PULL=true 26 | CONTAINER_NETWORK=cloudbuild 27 | 28 | OPTIND=1 29 | while getopts ":e:i:n:s:t:xPr:" opt; do 30 | case $opt in 31 | e) 32 | ENV_PARAMS+=(-e "$OPTARG") 33 | ;; 34 | i) 35 | IMAGE=$OPTARG 36 | ;; 37 | n) 38 | CONTAINER_NETWORK=$OPTARG 39 | ;; 40 | s) 41 | SQL_INSTANCES+=("$OPTARG") 42 | ;; 43 | t) 44 | SQL_TIMEOUT=$OPTARG 45 | ;; 46 | x) 47 | STRICT_ERRORS= 48 | ;; 49 | P) 50 | PRE_PULL= 51 | ;; 52 | r) 53 | ENTRYPOINT=$OPTARG 54 | ;; 55 | \?) 56 | echo "Invalid option: -$OPTARG" >&2 57 | exit 1 58 | ;; 59 | :) 60 | echo "Option $OPTARG requires a parameter" >&2 61 | exit 1 62 | ;; 63 | esac 64 | done 65 | shift $((OPTIND-1)) 66 | 67 | if [ -z "${IMAGE}" ]; then 68 | >&2 echo "ERROR: Docker image expected" 69 | exit 1 70 | fi 71 | 72 | CONTAINER=$(cat /proc/self/mountinfo | sed -n 's|^.*/docker/containers/\([a-f0-9]*\)/.*$|\1|p' | awk 'NR==1') 73 | if [ -z "$CONTAINER" ]; then 74 | CONTAINER=$(cat /proc/1/cgroup | sed -n 's|^.*/docker/\([a-f0-9]*\)|\1|p' | awk 'NR==1') 75 | fi 76 | if [ -z "$CONTAINER" ]; then 77 | CONTAINER=$(basename $(cat /proc/1/cpuset)) 78 | fi 79 | if [ -z "$CONTAINER" ]; then 80 | >&2 echo "ERROR: Unable to determine current container" 81 | exit 1 82 | fi 83 | 84 | if [ -n "$PRE_PULL" ]; then 85 | echo 86 | echo "---------- INSTALL IMAGE ----------" 87 | docker pull ${IMAGE} 88 | fi 89 | 90 | SQL_INSTANCES=$(IFS=,; echo "${SQL_INSTANCES[*]}") 91 | if [ -n "${SQL_INSTANCES}" ]; then 92 | echo 93 | echo "---------- CONNECT CLOUDSQL ----------" 94 | touch cloud_sql_proxy.log 95 | /buildstep/cloud_sql_proxy -dir=/cloudsql -instances=${SQL_INSTANCES} > cloud_sql_proxy.log 2>&1 & 96 | if (timeout ${SQL_TIMEOUT}s tail -f --lines=+1 cloud_sql_proxy.log &) | grep -qe 'Ready for new connections'; then 97 | echo "cloud_sql_proxy is running." 98 | echo "Connections: ${SQL_INSTANCES}." 99 | else 100 | >&2 echo "ERROR: Failed to start cloud_sql_proxy" 101 | >&2 cat cloud_sql_proxy.log 102 | [ -n "$STRICT_ERRORS" ] && exit 1 103 | fi 104 | fi 105 | 106 | if [ -n "${ENTRYPOINT}" ]; then 107 | ENTRYPOINT="--entrypoint \"${ENTRYPOINT}\"" 108 | fi 109 | 110 | echo 111 | echo "---------- EXECUTE COMMAND ----------" 112 | echo "$@" 113 | 114 | docker run --rm ${ENTRYPOINT} --volumes-from=${CONTAINER} --network=${CONTAINER_NETWORK} "${ENV_PARAMS[@]}" ${IMAGE} "$@" 115 | 116 | echo 117 | echo "---------- CLEANUP ----------" 118 | -------------------------------------------------------------------------------- /build-app-engine-exec-wrapper.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Copyright 2017 Google Inc. 4 | # 5 | # Licensed under the Apache License, Version 2.0 (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | 17 | 18 | set -e 19 | 20 | DIRNAME=$(dirname $0) 21 | 22 | PROJECT= 23 | IMAGE_NAME="exec-wrapper" 24 | IMAGE_TAG= 25 | STAGING_FLAG= 26 | AUTO_YES= 27 | 28 | show_usage() { 29 | echo "Usage: ./build-app-engine-exec-wrapper.sh [flags...]" >&2 30 | echo "Flags:" >&2 31 | echo ' -n : set the image name (defaults to `exec-wrapper`)' >&2 32 | echo ' -p : set the project (defaults to current gcloud config)' >&2 33 | echo ' -s: tag new image as staging' >&2 34 | echo ' -t : set the new image tag (defaults to a new tag)' >&2 35 | echo ' -y: automatically confirm' >&2 36 | } 37 | 38 | OPTIND=1 39 | while getopts ":n:p:st:yh" opt; do 40 | case ${opt} in 41 | n) 42 | IMAGE_NAME=${OPTARG} 43 | ;; 44 | p) 45 | PROJECT=${OPTARG} 46 | ;; 47 | s) 48 | STAGING_FLAG="true" 49 | ;; 50 | t) 51 | IMAGE_TAG=${OPTARG} 52 | ;; 53 | y) 54 | AUTO_YES="true" 55 | ;; 56 | h) 57 | show_usage 58 | exit 0 59 | ;; 60 | \?) 61 | echo "Invalid option: -${OPTARG}" >&2 62 | echo >&2 63 | show_usage 64 | exit 1 65 | ;; 66 | :) 67 | echo "Option ${OPTARG} requires a parameter" >&2 68 | echo >&2 69 | show_usage 70 | exit 1 71 | ;; 72 | esac 73 | done 74 | shift $((OPTIND-1)) 75 | 76 | if [ -z "${PROJECT}" ]; then 77 | PROJECT=$(gcloud config get-value project) 78 | echo "Using project from gcloud config: ${PROJECT}" >&2 79 | fi 80 | if [ -z "${IMAGE_TAG}" ]; then 81 | IMAGE_TAG=$(date +%Y-%m-%d-%H%M%S) 82 | echo "Creating new IMAGE_TAG: ${IMAGE_TAG}" >&2 83 | fi 84 | 85 | EXISTING=$(gcloud container images list-tags gcr.io/${PROJECT}/${IMAGE_NAME} --filter=tags=${IMAGE_TAG} --format='get(tags)') 86 | if [ -n "${EXISTING}" ]; then 87 | echo "Tag ${IMAGE_TAG} for gcr.io/${PROJECT}/${IMAGE_NAME} already exists. Aborting." >&2 88 | exit 1 89 | fi 90 | 91 | echo 92 | echo "Building appengine exec wrapper image:" 93 | echo " gcr.io/${PROJECT}/${IMAGE_NAME}:${IMAGE_TAG}" 94 | if [ "${STAGING_FLAG}" = "true" ]; then 95 | echo "and tagging as staging." 96 | else 97 | echo "but NOT tagging as staging." 98 | fi 99 | if [ -z "${AUTO_YES}" ]; then 100 | read -r -p "Ok to build? [Y/n] " response 101 | response=${response,,} # tolower 102 | if [[ "${response}" =~ ^(no|n)$ ]]; then 103 | echo "Aborting." 104 | exit 1 105 | fi 106 | fi 107 | echo 108 | 109 | gcloud builds submit ${DIRNAME}/app-engine-exec-wrapper \ 110 | --config=${DIRNAME}/app-engine-exec-wrapper/cloudbuild.yaml --project ${PROJECT} \ 111 | --substitutions _OUTPUT_IMAGE=gcr.io/${PROJECT}/${IMAGE_NAME}:${IMAGE_TAG} 112 | echo "**** Built image: gcr.io/${PROJECT}/${IMAGE_NAME}:${IMAGE_TAG}" 113 | 114 | if [ "$STAGING_FLAG" = "true" ]; then 115 | gcloud container images add-tag --project ${PROJECT} \ 116 | gcr.io/${PROJECT}/${IMAGE_NAME}:${IMAGE_TAG} \ 117 | gcr.io/${PROJECT}/${IMAGE_NAME}:staging -q 118 | echo "**** Tagged image as gcr.io/${PROJECT}/${IMAGE_NAME}:staging" 119 | fi 120 | -------------------------------------------------------------------------------- /build-ruby-binary-images.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Copyright 2017 Google Inc. 4 | # 5 | # Licensed under the Apache License, Version 2.0 (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | 17 | 18 | set -e 19 | 20 | DIRNAME=$(dirname $0) 21 | 22 | OS_NAME=ubuntu20 23 | RUNTIME_NAME=ruby 24 | PROJECT= 25 | IMAGE_TAG= 26 | BASE_IMAGE_TAG=staging 27 | STAGING_FLAG= 28 | AUTO_YES= 29 | PREBUILT_VERSIONS=() 30 | 31 | if [ -f ${DIRNAME}/prebuilt-versions.txt ]; then 32 | mapfile -t PREBUILT_VERSIONS < ${DIRNAME}/prebuilt-versions.txt 33 | fi 34 | 35 | show_usage() { 36 | echo 'Usage: build-ruby-binary-images.sh [flags...]' >&2 37 | echo 'Flags:' >&2 38 | echo ' -a : use this base image tag (defaults to `staging`)' >&2 39 | echo ' -c : comma separated prebuilt ruby versions (defaults to prebuilt-versions.txt)' >&2 40 | echo ' -n : set the runtime name (defaults to `ruby`)' >&2 41 | echo ' -o : build against the given os base image (defaults to ubuntu20)' >&2 42 | echo ' -p : set the project (defaults to current gcloud config setting)' >&2 43 | echo ' -s: also tag new images as `staging`' >&2 44 | echo ' -t : set the new image tag (creates a new tag if not provided)' >&2 45 | echo ' -y: automatically confirm' >&2 46 | } 47 | 48 | OPTIND=1 49 | while getopts ":a:c:n:o:p:st:yh" opt; do 50 | case ${opt} in 51 | a) 52 | BASE_IMAGE_TAG=${OPTARG} 53 | ;; 54 | c) 55 | if [ "${OPTARG}" = "none" ]; then 56 | PREBUILT_VERSIONS=() 57 | else 58 | IFS=',' read -r -a PREBUILT_VERSIONS <<< "${OPTARG}" 59 | fi 60 | ;; 61 | n) 62 | RUNTIME_NAME=${OPTARG} 63 | ;; 64 | o) 65 | OS_NAME=${OPTARG} 66 | ;; 67 | p) 68 | PROJECT=${OPTARG} 69 | ;; 70 | s) 71 | STAGING_FLAG="true" 72 | ;; 73 | t) 74 | IMAGE_TAG=${OPTARG} 75 | ;; 76 | y) 77 | AUTO_YES="true" 78 | ;; 79 | h) 80 | show_usage 81 | exit 0 82 | ;; 83 | \?) 84 | echo "Invalid option: -${OPTARG}" >&2 85 | echo >&2 86 | show_usage 87 | exit 1 88 | ;; 89 | :) 90 | echo "Option ${OPTARG} requires a parameter" >&2 91 | echo >&2 92 | show_usage 93 | exit 1 94 | ;; 95 | esac 96 | done 97 | shift $((OPTIND-1)) 98 | 99 | if [ "${#PREBUILT_VERSIONS[@]}" = "0" ]; then 100 | echo "No versions to build. Aborting." 101 | exit 1 102 | fi 103 | 104 | if [ -z "${PROJECT}" ]; then 105 | PROJECT=$(gcloud config get-value project) 106 | echo "Using project from gcloud config: ${PROJECT}" >&2 107 | fi 108 | if [ -z "${IMAGE_TAG}" ]; then 109 | IMAGE_TAG=$(date +%Y-%m-%d-%H%M%S) 110 | echo "Creating new IMAGE_TAG: ${IMAGE_TAG}" >&2 111 | fi 112 | 113 | OS_BASE_IMAGE=gcr.io/${PROJECT}/${RUNTIME_NAME}/${OS_NAME} 114 | OS_SSL10_BASE_IMAGE=gcr.io/${PROJECT}/${RUNTIME_NAME}/${OS_NAME}/ssl10 115 | PREBUILT_IMAGE_PREFIX=gcr.io/${PROJECT}/${RUNTIME_NAME}/${OS_NAME}/prebuilt/ruby- 116 | 117 | echo 118 | echo "Using ${OS_BASE_IMAGE}:${BASE_IMAGE_TAG}" 119 | echo "Building images:" 120 | for version in "${PREBUILT_VERSIONS[@]}"; do 121 | echo " ${PREBUILT_IMAGE_PREFIX}${version}:${IMAGE_TAG}" 122 | done 123 | if [ "${STAGING_FLAG}" = "true" ]; then 124 | echo "and tagging them as staging." 125 | else 126 | echo "but NOT tagging them as staging." 127 | fi 128 | if [ -z "${AUTO_YES}" ]; then 129 | read -r -p "Ok to build? [Y/n] " response 130 | response=${response,,} # tolower 131 | if [[ "${response}" =~ ^(no|n)$ ]]; then 132 | echo "Aborting." 133 | exit 1 134 | fi 135 | fi 136 | echo 137 | 138 | sed -e "s|@@RUBY_OS_IMAGE@@|ruby-${OS_NAME}|g" \ 139 | < ${DIRNAME}/ruby-prebuilt/Dockerfile.in > ${DIRNAME}/ruby-prebuilt/Dockerfile 140 | for version in "${PREBUILT_VERSIONS[@]}"; do 141 | if [[ "${version}" < "2.4.0" ]]; then 142 | chosen_os_base_image=${OS_SSL10_BASE_IMAGE} 143 | else 144 | chosen_os_base_image=${OS_BASE_IMAGE} 145 | fi 146 | gcloud builds submit ${DIRNAME}/ruby-prebuilt \ 147 | --config ${DIRNAME}/ruby-prebuilt/cloudbuild.yaml --project ${PROJECT} --timeout 20m \ 148 | --substitutions _OS_NAME=${OS_NAME},_OS_BASE_IMAGE=${chosen_os_base_image},_IMAGE=${PREBUILT_IMAGE_PREFIX}${version},_TAG=${IMAGE_TAG},_BASE_TAG=${BASE_IMAGE_TAG},_RUBY_VERSION=${version} 149 | echo "**** Built image: ${PREBUILT_IMAGE_PREFIX}${version}:${IMAGE_TAG}" 150 | if [ "${STAGING_FLAG}" = "true" ]; then 151 | gcloud container images add-tag --project ${PROJECT} \ 152 | ${PREBUILT_IMAGE_PREFIX}${version}:${IMAGE_TAG} \ 153 | ${PREBUILT_IMAGE_PREFIX}${version}:staging -q 154 | echo "**** And tagged as ${PREBUILT_IMAGE_PREFIX}${version}:staging" 155 | fi 156 | done 157 | -------------------------------------------------------------------------------- /integration_test/builder_app/Gemfile: -------------------------------------------------------------------------------- 1 | source 'https://rubygems.org' 2 | 3 | gem 'sinatra', '~> 2.0' 4 | gem "sinatra-contrib", "~> 2.0" 5 | 6 | gem "stackdriver", "~> 0.16" 7 | gem "google-cloud-monitoring", "~> 0.38" 8 | -------------------------------------------------------------------------------- /integration_test/builder_app/Gemfile.lock: -------------------------------------------------------------------------------- 1 | GEM 2 | remote: https://rubygems.org/ 3 | specs: 4 | addressable (2.7.0) 5 | public_suffix (>= 2.0.2, < 5.0) 6 | backports (3.17.1) 7 | binding_of_caller (0.8.0) 8 | debug_inspector (>= 0.0.1) 9 | concurrent-ruby (1.1.6) 10 | debug_inspector (0.0.3) 11 | faraday (1.0.1) 12 | multipart-post (>= 1.2, < 3) 13 | google-cloud-core (1.5.0) 14 | google-cloud-env (~> 1.0) 15 | google-cloud-errors (~> 1.0) 16 | google-cloud-debugger (0.36.1) 17 | binding_of_caller (~> 0.7) 18 | concurrent-ruby (~> 1.1) 19 | google-cloud-core (~> 1.2) 20 | google-cloud-logging (~> 1.0) 21 | google-gax (~> 1.8) 22 | googleapis-common-protos (>= 1.3.9, < 2.0) 23 | googleapis-common-protos-types (>= 1.0.4, < 2.0) 24 | stackdriver-core (~> 1.3) 25 | google-cloud-env (1.3.1) 26 | faraday (>= 0.17.3, < 2.0) 27 | google-cloud-error_reporting (0.35.1) 28 | concurrent-ruby (~> 1.1) 29 | google-cloud-core (~> 1.2) 30 | google-gax (~> 1.8) 31 | googleapis-common-protos (>= 1.3.9, < 2.0) 32 | googleapis-common-protos-types (>= 1.0.4, < 2.0) 33 | stackdriver-core (~> 1.3) 34 | google-cloud-errors (1.0.0) 35 | google-cloud-logging (1.10.6) 36 | concurrent-ruby (~> 1.1) 37 | google-cloud-core (~> 1.2) 38 | google-gax (~> 1.8) 39 | googleapis-common-protos (>= 1.3.9, < 2.0) 40 | googleapis-common-protos-types (>= 1.0.4, < 2.0) 41 | stackdriver-core (~> 1.3) 42 | google-cloud-monitoring (0.38.0) 43 | google-gax (~> 1.8) 44 | googleapis-common-protos (>= 1.3.9, < 2.0) 45 | googleapis-common-protos-types (>= 1.0.4, < 2.0) 46 | google-cloud-trace (0.38.2) 47 | concurrent-ruby (~> 1.1) 48 | google-cloud-core (~> 1.2) 49 | google-gax (~> 1.8) 50 | googleapis-common-protos (>= 1.3.9, < 2.0) 51 | googleapis-common-protos-types (>= 1.0.4, < 2.0) 52 | stackdriver-core (~> 1.3) 53 | google-gax (1.8.1) 54 | google-protobuf (~> 3.9) 55 | googleapis-common-protos (>= 1.3.9, < 2.0) 56 | googleauth (~> 0.9) 57 | grpc (~> 1.24) 58 | rly (~> 0.2.3) 59 | google-protobuf (3.12.0) 60 | googleapis-common-protos (1.3.10) 61 | google-protobuf (~> 3.11) 62 | googleapis-common-protos-types (>= 1.0.5, < 2.0) 63 | grpc (~> 1.27) 64 | googleapis-common-protos-types (1.0.5) 65 | google-protobuf (~> 3.11) 66 | googleauth (0.12.0) 67 | faraday (>= 0.17.3, < 2.0) 68 | jwt (>= 1.4, < 3.0) 69 | memoist (~> 0.16) 70 | multi_json (~> 1.11) 71 | os (>= 0.9, < 2.0) 72 | signet (~> 0.14) 73 | grpc (1.28.0) 74 | google-protobuf (~> 3.11) 75 | googleapis-common-protos-types (~> 1.0) 76 | jwt (2.2.1) 77 | memoist (0.16.2) 78 | multi_json (1.14.1) 79 | multipart-post (2.1.1) 80 | mustermann (1.1.1) 81 | ruby2_keywords (~> 0.0.1) 82 | os (1.1.0) 83 | public_suffix (4.0.5) 84 | rack (2.2.2) 85 | rack-protection (2.0.8.1) 86 | rack 87 | rly (0.2.3) 88 | ruby2_keywords (0.0.2) 89 | signet (0.14.0) 90 | addressable (~> 2.3) 91 | faraday (>= 0.17.3, < 2.0) 92 | jwt (>= 1.5, < 3.0) 93 | multi_json (~> 1.10) 94 | sinatra (2.0.8.1) 95 | mustermann (~> 1.0) 96 | rack (~> 2.0) 97 | rack-protection (= 2.0.8.1) 98 | tilt (~> 2.0) 99 | sinatra-contrib (2.0.8.1) 100 | backports (>= 2.8.2) 101 | multi_json 102 | mustermann (~> 1.0) 103 | rack-protection (= 2.0.8.1) 104 | sinatra (= 2.0.8.1) 105 | tilt (~> 2.0) 106 | stackdriver (0.16.1) 107 | google-cloud-debugger (~> 0.32) 108 | google-cloud-error_reporting (~> 0.30) 109 | google-cloud-logging (~> 1.5) 110 | google-cloud-trace (~> 0.33) 111 | stackdriver-core (1.4.0) 112 | google-cloud-core (~> 1.2) 113 | tilt (2.0.10) 114 | 115 | PLATFORMS 116 | ruby 117 | 118 | DEPENDENCIES 119 | google-cloud-monitoring (~> 0.38) 120 | sinatra (~> 2.0) 121 | sinatra-contrib (~> 2.0) 122 | stackdriver (~> 0.16) 123 | 124 | BUNDLED WITH 125 | 1.17.3 126 | -------------------------------------------------------------------------------- /integration_test/builder_app/app.yaml: -------------------------------------------------------------------------------- 1 | runtime: ruby 2 | env: flex 3 | entrypoint: bundle exec ruby myapp.rb 4 | -------------------------------------------------------------------------------- /integration_test/builder_app/myapp.rb: -------------------------------------------------------------------------------- 1 | require 'json' 2 | require 'sinatra' 3 | require "sinatra/multi_route" 4 | require 'stackdriver' 5 | require "google/cloud/monitoring/v3" 6 | require 'open3' 7 | 8 | # Grab project_id from gcloud sdk 9 | project_id = ENV["GOOGLE_CLOUD_PROJECT"] || Google::Cloud.env.project_id.to_s 10 | 11 | unless project_id.empty? 12 | ####################################### 13 | # Setup ErrorReporting Middleware 14 | use Google::Cloud::ErrorReporting::Middleware 15 | 16 | ####################################### 17 | # Setup Logging Middleware 18 | use Google::Cloud::Logging::Middleware 19 | 20 | ####################################### 21 | # Setup Trace Middleware 22 | use Google::Cloud::Trace::Middleware 23 | 24 | ####################################### 25 | # Setup Monitoring 26 | monitoring = Google::Cloud::Monitoring::V3::MetricServiceClient.new 27 | end 28 | 29 | 30 | set :environment, :production 31 | set :bind, "0.0.0.0" 32 | set :port, 8080 33 | set :show_exceptions, true 34 | 35 | get '/' do 36 | "Hello World!" 37 | end 38 | 39 | get '/system' do 40 | ENV.inspect 41 | end 42 | 43 | get '/_ah/health' do 44 | "Success" 45 | end 46 | 47 | get '/custom' do 48 | "{}" 49 | end 50 | 51 | route :get, :post, '/exception' do 52 | fail "project_id missing." if project_id.empty? 53 | 54 | begin 55 | fail "Test error from sinatra app" 56 | rescue => e 57 | Google::Cloud::ErrorReporting.report e 58 | end 59 | "Error submitted." 60 | end 61 | 62 | route :get, :post, '/logging_standard' do 63 | fail "project_id missing." if project_id.empty? 64 | 65 | request.body.rewind 66 | request_payload = JSON.parse request.body.read 67 | 68 | token = request_payload["token"] 69 | level = request_payload["level"].to_sym 70 | 71 | logger.add level, token 72 | 73 | 'appengine.googleapis.com%2Fruby_app_log' 74 | end 75 | 76 | route :get, :post, "/logging_custom" do 77 | fail "project_id missing." if project_id.empty? 78 | 79 | request.body.rewind 80 | request_payload = JSON.parse request.body.read 81 | 82 | token = request_payload["token"] 83 | level = request_payload["level"].to_sym 84 | log_name = request_payload["log_name"] 85 | 86 | logging = Google::Cloud::Logging.new 87 | resource = Google::Cloud::Logging::Middleware.build_monitored_resource 88 | 89 | entry = logging.entry.tap do |e| 90 | e.payload = token 91 | e.log_name = log_name 92 | e.severity = level 93 | e.resource = resource 94 | end 95 | 96 | logging.write_entries entry 97 | end 98 | 99 | route :get, :post, '/monitoring' do 100 | fail "project_id missing." if project_id.empty? 101 | 102 | request.body.rewind 103 | request_payload = JSON.parse request.body.read 104 | 105 | token = request_payload["token"] 106 | name = request_payload["name"] 107 | 108 | time_series_hash = { 109 | metric: { 110 | type: name 111 | }, 112 | resource: { 113 | type: "global" 114 | }, 115 | points: [{ 116 | interval: { 117 | endTime: { 118 | seconds: Time.now.to_i, 119 | nanos: Time.now.nsec 120 | } 121 | }, 122 | value: { 123 | int64_value: token.to_i 124 | } 125 | }] 126 | } 127 | time_series = Google::Monitoring::V3::TimeSeries.decode_json time_series_hash.to_json 128 | 129 | monitoring.create_time_series "projects/#{project_id}", [time_series] 130 | 131 | "Time series submitted." 132 | end 133 | 134 | 135 | 136 | -------------------------------------------------------------------------------- /integration_test/builder_app/runtimes.yaml: -------------------------------------------------------------------------------- 1 | schema_version: 1 2 | 3 | runtimes: 4 | ruby: 5 | target: 6 | file: test.yaml -------------------------------------------------------------------------------- /integration_test/builder_app/test.yaml.in: -------------------------------------------------------------------------------- 1 | steps: 2 | - name: '${STAGING_BUILDER_IMAGE}' 3 | args: ['--base-image', 'gcr.io/gcp-runtimes/ruby/ubuntu20:staging', 4 | '--build-tools-image', 'gcr.io/gcp-runtimes/ruby/ubuntu20/build-tools:staging', 5 | '--prebuilt-image', '3.1.2=gcr.io/gcp-runtimes/ruby/ubuntu20/prebuilt/ruby-3.1.2:latest', 6 | '--default-ruby-version', '3.1.2'] 7 | - name: 'gcr.io/cloud-builders/docker:latest' 8 | args: ['build', '--network=cloudbuild', '-t', '${_OUTPUT_IMAGE}', '.'] 9 | images: 10 | - '${_OUTPUT_IMAGE}' 11 | -------------------------------------------------------------------------------- /integration_test/deploy_check/Gemfile: -------------------------------------------------------------------------------- 1 | source "https://rubygems.org" 2 | gem 'sinatra', '~> 2.0' 3 | -------------------------------------------------------------------------------- /integration_test/deploy_check/Gemfile.lock: -------------------------------------------------------------------------------- 1 | GEM 2 | remote: https://rubygems.org/ 3 | specs: 4 | mustermann (1.1.1) 5 | ruby2_keywords (~> 0.0.1) 6 | rack (2.2.2) 7 | rack-protection (2.0.8.1) 8 | rack 9 | ruby2_keywords (0.0.2) 10 | sinatra (2.0.8.1) 11 | mustermann (~> 1.0) 12 | rack (~> 2.0) 13 | rack-protection (= 2.0.8.1) 14 | tilt (~> 2.0) 15 | tilt (2.0.10) 16 | 17 | PLATFORMS 18 | ruby 19 | 20 | DEPENDENCIES 21 | sinatra (~> 2.0) 22 | 23 | BUNDLED WITH 24 | 1.17.3 25 | -------------------------------------------------------------------------------- /integration_test/deploy_check/app.rb: -------------------------------------------------------------------------------- 1 | require "sinatra" 2 | 3 | get "/" do 4 | "Hello world!" 5 | end 6 | -------------------------------------------------------------------------------- /integration_test/deploy_check/app.yaml: -------------------------------------------------------------------------------- 1 | runtime: ruby 2 | env: flex 3 | entrypoint: bundle exec ruby app.rb -p $PORT 4 | -------------------------------------------------------------------------------- /integration_test/deploy_check/app.yaml.in: -------------------------------------------------------------------------------- 1 | runtime: ${RUNTIME_SPEC} 2 | env: flex 3 | entrypoint: bundle exec ruby app.rb -p $PORT 4 | -------------------------------------------------------------------------------- /integration_test/simple_app/Dockerfile.in: -------------------------------------------------------------------------------- 1 | FROM ${STAGING_IMAGE} 2 | 3 | COPY . /app/ 4 | 5 | RUN cd /app && bundle install 6 | 7 | ENTRYPOINT bundle exec ruby /app/myapp.rb 8 | -------------------------------------------------------------------------------- /integration_test/simple_app/Gemfile: -------------------------------------------------------------------------------- 1 | source 'https://rubygems.org' 2 | 3 | gem 'sinatra', '~> 2.0' 4 | gem "sinatra-contrib", "~> 2.0" 5 | 6 | gem "stackdriver", "~> 0.16" 7 | gem "google-cloud-monitoring", "~> 0.38" 8 | -------------------------------------------------------------------------------- /integration_test/simple_app/Gemfile.lock: -------------------------------------------------------------------------------- 1 | GEM 2 | remote: https://rubygems.org/ 3 | specs: 4 | addressable (2.7.0) 5 | public_suffix (>= 2.0.2, < 5.0) 6 | backports (3.17.1) 7 | binding_of_caller (0.8.0) 8 | debug_inspector (>= 0.0.1) 9 | concurrent-ruby (1.1.6) 10 | debug_inspector (0.0.3) 11 | faraday (1.0.1) 12 | multipart-post (>= 1.2, < 3) 13 | google-cloud-core (1.5.0) 14 | google-cloud-env (~> 1.0) 15 | google-cloud-errors (~> 1.0) 16 | google-cloud-debugger (0.36.1) 17 | binding_of_caller (~> 0.7) 18 | concurrent-ruby (~> 1.1) 19 | google-cloud-core (~> 1.2) 20 | google-cloud-logging (~> 1.0) 21 | google-gax (~> 1.8) 22 | googleapis-common-protos (>= 1.3.9, < 2.0) 23 | googleapis-common-protos-types (>= 1.0.4, < 2.0) 24 | stackdriver-core (~> 1.3) 25 | google-cloud-env (1.3.1) 26 | faraday (>= 0.17.3, < 2.0) 27 | google-cloud-error_reporting (0.35.1) 28 | concurrent-ruby (~> 1.1) 29 | google-cloud-core (~> 1.2) 30 | google-gax (~> 1.8) 31 | googleapis-common-protos (>= 1.3.9, < 2.0) 32 | googleapis-common-protos-types (>= 1.0.4, < 2.0) 33 | stackdriver-core (~> 1.3) 34 | google-cloud-errors (1.0.0) 35 | google-cloud-logging (1.10.6) 36 | concurrent-ruby (~> 1.1) 37 | google-cloud-core (~> 1.2) 38 | google-gax (~> 1.8) 39 | googleapis-common-protos (>= 1.3.9, < 2.0) 40 | googleapis-common-protos-types (>= 1.0.4, < 2.0) 41 | stackdriver-core (~> 1.3) 42 | google-cloud-monitoring (0.38.0) 43 | google-gax (~> 1.8) 44 | googleapis-common-protos (>= 1.3.9, < 2.0) 45 | googleapis-common-protos-types (>= 1.0.4, < 2.0) 46 | google-cloud-trace (0.38.2) 47 | concurrent-ruby (~> 1.1) 48 | google-cloud-core (~> 1.2) 49 | google-gax (~> 1.8) 50 | googleapis-common-protos (>= 1.3.9, < 2.0) 51 | googleapis-common-protos-types (>= 1.0.4, < 2.0) 52 | stackdriver-core (~> 1.3) 53 | google-gax (1.8.1) 54 | google-protobuf (~> 3.9) 55 | googleapis-common-protos (>= 1.3.9, < 2.0) 56 | googleauth (~> 0.9) 57 | grpc (~> 1.24) 58 | rly (~> 0.2.3) 59 | google-protobuf (3.12.0) 60 | googleapis-common-protos (1.3.10) 61 | google-protobuf (~> 3.11) 62 | googleapis-common-protos-types (>= 1.0.5, < 2.0) 63 | grpc (~> 1.27) 64 | googleapis-common-protos-types (1.0.5) 65 | google-protobuf (~> 3.11) 66 | googleauth (0.12.0) 67 | faraday (>= 0.17.3, < 2.0) 68 | jwt (>= 1.4, < 3.0) 69 | memoist (~> 0.16) 70 | multi_json (~> 1.11) 71 | os (>= 0.9, < 2.0) 72 | signet (~> 0.14) 73 | grpc (1.28.0) 74 | google-protobuf (~> 3.11) 75 | googleapis-common-protos-types (~> 1.0) 76 | jwt (2.2.1) 77 | memoist (0.16.2) 78 | multi_json (1.14.1) 79 | multipart-post (2.1.1) 80 | mustermann (1.1.1) 81 | ruby2_keywords (~> 0.0.1) 82 | os (1.1.0) 83 | public_suffix (4.0.5) 84 | rack (2.2.2) 85 | rack-protection (2.0.8.1) 86 | rack 87 | rly (0.2.3) 88 | ruby2_keywords (0.0.2) 89 | signet (0.14.0) 90 | addressable (~> 2.3) 91 | faraday (>= 0.17.3, < 2.0) 92 | jwt (>= 1.5, < 3.0) 93 | multi_json (~> 1.10) 94 | sinatra (2.0.8.1) 95 | mustermann (~> 1.0) 96 | rack (~> 2.0) 97 | rack-protection (= 2.0.8.1) 98 | tilt (~> 2.0) 99 | sinatra-contrib (2.0.8.1) 100 | backports (>= 2.8.2) 101 | multi_json 102 | mustermann (~> 1.0) 103 | rack-protection (= 2.0.8.1) 104 | sinatra (= 2.0.8.1) 105 | tilt (~> 2.0) 106 | stackdriver (0.16.1) 107 | google-cloud-debugger (~> 0.32) 108 | google-cloud-error_reporting (~> 0.30) 109 | google-cloud-logging (~> 1.5) 110 | google-cloud-trace (~> 0.33) 111 | stackdriver-core (1.4.0) 112 | google-cloud-core (~> 1.2) 113 | tilt (2.0.10) 114 | 115 | PLATFORMS 116 | ruby 117 | 118 | DEPENDENCIES 119 | google-cloud-monitoring (~> 0.38) 120 | sinatra (~> 2.0) 121 | sinatra-contrib (~> 2.0) 122 | stackdriver (~> 0.16) 123 | 124 | BUNDLED WITH 125 | 1.17.3 126 | -------------------------------------------------------------------------------- /integration_test/simple_app/app.yaml: -------------------------------------------------------------------------------- 1 | runtime: custom 2 | env: flex 3 | -------------------------------------------------------------------------------- /integration_test/simple_app/myapp.rb: -------------------------------------------------------------------------------- 1 | require 'json' 2 | require 'sinatra' 3 | require "sinatra/multi_route" 4 | require 'stackdriver' 5 | require "google/cloud/monitoring/v3" 6 | require 'open3' 7 | 8 | # Grab project_id from gcloud sdk 9 | project_id = ENV["GOOGLE_CLOUD_PROJECT"] || Google::Cloud.env.project_id.to_s 10 | 11 | unless project_id.empty? 12 | ####################################### 13 | # Setup ErrorReporting Middleware 14 | use Google::Cloud::ErrorReporting::Middleware 15 | 16 | ####################################### 17 | # Setup Logging Middleware 18 | use Google::Cloud::Logging::Middleware 19 | 20 | ####################################### 21 | # Setup Trace Middleware 22 | use Google::Cloud::Trace::Middleware 23 | 24 | ####################################### 25 | # Setup Monitoring 26 | monitoring = Google::Cloud::Monitoring::V3::MetricServiceClient.new 27 | end 28 | 29 | 30 | set :environment, :production 31 | set :bind, "0.0.0.0" 32 | set :port, 8080 33 | set :show_exceptions, true 34 | 35 | get '/' do 36 | "Hello World!" 37 | end 38 | 39 | get '/system' do 40 | ENV.inspect 41 | end 42 | 43 | get '/_ah/health' do 44 | "Success" 45 | end 46 | 47 | get '/custom' do 48 | "{}" 49 | end 50 | 51 | route :get, :post, '/exception' do 52 | fail "project_id missing." if project_id.empty? 53 | 54 | begin 55 | fail "Test error from sinatra app" 56 | rescue => e 57 | Google::Cloud::ErrorReporting.report e 58 | end 59 | "Error submitted." 60 | end 61 | 62 | route :get, :post, '/logging_standard' do 63 | fail "project_id missing." if project_id.empty? 64 | 65 | request.body.rewind 66 | request_payload = JSON.parse request.body.read 67 | 68 | token = request_payload["token"] 69 | level = request_payload["level"].to_sym 70 | 71 | logger.add level, token 72 | 73 | 'appengine.googleapis.com%2Fruby_app_log' 74 | end 75 | 76 | route :get, :post, "/logging_custom" do 77 | fail "project_id missing." if project_id.empty? 78 | 79 | request.body.rewind 80 | request_payload = JSON.parse request.body.read 81 | 82 | token = request_payload["token"] 83 | level = request_payload["level"].to_sym 84 | log_name = request_payload["log_name"] 85 | 86 | logging = Google::Cloud::Logging.new 87 | resource = Google::Cloud::Logging::Middleware.build_monitored_resource 88 | 89 | entry = logging.entry.tap do |e| 90 | e.payload = token 91 | e.log_name = log_name 92 | e.severity = level 93 | e.resource = resource 94 | end 95 | 96 | logging.write_entries entry 97 | end 98 | 99 | route :get, :post, '/monitoring' do 100 | fail "project_id missing." if project_id.empty? 101 | 102 | request.body.rewind 103 | request_payload = JSON.parse request.body.read 104 | 105 | token = request_payload["token"] 106 | name = request_payload["name"] 107 | 108 | time_series_hash = { 109 | metric: { 110 | type: name 111 | }, 112 | resource: { 113 | type: "global" 114 | }, 115 | points: [{ 116 | interval: { 117 | endTime: { 118 | seconds: Time.now.to_i, 119 | nanos: Time.now.nsec 120 | } 121 | }, 122 | value: { 123 | int64_value: token.to_i 124 | } 125 | }] 126 | } 127 | time_series = Google::Monitoring::V3::TimeSeries.decode_json time_series_hash.to_json 128 | 129 | monitoring.create_time_series "projects/#{project_id}", [time_series] 130 | 131 | "Time series submitted." 132 | end 133 | 134 | 135 | 136 | -------------------------------------------------------------------------------- /obsolete/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM gcr.io/google-appengine/base 2 | 3 | ENV MESSAGE \\n\ 4 | ********************************** NOTICE **********************************\\n\ 5 | \\n\ 6 | The google/ruby images have been obsoleted.\\n\ 7 | \\n\ 8 | If you want to deploy a Ruby application to Google App Engine, you can\\n\ 9 | simply specify "runtime: ruby" in your app.yaml configuration file.\\n\ 10 | If you'd like to extend the Ruby runtime for App Engine, use\\n\ 11 | "gcr.io/google-appengine/ruby" as the base image.\\n\ 12 | See http://cloud.google.com/ruby for more information on running Ruby on\\n\ 13 | Google Cloud Platform.\\n\ 14 | \\n\ 15 | If you are looking for a generic Ruby base image, consider the official\\n\ 16 | Ruby image on DockerHub at https://hub.docker.com/_/ruby/\\n\ 17 | \\n\ 18 | ********************************** NOTICE **********************************\\n\ 19 | \\n 20 | 21 | # Prevent (most) docker runs of this image and print the above message. 22 | ENTRYPOINT printf "$MESSAGE" && printf "ABORTING CONTAINER\\n\\n" && false 23 | 24 | # Prevent inheriting of this image and print the above message. 25 | ONBUILD RUN printf "$MESSAGE" && printf "ABORTING BUILD\\n\\n" && false 26 | -------------------------------------------------------------------------------- /obsolete/README.md: -------------------------------------------------------------------------------- 1 | # Obsolete images 2 | 3 | The following images are now obsolete: 4 | 5 | * [`google/ruby`](https://hub.docker.com/r/google/ruby/) 6 | * [`google/ruby-runtime`](https://hub.docker.com/r/google/ruby-runtime/) 7 | * [`google/ruby-hello`](https://hub.docker.com/r/google/ruby-hello/) 8 | 9 | If you want to deploy a Ruby application to Google App Engine, you can simply specify "runtime: ruby" in your app.yaml configuration file. 10 | 11 | If you'd like to extend the Ruby runtime for App Engine, use "gcr.io/google-appengine/ruby" as the base image. 12 | 13 | See http://cloud.google.com/ruby for more information on using Ruby on Google Cloud Platform. 14 | 15 | If you are looking for a generic Ruby base image, consider the [official Ruby image on DockerHub](https://hub.docker.com/_/ruby/). 16 | -------------------------------------------------------------------------------- /obsolete/rake_image/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM gcr.io/cloud-builders/docker 2 | 3 | RUN apk update && apk upgrade && apk --update add ruby-rake ruby-minitest curl 4 | 5 | ENTRYPOINT 'rake' 6 | -------------------------------------------------------------------------------- /obsolete/rake_image/cloudbuild.yaml: -------------------------------------------------------------------------------- 1 | steps: 2 | - name: gcr.io/cloud-builders/docker 3 | args: ['build', '-t', 'gcr.io/gcp-runtimes/rake', '.'] 4 | images: 5 | - 'gcr.io/gcp-runtimes/rake' 6 | -------------------------------------------------------------------------------- /release-app-engine-exec-wrapper.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Copyright 2017 Google Inc. 4 | # 5 | # Licensed under the Apache License, Version 2.0 (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | 17 | 18 | set -e 19 | 20 | DIRNAME=$(dirname $0) 21 | 22 | PROJECT= 23 | IMAGE_NAME="exec-wrapper" 24 | IMAGE_TAG="staging" 25 | AUTO_YES= 26 | 27 | show_usage() { 28 | echo "Usage: ./release-app-engine-exec-wrapper.sh [flags...]" >&2 29 | echo "Flags:" >&2 30 | echo ' -n : set the image name (defaults to `exec-wrapper`)' >&2 31 | echo ' -p : set the project (defaults to current gcloud config)' >&2 32 | echo ' -t : the image tag to release (defaults to `staging`)' >&2 33 | echo ' -y: automatically confirm' >&2 34 | } 35 | 36 | OPTIND=1 37 | while getopts ":n:p:t:yh" opt; do 38 | case ${opt} in 39 | n) 40 | IMAGE_NAME=${OPTARG} 41 | ;; 42 | p) 43 | PROJECT=${OPTARG} 44 | ;; 45 | t) 46 | IMAGE_TAG=${OPTARG} 47 | ;; 48 | y) 49 | AUTO_YES="true" 50 | ;; 51 | h) 52 | show_usage 53 | exit 0 54 | ;; 55 | \?) 56 | echo "Invalid option: -${OPTARG}" >&2 57 | echo >&2 58 | show_usage 59 | exit 1 60 | ;; 61 | :) 62 | echo "Option ${OPTARG} requires a parameter" >&2 63 | echo >&2 64 | show_usage 65 | exit 1 66 | ;; 67 | esac 68 | done 69 | shift $((OPTIND-1)) 70 | 71 | if [ -z "${PROJECT}" ]; then 72 | PROJECT=$(gcloud config get-value project) 73 | echo "**** Using project from gcloud config: ${PROJECT}" >&2 74 | fi 75 | 76 | WRAPPER_IMAGE=gcr.io/${PROJECT}/${IMAGE_NAME} 77 | 78 | echo 79 | echo "Releasing exec wrapper:" 80 | echo " ${WRAPPER_IMAGE}:${IMAGE_TAG}" 81 | if [ -z "${AUTO_YES}" ]; then 82 | read -r -p "Ok to proceed? [Y/n] " response 83 | response=${response,,} # tolower 84 | if [[ "${response}" =~ ^(no|n)$ ]]; then 85 | echo "Aborting." 86 | exit 1 87 | fi 88 | fi 89 | echo 90 | 91 | gcloud container images add-tag --project ${PROJECT} \ 92 | ${WRAPPER_IMAGE}:${IMAGE_TAG} ${WRAPPER_IMAGE}:latest -q 93 | echo "**** Tagged image ${WRAPPER_IMAGE}:${IMAGE_TAG} as latest" 94 | -------------------------------------------------------------------------------- /release-ruby-binary-images.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Copyright 2017 Google Inc. 4 | # 5 | # Licensed under the Apache License, Version 2.0 (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | 17 | 18 | set -e 19 | 20 | DIRNAME=$(dirname $0) 21 | 22 | OS_NAME=ubuntu20 23 | RUNTIME_NAME=ruby 24 | PROJECT= 25 | IMAGE_TAG=staging 26 | AUTO_YES= 27 | PREBUILT_VERSIONS=() 28 | 29 | if [ -f ${DIRNAME}/prebuilt-versions.txt ]; then 30 | mapfile -t PREBUILT_VERSIONS < ${DIRNAME}/prebuilt-versions.txt 31 | fi 32 | 33 | show_usage() { 34 | echo 'Usage: release-ruby-binary-images.sh [flags...]' >&2 35 | echo 'Flags:' >&2 36 | echo ' -c : comma separated prebuilt ruby versions (defaults to prebuilt-versions.txt)' >&2 37 | echo ' -n : set the runtime name (defaults to `ruby`)' >&2 38 | echo ' -o : build against the given os base image (defaults to ubuntu20)' >&2 39 | echo ' -p : set the project (defaults to current gcloud config setting)' >&2 40 | echo ' -t : the image tag to release (defaults to `staging`)' >&2 41 | echo ' -y: automatically confirm' >&2 42 | } 43 | 44 | OPTIND=1 45 | while getopts ":c:n:o:p:t:yh" opt; do 46 | case ${opt} in 47 | c) 48 | if [ "${OPTARG}" = "none" ]; then 49 | PREBUILT_VERSIONS=() 50 | else 51 | IFS=',' read -r -a PREBUILT_VERSIONS <<< "${OPTARG}" 52 | fi 53 | ;; 54 | n) 55 | RUNTIME_NAME=${OPTARG} 56 | ;; 57 | o) 58 | OS_NAME=${OPTARG} 59 | ;; 60 | p) 61 | PROJECT=${OPTARG} 62 | ;; 63 | t) 64 | IMAGE_TAG=${OPTARG} 65 | ;; 66 | y) 67 | AUTO_YES="true" 68 | ;; 69 | h) 70 | show_usage 71 | exit 0 72 | ;; 73 | \?) 74 | echo "Invalid option: -${OPTARG}" >&2 75 | echo >&2 76 | show_usage 77 | exit 1 78 | ;; 79 | :) 80 | echo "Option ${OPTARG} requires a parameter" >&2 81 | echo >&2 82 | show_usage 83 | exit 1 84 | ;; 85 | esac 86 | done 87 | shift $((OPTIND-1)) 88 | 89 | if [ "${#PREBUILT_VERSIONS[@]}" = "0" ]; then 90 | echo "No versions to build. Aborting." 91 | exit 1 92 | fi 93 | 94 | if [ -z "${PROJECT}" ]; then 95 | PROJECT=$(gcloud config get-value project) 96 | echo "Using project from gcloud config: ${PROJECT}" >&2 97 | fi 98 | 99 | PREBUILT_IMAGE_PREFIX=gcr.io/${PROJECT}/${RUNTIME_NAME}/${OS_NAME}/prebuilt/ruby- 100 | 101 | echo 102 | echo "Releasing (i.e. tagging as latest) binary images:" 103 | for version in "${PREBUILT_VERSIONS[@]}"; do 104 | echo " ${PREBUILT_IMAGE_PREFIX}${version}:${IMAGE_TAG}" 105 | done 106 | if [ -z "${AUTO_YES}" ]; then 107 | read -r -p "Ok to proceed? [Y/n] " response 108 | response=${response,,} # tolower 109 | if [[ "${response}" =~ ^(no|n)$ ]]; then 110 | echo "Aborting." 111 | exit 1 112 | fi 113 | fi 114 | echo 115 | 116 | for version in "${PREBUILT_VERSIONS[@]}"; do 117 | gcloud container images add-tag --project ${PROJECT} \ 118 | ${PREBUILT_IMAGE_PREFIX}${version}:${IMAGE_TAG} \ 119 | ${PREBUILT_IMAGE_PREFIX}${version}:latest -q 120 | echo "**** Tagged image ${PREBUILT_IMAGE_PREFIX}${version}:${IMAGE_TAG} as latest" 121 | done 122 | -------------------------------------------------------------------------------- /release-ruby-runtime-images.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Copyright 2017 Google Inc. 4 | # 5 | # Licensed under the Apache License, Version 2.0 (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | 17 | 18 | set -e 19 | 20 | DIRNAME=$(dirname $0) 21 | 22 | OS_NAME=ubuntu20 23 | RUNTIME_NAME=ruby 24 | PROJECT= 25 | IMAGE_TAG=staging 26 | AUTO_YES= 27 | 28 | show_usage() { 29 | echo 'Usage: release-ruby-runtime-images.sh [flags...]' >&2 30 | echo 'Flags:' >&2 31 | echo ' -n : set the runtime name (defaults to `ruby`)' >&2 32 | echo ' -o : build against the given os base image (defaults to ubuntu20)' >&2 33 | echo ' -p : set the project (defaults to current gcloud config setting)' >&2 34 | echo ' -t : the image tag to release (defaults to `staging`)' >&2 35 | echo ' -y: automatically confirm' >&2 36 | } 37 | 38 | OPTIND=1 39 | while getopts ":n:o:p:t:yh" opt; do 40 | case ${opt} in 41 | n) 42 | RUNTIME_NAME=${OPTARG} 43 | ;; 44 | o) 45 | OS_NAME=${OPTARG} 46 | ;; 47 | p) 48 | PROJECT=${OPTARG} 49 | ;; 50 | t) 51 | IMAGE_TAG=${OPTARG} 52 | ;; 53 | y) 54 | AUTO_YES="true" 55 | ;; 56 | h) 57 | show_usage 58 | exit 0 59 | ;; 60 | \?) 61 | echo "Invalid option: -${OPTARG}" >&2 62 | echo >&2 63 | show_usage 64 | exit 1 65 | ;; 66 | :) 67 | echo "Option ${OPTARG} requires a parameter" >&2 68 | echo >&2 69 | show_usage 70 | exit 1 71 | ;; 72 | esac 73 | done 74 | shift $((OPTIND-1)) 75 | 76 | if [ -z "${PROJECT}" ]; then 77 | PROJECT=$(gcloud config get-value project) 78 | echo "Using project from gcloud config: ${PROJECT}" >&2 79 | fi 80 | 81 | OS_BASE_IMAGE=gcr.io/${PROJECT}/${RUNTIME_NAME}/${OS_NAME} 82 | OS_SSL10_BASE_IMAGE=gcr.io/${PROJECT}/${RUNTIME_NAME}/${OS_NAME}/ssl10 83 | RUBY_BASIC_IMAGE=gcr.io/${PROJECT}/${RUNTIME_NAME}/${OS_NAME}/basic 84 | BUILD_TOOLS_IMAGE=gcr.io/${PROJECT}/${RUNTIME_NAME}/${OS_NAME}/build-tools 85 | GENERATE_DOCKERFILE_IMAGE=gcr.io/${PROJECT}/${RUNTIME_NAME}/${OS_NAME}/generate-dockerfile 86 | 87 | echo 88 | echo "Releasing (i.e. tagging as latest) runtime images:" 89 | echo " ${OS_BASE_IMAGE}:${IMAGE_TAG}" 90 | if [ "${OS_NAME}" != "ubuntu16" ]; then 91 | echo " ${OS_SSL10_BASE_IMAGE}:${IMAGE_TAG}" 92 | fi 93 | echo " ${RUBY_BASIC_IMAGE}:${IMAGE_TAG}" 94 | echo " ${BUILD_TOOLS_IMAGE}:${IMAGE_TAG}" 95 | echo " ${GENERATE_DOCKERFILE_IMAGE}:${IMAGE_TAG}" 96 | if [ -z "${AUTO_YES}" ]; then 97 | read -r -p "Ok to proceed? [Y/n] " response 98 | response=${response,,} # tolower 99 | if [[ "${response}" =~ ^(no|n)$ ]]; then 100 | echo "Aborting." 101 | exit 1 102 | fi 103 | fi 104 | echo 105 | 106 | gcloud container images add-tag --project ${PROJECT} \ 107 | ${OS_BASE_IMAGE}:${IMAGE_TAG} \ 108 | ${OS_BASE_IMAGE}:latest -q 109 | echo "**** Tagged image ${OS_BASE_IMAGE}:${IMAGE_TAG} as latest" 110 | 111 | if [ "${OS_NAME}" != "ubuntu16" ]; then 112 | gcloud container images add-tag --project ${PROJECT} \ 113 | ${OS_SSL10_BASE_IMAGE}:${IMAGE_TAG} \ 114 | ${OS_SSL10_BASE_IMAGE}:latest -q 115 | echo "**** Tagged image ${OS_SSL10_BASE_IMAGE}:${IMAGE_TAG} as latest" 116 | fi 117 | 118 | gcloud container images add-tag --project ${PROJECT} \ 119 | ${RUBY_BASIC_IMAGE}:${IMAGE_TAG} \ 120 | ${RUBY_BASIC_IMAGE}:latest -q 121 | echo "**** Tagged image ${RUBY_BASIC_IMAGE}:${IMAGE_TAG} as latest" 122 | 123 | gcloud container images add-tag --project ${PROJECT} \ 124 | ${BUILD_TOOLS_IMAGE}:${IMAGE_TAG} \ 125 | ${BUILD_TOOLS_IMAGE}:latest -q 126 | echo "**** Tagged image ${BUILD_TOOLS_IMAGE}:${IMAGE_TAG} as latest" 127 | 128 | gcloud container images add-tag --project ${PROJECT} \ 129 | ${GENERATE_DOCKERFILE_IMAGE}:${IMAGE_TAG} \ 130 | ${GENERATE_DOCKERFILE_IMAGE}:latest -q 131 | echo "**** Tagged image ${GENERATE_DOCKERFILE_IMAGE}:${IMAGE_TAG} as latest" 132 | -------------------------------------------------------------------------------- /release-ruby-runtime-pipeline.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Copyright 2017 Google Inc. 4 | # 5 | # Licensed under the Apache License, Version 2.0 (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | 17 | 18 | set -e 19 | 20 | DIRNAME=$(dirname $0) 21 | 22 | UPLOAD_BUCKET= 23 | RUNTIME_NAME=ruby 24 | PROJECT= 25 | RUNTIME_VERSION=staging 26 | AUTO_YES= 27 | 28 | show_usage() { 29 | echo 'Usage: release-ruby-runtime-pipeline.sh [flags...]' >&2 30 | echo 'Flags:' >&2 31 | echo ' -b : promote the runtime definition in this gcs bucket (required)' >&2 32 | echo ' -n : set the runtime name (defaults to `ruby`)' >&2 33 | echo ' -p : set the builder images project (defaults to current gcloud config setting)' >&2 34 | echo ' -r : release this runtime (defaults to staging)' >&2 35 | echo ' -y: automatically confirm' >&2 36 | } 37 | 38 | OPTIND=1 39 | while getopts ":b:n:p:t:yh" opt; do 40 | case ${opt} in 41 | b) 42 | UPLOAD_BUCKET=${OPTARG} 43 | ;; 44 | n) 45 | RUNTIME_NAME=${OPTARG} 46 | ;; 47 | p) 48 | PROJECT=${OPTARG} 49 | ;; 50 | r) 51 | RUNTIME_VERSION=${OPTARG} 52 | ;; 53 | y) 54 | AUTO_YES="true" 55 | ;; 56 | h) 57 | show_usage 58 | exit 0 59 | ;; 60 | \?) 61 | echo "Invalid option: -${OPTARG}" >&2 62 | echo >&2 63 | show_usage 64 | exit 1 65 | ;; 66 | :) 67 | echo "Option ${OPTARG} requires a parameter" >&2 68 | echo >&2 69 | show_usage 70 | exit 1 71 | ;; 72 | esac 73 | done 74 | shift $((OPTIND-1)) 75 | 76 | if [ -z "${UPLOAD_BUCKET}" ]; then 77 | echo "Error: -b flag is required." >&2 78 | echo >&2 79 | show_usage 80 | exit 1 81 | fi 82 | 83 | if [ -z "${PROJECT}" ]; then 84 | PROJECT=$(gcloud config get-value project) 85 | echo "Using builder image project from gcloud config: ${PROJECT}" >&2 86 | fi 87 | 88 | SOURCE_GS_URL=gs://${UPLOAD_BUCKET}/${RUNTIME_NAME}-default-builder-${RUNTIME_VERSION}.yaml 89 | RELEASE_GS_URL=gs://${UPLOAD_BUCKET}/${RUNTIME_NAME}-default-builder.yaml 90 | 91 | echo 92 | echo "Releasing runtime: ${SOURCE_GS_URL}" 93 | if [ -z "${AUTO_YES}" ]; then 94 | read -r -p "Ok to proceed? [Y/n] " response 95 | response=${response,,} # tolower 96 | if [[ "${response}" =~ ^(no|n)$ ]]; then 97 | echo "Aborting." 98 | exit 1 99 | fi 100 | fi 101 | 102 | gsutil cp ${SOURCE_GS_URL} ${RELEASE_GS_URL} 103 | echo "**** Promoted runtime config ${SOURCE_GS_URL} to ${RELEASE_GS_URL}" 104 | -------------------------------------------------------------------------------- /ruby-base/Dockerfile-default.in: -------------------------------------------------------------------------------- 1 | # Copyright 2018 Google LLC 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | 16 | # This is the base Dockerfile for an App Engine Ruby runtime. 17 | # Dockerfiles for App Engine Ruby apps should inherit FROM this image. 18 | 19 | FROM @@RUBY_OS_IMAGE@@ 20 | 21 | ARG ruby_version 22 | ARG bundler1_version 23 | ARG bundler2_version 24 | 25 | ENV DEFAULT_RUBY_VERSION=${ruby_version} 26 | 27 | # Install Ruby, set default Ruby version, and install Bundler 28 | RUN rbenv install -s ${ruby_version} \ 29 | && rbenv global ${ruby_version} \ 30 | && rbenv rehash \ 31 | && (gem install bundler --version ${bundler1_version} ; \ 32 | gem install bundler --version ${bundler2_version} ; \ 33 | rbenv rehash) 34 | -------------------------------------------------------------------------------- /ruby-base/Dockerfile-prebuilt.in: -------------------------------------------------------------------------------- 1 | # Copyright 2018 Google LLC 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | 16 | # This is the base Dockerfile for an App Engine Ruby runtime. 17 | # Dockerfiles for App Engine Ruby apps should inherit FROM this image. 18 | 19 | FROM @@RUBY_OS_IMAGE@@ 20 | 21 | ARG ruby_version 22 | ARG bundler1_version 23 | ARG bundler2_version 24 | 25 | ENV DEFAULT_RUBY_VERSION=${ruby_version} 26 | 27 | # Install Ruby from prebuilt image 28 | COPY --from=@@PREBUILT_RUBY_IMAGE@@ \ 29 | /opt/rbenv/versions/${ruby_version} \ 30 | /opt/rbenv/versions/${ruby_version} 31 | 32 | # Set default Ruby version and install Bundler 33 | RUN rbenv global ${ruby_version} \ 34 | && rbenv rehash \ 35 | && (gem install bundler --version ${bundler1_version} ; \ 36 | gem install bundler --version ${bundler2_version} ; \ 37 | rbenv rehash) 38 | -------------------------------------------------------------------------------- /ruby-base/cloudbuild.yaml: -------------------------------------------------------------------------------- 1 | steps: 2 | - name: 'gcr.io/cloud-builders/docker' 3 | args: ['pull', '$_OS_BASE_IMAGE:$_TAG'] 4 | - name: 'gcr.io/cloud-builders/docker' 5 | args: ['tag', '$_OS_BASE_IMAGE:$_TAG', 'ruby-$_OS_NAME'] 6 | - name: 'gcr.io/cloud-builders/docker' 7 | args: ['build', '-t', '$_IMAGE:$_TAG', 8 | '--build-arg', 'ruby_version=$_RUBY_VERSION', 9 | '--build-arg', 'bundler1_version=$_BUNDLER1_VERSION', 10 | '--build-arg', 'bundler2_version=$_BUNDLER2_VERSION', 11 | '.'] 12 | - name: 'gcr.io/gcp-runtimes/structure_test' 13 | args: ['--image', '$_IMAGE:$_TAG', '-v', 14 | '--config', '/workspace/structure-test.json'] 15 | 16 | images: 17 | - '$_IMAGE:$_TAG' 18 | -------------------------------------------------------------------------------- /ruby-base/structure-test.json: -------------------------------------------------------------------------------- 1 | { 2 | "schemaVersion": "1.0.0", 3 | "commandTests": [ 4 | { 5 | "name": "test_rbenv_installation", 6 | "command": ["rbenv", "global"], 7 | "expectedOutput": ["[0-9]+\\.[0-9]+\\.[0-9]+\n"] 8 | }, 9 | { 10 | "name": "test_bundler_installation", 11 | "command": ["bundle", "version"], 12 | "expectedOutput": ["Bundler version [0-9]+\\.\\d+.*"] 13 | } 14 | ] 15 | } 16 | -------------------------------------------------------------------------------- /ruby-build-tools/Dockerfile: -------------------------------------------------------------------------------- 1 | # Copyright 2017 Google Inc. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | 16 | # Working image, downloads all the tools into the /app directory. 17 | 18 | # Use the Ruby base image as a tool to download things. 19 | FROM ruby-base AS builder 20 | 21 | # Versions 22 | ARG gcloud_version 23 | ARG bundler1_version 24 | ARG bundler2_version 25 | 26 | RUN mkdir -p /app/bin 27 | 28 | # Install build script files. 29 | COPY access_cloud_sql /app/bin/ 30 | 31 | # Install Yarn 32 | RUN mkdir /app/yarn \ 33 | && (curl -s -L https://yarnpkg.com/latest.tar.gz \ 34 | | tar xzf - --directory=/app/yarn --strip-components=1) 35 | 36 | # Install CloudSQL Proxy 37 | RUN (curl -s https://dl.google.com/cloudsql/cloud_sql_proxy.linux.amd64 \ 38 | > /app/bin/cloud_sql_proxy) \ 39 | && chmod a+x /app/bin/cloud_sql_proxy 40 | 41 | # Install Google Cloud SDK 42 | RUN mkdir /app/google-cloud-sdk \ 43 | && (curl -s https://dl.google.com/dl/cloudsdk/channels/rapid/downloads/google-cloud-sdk-${gcloud_version}-linux-x86_64.tar.gz \ 44 | | tar xzf - --directory=/app/google-cloud-sdk --strip-components=1) 45 | 46 | # Pre-download the gems we'll commonly install 47 | RUN mkdir -p /app/gems \ 48 | && cd /app/gems \ 49 | && gem fetch bundler --version ${bundler2_version} \ 50 | && gem fetch bundler --version ${bundler1_version} 51 | 52 | # Generate a minimal image with only the tool files themselves. This image 53 | # can be downloaded quickly and the files copied into a build image. 54 | FROM scratch 55 | COPY --from=builder /app/ /opt/ 56 | -------------------------------------------------------------------------------- /ruby-build-tools/access_cloud_sql: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Copyright 2017 Google Inc. 4 | # 5 | # Licensed under the Apache License, Version 2.0 (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | 17 | set -e 18 | 19 | SQL_TIMEOUT=10 20 | 21 | if [ "$1" == "--lenient" ]; then 22 | ERROR_RESULT=0 23 | else 24 | ERROR_RESULT=1 25 | fi 26 | 27 | if [ -z "${BUILD_CLOUDSQL_INSTANCES}" ]; then 28 | >&2 echo "ERROR: Invoked access_cloud_sql with no CloudSQL instances available" 29 | exit ${ERROR_RESULT} 30 | fi 31 | 32 | rm -f /tmp/cloud_sql_proxy.log 33 | touch /tmp/cloud_sql_proxy.log 34 | cloud_sql_proxy -dir=/cloudsql -instances=${BUILD_CLOUDSQL_INSTANCES} > /tmp/cloud_sql_proxy.log 2>&1 & 35 | if (timeout ${SQL_TIMEOUT}s tail -f --lines=+1 /tmp/cloud_sql_proxy.log &) | grep -qe 'Ready for new connections'; then 36 | echo "Started cloud_sql_proxy." 37 | else 38 | >&2 echo "ERROR: Failed to start cloud_sql_proxy" 39 | >&2 cat /tmp/cloud_sql_proxy.log 40 | exit ${ERROR_RESULT} 41 | fi 42 | -------------------------------------------------------------------------------- /ruby-build-tools/cloudbuild.yaml: -------------------------------------------------------------------------------- 1 | steps: 2 | - name: 'gcr.io/cloud-builders/docker' 3 | args: ['pull', '$_BASE_IMAGE:$_TAG'] 4 | - name: 'gcr.io/cloud-builders/docker' 5 | args: ['tag', '$_BASE_IMAGE:$_TAG', 'ruby-base'] 6 | - name: 'gcr.io/cloud-builders/docker' 7 | args: ['build', '-t', '$_IMAGE:$_TAG', 8 | '--build-arg', 'gcloud_version=$_GCLOUD_VERSION', 9 | '--build-arg', 'bundler1_version=$_BUNDLER1_VERSION', 10 | '--build-arg', 'bundler2_version=$_BUNDLER2_VERSION', 11 | '.'] 12 | 13 | images: 14 | - '$_IMAGE:$_TAG' 15 | -------------------------------------------------------------------------------- /ruby-generate-dockerfile/Dockerfile: -------------------------------------------------------------------------------- 1 | # Copyright 2017 Google Inc. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | # Use the Ruby base image to get Ruby and its dependencies. 16 | FROM ruby-base 17 | 18 | ARG base_image="" 19 | ARG build_tools_image="" 20 | ARG prebuilt_ruby_images="" 21 | ARG default_ruby_version="" 22 | ARG bundler1_version="" 23 | ARG bundler2_version="" 24 | 25 | ENV DEFAULT_RUBY_BASE_IMAGE=${base_image} \ 26 | DEFAULT_RUBY_BUILD_TOOLS_IMAGE=${build_tools_image} \ 27 | DEFAULT_PREBUILT_RUBY_IMAGES=${prebuilt_ruby_images} \ 28 | DEFAULT_RUBY_VERSION=${default_ruby_version} \ 29 | PROVIDED_BUNDLER1_VERSION=${bundler1_version} \ 30 | PROVIDED_BUNDLER2_VERSION=${bundler2_version} 31 | 32 | # Install the Dockerfile generation script and template. 33 | COPY app/ /app/ 34 | 35 | # The entry point runs the generation script. 36 | ENTRYPOINT ["/app/generate_dockerfile.sh"] 37 | -------------------------------------------------------------------------------- /ruby-generate-dockerfile/app/generate_dockerfile.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Copyright 2017 Google Inc. 4 | # 5 | # Licensed under the Apache License, Version 2.0 (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | 17 | set -e 18 | 19 | WORKSPACE_DIR=$(/bin/pwd) 20 | cd /app 21 | ruby generate_dockerfile.rb --workspace-dir=${WORKSPACE_DIR} "$@" 22 | -------------------------------------------------------------------------------- /ruby-generate-dockerfile/cloudbuild.yaml: -------------------------------------------------------------------------------- 1 | steps: 2 | - name: 'gcr.io/cloud-builders/docker' 3 | args: ['pull', '$_BASE_IMAGE:$_TAG'] 4 | - name: 'gcr.io/cloud-builders/docker' 5 | args: ['tag', '$_BASE_IMAGE:$_TAG', 'ruby-base'] 6 | - name: 'gcr.io/cloud-builders/docker' 7 | args: ['build', '-t', '$_IMAGE:$_TAG', 8 | '--build-arg', 'bundler1_version=$_BUNDLER1_VERSION', 9 | '--build-arg', 'bundler2_version=$_BUNDLER2_VERSION', 10 | '.'] 11 | 12 | images: 13 | - '$_IMAGE:$_TAG' 14 | -------------------------------------------------------------------------------- /ruby-pipeline/ruby-template.yaml.in: -------------------------------------------------------------------------------- 1 | steps: 2 | - name: '@@GENERATE_DOCKERFILE_IMAGE@@:@@TAG@@' 3 | args: [@@PREBUILT_IMAGE_ARGS@@ 4 | '--base-image', '@@RUBY_OS_IMAGE@@:@@TAG@@', 5 | '--build-tools-image', '@@BUILD_TOOLS_IMAGE@@:@@TAG@@', 6 | '--default-ruby-version', '@@DEFAULT_RUBY_VERSION@@'] 7 | - name: 'gcr.io/cloud-builders/docker:latest' 8 | args: ['build', '--network=cloudbuild', '-t', '$_OUTPUT_IMAGE', '.'] 9 | images: 10 | - '$_OUTPUT_IMAGE' 11 | -------------------------------------------------------------------------------- /ruby-prebuilt/Dockerfile.in: -------------------------------------------------------------------------------- 1 | # Copyright 2018 Google LLC 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | 16 | # Build a prebuilt Ruby binary installer 17 | 18 | FROM @@RUBY_OS_IMAGE@@ AS builder 19 | ARG ruby_version 20 | RUN cd ${RBENV_ROOT}/plugins/ruby-build \ 21 | && git pull \ 22 | && rbenv install -s ${ruby_version} 23 | 24 | FROM scratch 25 | ARG ruby_version 26 | COPY --from=builder \ 27 | /opt/rbenv/versions/${ruby_version} \ 28 | /opt/rbenv/versions/${ruby_version} 29 | -------------------------------------------------------------------------------- /ruby-prebuilt/cloudbuild.yaml: -------------------------------------------------------------------------------- 1 | steps: 2 | - name: 'gcr.io/cloud-builders/docker' 3 | args: ['pull', '$_OS_BASE_IMAGE:$_BASE_TAG'] 4 | - name: 'gcr.io/cloud-builders/docker' 5 | args: ['tag', '$_OS_BASE_IMAGE:$_BASE_TAG', 'ruby-$_OS_NAME'] 6 | - name: 'gcr.io/cloud-builders/docker' 7 | args: ['build', '-t', '$_IMAGE:$_TAG', 8 | '--build-arg', 'ruby_version=$_RUBY_VERSION', 9 | '.'] 10 | 11 | images: 12 | - '$_IMAGE:$_TAG' 13 | -------------------------------------------------------------------------------- /ruby-ubuntu16/Dockerfile.in: -------------------------------------------------------------------------------- 1 | # Copyright 2018 Google LLC 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | 16 | # This is the base Dockerfile for an App Engine Ruby runtime. 17 | # Dockerfiles for App Engine Ruby apps should inherit FROM this image. 18 | # 19 | # Installs dependencies for the following common gems: 20 | # 21 | # gems dependencies 22 | # ------------------------------------------------------------------ 23 | # curb libcurl3, libcurl3-gnutls, libcurl4-openssl-dev 24 | # pg libpq-dev 25 | # rmagick imagemagick, libmagickwand-dev 26 | # nokogiri libxml2-dev, libxslt-dev 27 | # sqlite3 libsqlite3-dev 28 | # mysql2 libmysqlclient-dev 29 | # paperclip file 30 | # charlock_holmes libicu-dev 31 | # rugged libgit2-dev 32 | 33 | 34 | FROM gcr.io/gcp-runtimes/ubuntu_16_0_4 35 | 36 | ARG bundler_version 37 | ARG nodejs_version 38 | 39 | ENV RBENV_ROOT=/opt/rbenv \ 40 | DEFAULT_BUNDLER_VERSION=${bundler_version} 41 | 42 | ARG DEBIAN_FRONTEND=noninteractive 43 | 44 | RUN apt-get update -y \ 45 | && apt-get install -y -q --no-install-recommends \ 46 | apt-utils \ 47 | autoconf \ 48 | build-essential \ 49 | ca-certificates \ 50 | cmake \ 51 | curl \ 52 | file \ 53 | git \ 54 | imagemagick \ 55 | libcurl3 \ 56 | libcurl3-gnutls \ 57 | libcurl4-openssl-dev \ 58 | libffi-dev \ 59 | libgdbm-dev \ 60 | libgmp-dev \ 61 | libicu-dev \ 62 | libjemalloc-dev \ 63 | libjemalloc1 \ 64 | libmagickwand-dev \ 65 | libmysqlclient-dev \ 66 | libncurses5-dev \ 67 | libpq-dev \ 68 | libqdbm-dev \ 69 | libreadline6-dev \ 70 | libsqlite3-dev \ 71 | libssl-dev \ 72 | libxml2-dev \ 73 | libxslt-dev \ 74 | libyaml-dev \ 75 | libz-dev \ 76 | systemtap \ 77 | tzdata \ 78 | && apt-get install -y -q --no-install-recommends libgit2-dev \ 79 | && apt-get upgrade -yq \ 80 | && apt-get clean \ 81 | && rm -f /var/lib/apt/lists/*_* \ 82 | && mkdir -p /opt/nodejs \ 83 | && rm -f /etc/ImageMagick-6/policy.xml \ 84 | && git clone https://github.com/sstephenson/rbenv.git ${RBENV_ROOT} \ 85 | && git clone https://github.com/sstephenson/ruby-build.git ${RBENV_ROOT}/plugins/ruby-build \ 86 | && (curl -s https://nodejs.org/dist/v${nodejs_version}/node-v${nodejs_version}-linux-x64.tar.gz \ 87 | | tar xzf - --directory=/opt/nodejs --strip-components=1) \ 88 | && ln -s ${RBENV_ROOT} /rbenv \ 89 | && ln -s /opt/nodejs /nodejs 90 | 91 | COPY files /root 92 | 93 | ENV PATH=/opt/nodejs/bin:${RBENV_ROOT}/shims:${RBENV_ROOT}/bin:${PATH} \ 94 | MALLOC_ARENA_MAX=2 \ 95 | RACK_ENV=production \ 96 | RAILS_ENV=production \ 97 | APP_ENV=production \ 98 | RAILS_SERVE_STATIC_FILES=true \ 99 | RAILS_LOG_TO_STDOUT=true \ 100 | NOKOGIRI_USE_SYSTEM_LIBRARIES=1 \ 101 | PORT=8080 102 | 103 | # Initialize entrypoint 104 | WORKDIR /app 105 | EXPOSE 8080 106 | ENTRYPOINT [] 107 | CMD [] 108 | -------------------------------------------------------------------------------- /ruby-ubuntu16/cloudbuild.yaml: -------------------------------------------------------------------------------- 1 | steps: 2 | - name: 'gcr.io/cloud-builders/docker' 3 | args: ['build', '-t', '$_IMAGE:$_TAG', 4 | '--build-arg', 'bundler_version=$_BUNDLER_VERSION', 5 | '--build-arg', 'nodejs_version=$_NODEJS_VERSION', 6 | '.'] 7 | - name: 'gcr.io/gcp-runtimes/structure_test' 8 | args: ['--image', '$_IMAGE:$_TAG', '-v', 9 | '--config', '/workspace/structure-test.json'] 10 | 11 | images: 12 | - '$_IMAGE:$_TAG' 13 | -------------------------------------------------------------------------------- /ruby-ubuntu16/files/.bundle/config: -------------------------------------------------------------------------------- 1 | --- 2 | BUNDLE_BUILD__NOKOGIRI: "--use-system-libraries" 3 | BUNDLE_SILENCE_ROOT_WARNING: "true" 4 | -------------------------------------------------------------------------------- /ruby-ubuntu16/files/.gemrc: -------------------------------------------------------------------------------- 1 | install: --no-document --quiet 2 | update: --no-document --quiet 3 | -------------------------------------------------------------------------------- /ruby-ubuntu16/structure-test.json: -------------------------------------------------------------------------------- 1 | { 2 | "schemaVersion": "1.0.0", 3 | "commandTests": [ 4 | { 5 | "name": "test_rbenv_installation", 6 | "command": ["rbenv", "--version"], 7 | "expectedOutput": ["rbenv [0-9]+\\.[0-9]+\\.[0-9]+"] 8 | }, 9 | { 10 | "name": "test_node_execution", 11 | "command": ["node", "-e", "console.log(\"Ruby on Google Cloud Platform\")"], 12 | "expectedOutput": ["Ruby on Google Cloud Platform\n"] 13 | }, 14 | { 15 | "name": "test_rack_env_var", 16 | "command": ["sh", "-c", "echo $RACK_ENV"], 17 | "expectedOutput": ["production\n"] 18 | }, 19 | { 20 | "name": "test_rails_env_var", 21 | "command": ["sh", "-c", "echo $RAILS_ENV"], 22 | "expectedOutput": ["production\n"] 23 | }, 24 | { 25 | "name": "test_imagemagick_installation", 26 | "command": ["convert", "-version"], 27 | "expectedOutput": ["Version: ImageMagick [0-9]+\\.\\d+.*"] 28 | } 29 | ], 30 | "licenseTests": [ 31 | { 32 | "debian": true, 33 | "files": [ 34 | "/opt/nodejs/LICENSE" 35 | ] 36 | } 37 | ] 38 | } 39 | -------------------------------------------------------------------------------- /ruby-ubuntu20/Dockerfile.in: -------------------------------------------------------------------------------- 1 | # Copyright 2018 Google LLC 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | 16 | # This is the base Dockerfile for an App Engine Ruby runtime. 17 | # Dockerfiles for App Engine Ruby apps should inherit FROM this image. 18 | # 19 | # Installs dependencies for the following common gems: 20 | # 21 | # gems dependencies 22 | # ------------------------------------------------------------------ 23 | # curb libcurl3, libcurl3-gnutls, libcurl4-openssl-dev 24 | # pg libpq-dev 25 | # rmagick imagemagick, libmagickwand-dev 26 | # nokogiri libxml2-dev, libxslt-dev 27 | # sqlite3 libsqlite3-dev 28 | # mysql2 libmysqlclient-dev 29 | # paperclip file 30 | # charlock_holmes libicu-dev 31 | # rugged libgit2-dev 32 | 33 | 34 | FROM gcr.io/gcp-runtimes/ubuntu_20_0_4 35 | 36 | ARG bundler_version 37 | ARG nodejs_version 38 | ARG ssl10_version 39 | 40 | ENV RBENV_ROOT=/opt/rbenv \ 41 | DEFAULT_BUNDLER_VERSION=${bundler_version} 42 | 43 | ARG DEBIAN_FRONTEND=noninteractive 44 | 45 | RUN apt-get update -y \ 46 | && apt-get install -y -q --no-install-recommends \ 47 | apt-utils \ 48 | autoconf \ 49 | build-essential \ 50 | ca-certificates \ 51 | cmake \ 52 | curl \ 53 | file \ 54 | git \ 55 | imagemagick \ 56 | libcurl3-gnutls \ 57 | libcurl4 \ 58 | libcurl4-openssl-dev \ 59 | libffi-dev \ 60 | libgdbm-dev \ 61 | libgmp-dev \ 62 | libicu-dev \ 63 | libjemalloc-dev \ 64 | libjemalloc2 \ 65 | libmagickwand-dev \ 66 | libmysqlclient-dev \ 67 | libncurses5-dev \ 68 | libpq-dev \ 69 | libqdbm-dev \ 70 | libreadline6-dev \ 71 | libsqlite3-dev \ 72 | libssl-dev \ 73 | libxml2-dev \ 74 | libxslt-dev \ 75 | libvips-dev \ 76 | libyaml-dev \ 77 | libz-dev \ 78 | systemtap \ 79 | tzdata \ 80 | wget \ 81 | && apt-get install -y -q --no-install-recommends libgit2-dev \ 82 | && apt-get upgrade -yq \ 83 | && apt-get clean \ 84 | && rm -f /var/lib/apt/lists/*_* \ 85 | && wget http://security.ubuntu.com/ubuntu/pool/main/o/openssl1.0/libssl1.0.0_${ssl10_version}_amd64.deb \ 86 | && dpkg -i libssl1.0.0_${ssl10_version}_amd64.deb \ 87 | && rm libssl1.0.0_${ssl10_version}_amd64.deb \ 88 | @@IF_SSL10_DEV@@ && apt-get remove --purge -yq libssl-dev libcurl4-openssl-dev \ 89 | @@IF_SSL10_DEV@@ && wget http://security.ubuntu.com/ubuntu/pool/main/o/openssl1.0/libssl1.0-dev_${ssl10_version}_amd64.deb \ 90 | @@IF_SSL10_DEV@@ && dpkg -i libssl1.0-dev_${ssl10_version}_amd64.deb \ 91 | @@IF_SSL10_DEV@@ && rm libssl1.0-dev_${ssl10_version}_amd64.deb \ 92 | && mkdir -p /opt/nodejs \ 93 | && rm -f /etc/ImageMagick-6/policy.xml \ 94 | && git clone https://github.com/sstephenson/rbenv.git ${RBENV_ROOT} \ 95 | && git clone https://github.com/sstephenson/ruby-build.git ${RBENV_ROOT}/plugins/ruby-build \ 96 | && (curl -s https://nodejs.org/dist/v${nodejs_version}/node-v${nodejs_version}-linux-x64.tar.gz \ 97 | | tar xzf - --directory=/opt/nodejs --strip-components=1) \ 98 | && ln -s ${RBENV_ROOT} /rbenv \ 99 | && ln -s /opt/nodejs /nodejs 100 | 101 | COPY files /root 102 | 103 | ENV PATH=/opt/nodejs/bin:${RBENV_ROOT}/shims:${RBENV_ROOT}/bin:${PATH} \ 104 | MALLOC_ARENA_MAX=2 \ 105 | RACK_ENV=production \ 106 | RAILS_ENV=production \ 107 | APP_ENV=production \ 108 | RAILS_SERVE_STATIC_FILES=true \ 109 | RAILS_LOG_TO_STDOUT=true \ 110 | NOKOGIRI_USE_SYSTEM_LIBRARIES=1 \ 111 | PORT=8080 112 | 113 | # Initialize entrypoint 114 | WORKDIR /app 115 | EXPOSE 8080 116 | ENTRYPOINT [] 117 | CMD [] 118 | -------------------------------------------------------------------------------- /ruby-ubuntu20/cloudbuild.yaml: -------------------------------------------------------------------------------- 1 | steps: 2 | - name: 'gcr.io/cloud-builders/docker' 3 | args: ['build', '-t', '$_IMAGE:$_TAG', 4 | '--build-arg', 'bundler_version=$_BUNDLER_VERSION', 5 | '--build-arg', 'nodejs_version=$_NODEJS_VERSION', 6 | '--build-arg', 'ssl10_version=$_SSL10_VERSION', 7 | '.'] 8 | - name: 'gcr.io/gcp-runtimes/structure_test' 9 | args: ['--image', '$_IMAGE:$_TAG', '-v', 10 | '--config', '/workspace/structure-test.json'] 11 | 12 | images: 13 | - '$_IMAGE:$_TAG' 14 | -------------------------------------------------------------------------------- /ruby-ubuntu20/files/.bundle/config: -------------------------------------------------------------------------------- 1 | --- 2 | BUNDLE_BUILD__NOKOGIRI: "--use-system-libraries" 3 | BUNDLE_SILENCE_ROOT_WARNING: "true" 4 | -------------------------------------------------------------------------------- /ruby-ubuntu20/files/.gemrc: -------------------------------------------------------------------------------- 1 | install: --no-document --quiet 2 | update: --no-document --quiet 3 | -------------------------------------------------------------------------------- /ruby-ubuntu20/structure-test.json: -------------------------------------------------------------------------------- 1 | { 2 | "schemaVersion": "1.0.0", 3 | "commandTests": [ 4 | { 5 | "name": "test_rbenv_installation", 6 | "command": ["rbenv", "--version"], 7 | "expectedOutput": ["rbenv [0-9]+\\.[0-9]+\\.[0-9]+"] 8 | }, 9 | { 10 | "name": "test_node_execution", 11 | "command": ["node", "-e", "console.log(\"Ruby on Google Cloud Platform\")"], 12 | "expectedOutput": ["Ruby on Google Cloud Platform\n"] 13 | }, 14 | { 15 | "name": "test_rack_env_var", 16 | "command": ["sh", "-c", "echo $RACK_ENV"], 17 | "expectedOutput": ["production\n"] 18 | }, 19 | { 20 | "name": "test_rails_env_var", 21 | "command": ["sh", "-c", "echo $RAILS_ENV"], 22 | "expectedOutput": ["production\n"] 23 | }, 24 | { 25 | "name": "test_imagemagick_installation", 26 | "command": ["convert", "-version"], 27 | "expectedOutput": ["Version: ImageMagick [0-9]+\\.\\d+.*"] 28 | } 29 | ], 30 | "licenseTests": [ 31 | { 32 | "files": [ 33 | "/opt/nodejs/LICENSE" 34 | ] 35 | } 36 | ] 37 | } 38 | -------------------------------------------------------------------------------- /runtime-config.env: -------------------------------------------------------------------------------- 1 | # Copyright 2022 Google LLC 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | # This file contains parameters for the runtime, that may change frequently. 16 | 17 | # This is the Ruby version that is installed in the "basic" convenience image 18 | # and that is used to run generate-dockerfile. It is NOT the same as the Ruby 19 | # version used by the runtime by default if one is not specified by the app. 20 | # (That version is set directly in ./ruby-pipeline/ruby-latest.yaml.) 21 | # Note: BASIC_RUBY_VERSION *must* be included in PRIMARY_RUBY_VERSIONS below. 22 | BASIC_RUBY_VERSION=2.7.6 23 | 24 | # This is a list of "primary" Ruby versions, generally the latest supported 25 | # patchlevels of the 4 currently supported minor versions. 26 | # This is used to choose a small number of versions for local testing. The full 27 | # list of prebuilt versions is much longer, and is reflected in the file 28 | # ./ruby-pipeline/ruby-latest.yaml. 29 | PRIMARY_RUBY_VERSIONS=2.6.10,2.7.6,3.0.4,3.1.2 30 | 31 | # This is the version of Bundler 1.x that is installed in each runtime. It 32 | # should be the newest 1.x.y version (which will probably remain 1.17.3). 33 | BUNDLER1_VERSION=1.17.3 34 | 35 | # This is the version of Bundler 2.x that is installed explicitly in each 36 | # runtime. Most recent versions of Ruby install their own (newer) Bundler, so 37 | # the one listed here is probably not the one that will actually be used. It's 38 | # likely okay for it to remain 2.1.4 indefinitely. 39 | BUNDLER2_VERSION=2.1.4 40 | 41 | # This is the version of NodeJS that gets installed in the base image. We 42 | # should periodically update it to the latest LTS. 43 | NODEJS_VERSION=16.15.0 44 | 45 | # This is the version of gcloud that gets installed in the base image and the 46 | # build tools. We should periodically update it to the latest. 47 | GCLOUD_VERSION=387.0.0 48 | 49 | # This is the version of the libssl1.0 package in Ubuntu 20_04, used to build 50 | # pre-2.4 versions of Ruby. It should match what is available under the 51 | # directory http://security.ubuntu.com/ubuntu/pool/main/o/openssl1.0/ 52 | SSL10_VERSION=1.0.2n-1ubuntu5.13 53 | -------------------------------------------------------------------------------- /test/app_config/bad-ruby-version/.ruby-version: -------------------------------------------------------------------------------- 1 | bad!version -------------------------------------------------------------------------------- /test/app_config/gemfile-old/Gemfile: -------------------------------------------------------------------------------- 1 | source 'https://rubygems.org' 2 | gem 'sinatra', '~> 2.0' 3 | -------------------------------------------------------------------------------- /test/app_config/gemfile-old/Gemfile.lock: -------------------------------------------------------------------------------- 1 | GEM 2 | remote: https://rubygems.org/ 3 | specs: 4 | mustermann (1.0.3) 5 | rack (2.0.6) 6 | rack-protection (2.0.5) 7 | rack 8 | sinatra (2.0.5) 9 | mustermann (~> 1.0) 10 | rack (~> 2.0) 11 | rack-protection (= 2.0.5) 12 | tilt (~> 2.0) 13 | tilt (2.0.9) 14 | 15 | PLATFORMS 16 | ruby 17 | 18 | DEPENDENCIES 19 | sinatra (~> 2.0) 20 | 21 | BUNDLED WITH 22 | 1.17.3 23 | -------------------------------------------------------------------------------- /test/app_config/gemfile-rack/config.ru: -------------------------------------------------------------------------------- 1 | puts "hello" 2 | -------------------------------------------------------------------------------- /test/app_config/gemfile-rack/gems.locked: -------------------------------------------------------------------------------- 1 | GEM 2 | remote: https://rubygems.org/ 3 | specs: 4 | rack (2.0.6) 5 | 6 | PLATFORMS 7 | ruby 8 | 9 | DEPENDENCIES 10 | rack (~> 2.0) 11 | 12 | BUNDLED WITH 13 | 1.17.3 14 | -------------------------------------------------------------------------------- /test/app_config/gemfile-rack/gems.rb: -------------------------------------------------------------------------------- 1 | source 'https://rubygems.org' 2 | gem 'rack', '~> 2.0' 3 | -------------------------------------------------------------------------------- /test/app_config/gemfile-ruby/gems.rb: -------------------------------------------------------------------------------- 1 | source 'https://rubygems.org' 2 | ruby "2.0.98" 3 | -------------------------------------------------------------------------------- /test/app_config/rails/app/assets/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GoogleCloudPlatform/ruby-docker/d2dca08aa04430c3e00c1fe1a99e855ccffdd8a1/test/app_config/rails/app/assets/.gitkeep -------------------------------------------------------------------------------- /test/app_config/rails/config/application.rb: -------------------------------------------------------------------------------- 1 | # Hello 2 | -------------------------------------------------------------------------------- /test/app_config/ruby-version/.ruby-version: -------------------------------------------------------------------------------- 1 | ruby-2.0.99 2 | -------------------------------------------------------------------------------- /test/app_engine_exec_wrapper/harness/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM app-engine-exec-wrapper 2 | RUN apt-get update -y && \ 3 | apt-get install -y -q --no-install-recommends ruby && \ 4 | rm /buildstep/cloud_sql_proxy 5 | COPY fake_cloud_sql_proxy.rb /buildstep/cloud_sql_proxy 6 | -------------------------------------------------------------------------------- /test/app_engine_exec_wrapper/harness/fake_cloud_sql_proxy.rb: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | 3 | # Copyright 2017 Google Inc. 4 | # 5 | # Licensed under the Apache License, Version 2.0 (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | 17 | 18 | class FakeCloudSqlProxy 19 | def initialize args 20 | @dir = nil 21 | @instances = [] 22 | args.each do |arg| 23 | case arg 24 | when /^-dir=(.*)$/ 25 | @dir = $1 26 | when /^-instances=(.*)$/ 27 | @instances += $1.split "," 28 | else 29 | abort "Unknown arg: #{arg}" 30 | end 31 | end 32 | end 33 | 34 | def run 35 | puts "Starting fake_cloud_sql_proxy" 36 | abort "Dir not given" unless @dir 37 | abort "No instances" if @instances.empty? 38 | sleep(1.0 + 4.0 * rand) 39 | if @dir 40 | @instances.each do |instance| 41 | system "touch #{@dir}/#{instance}" 42 | end 43 | end 44 | puts "Ready for new connections" 45 | end 46 | end 47 | 48 | FakeCloudSqlProxy.new(ARGV).run 49 | -------------------------------------------------------------------------------- /test/app_engine_exec_wrapper/no_cloudsql/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM ruby-base 2 | COPY run.rb /app/ 3 | CMD exec ruby run.rb 4 | -------------------------------------------------------------------------------- /test/app_engine_exec_wrapper/no_cloudsql/run.rb: -------------------------------------------------------------------------------- 1 | # Copyright 2017 Google Inc. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | abort "VAR1 incorrect" unless ::ENV["VAR1"] == "value1" 16 | abort "VAR2 incorrect" unless ::ENV["VAR2"] == "value2" 17 | 18 | entries = ::Dir.entries("/cloudsql") - [".", ".."] 19 | abort "cloudsql dir expected to be empty" unless entries.empty? 20 | 21 | puts "All good!" 22 | -------------------------------------------------------------------------------- /test/app_engine_exec_wrapper/simple/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM ruby-base 2 | COPY run.rb /app/ 3 | CMD exec ruby run.rb 4 | -------------------------------------------------------------------------------- /test/app_engine_exec_wrapper/simple/run.rb: -------------------------------------------------------------------------------- 1 | # Copyright 2017 Google Inc. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | abort "VAR1 incorrect" unless ::ENV["VAR1"] == "value1" 16 | abort "VAR2 incorrect" unless ::ENV["VAR2"] == "value2" 17 | 18 | abort "Sql socket not found" unless ::File.exist? "/cloudsql/sql:1:2:3" 19 | 20 | puts "All good!" 21 | -------------------------------------------------------------------------------- /test/builder_cases/rack_app/app.yaml: -------------------------------------------------------------------------------- 1 | runtime: ruby 2 | env: flex 3 | -------------------------------------------------------------------------------- /test/builder_cases/rails4_app/app.yaml: -------------------------------------------------------------------------------- 1 | runtime: ruby 2 | env: flex 3 | entrypoint: bundle exec bin/rails s -p $PORT 4 | env_variables: 5 | SECRET_KEY_BASE: "0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef" 6 | -------------------------------------------------------------------------------- /test/builder_cases/rails5_app/.ruby-version: -------------------------------------------------------------------------------- 1 | 2.5.1 2 | -------------------------------------------------------------------------------- /test/builder_cases/rails5_app/app.yaml: -------------------------------------------------------------------------------- 1 | runtime: ruby 2 | env: flex 3 | entrypoint: bundle exec bin/rails s 4 | env_variables: 5 | SECRET_KEY_BASE: "0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef" 6 | -------------------------------------------------------------------------------- /test/builder_cases/sinatra1_app/.ruby-version: -------------------------------------------------------------------------------- 1 | 2.4.4 2 | -------------------------------------------------------------------------------- /test/builder_cases/sinatra1_app/app.yaml: -------------------------------------------------------------------------------- 1 | runtime: ruby 2 | env: flex 3 | entrypoint: bundle exec ruby myapp.rb -p $PORT 4 | env_variables: 5 | GOOGLE_CLOUD_PROJECT: "" 6 | -------------------------------------------------------------------------------- /test/helper.rb: -------------------------------------------------------------------------------- 1 | # Copyright 2017 Google Inc. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | require "minitest/autorun" 16 | require "minitest/focus" 17 | require "minitest/rg" 18 | 19 | # A set of helpful methods and assertions for running tests. 20 | 21 | module Helper 22 | # The name of the OS currently being used for testing 23 | def self.os_name 24 | ::ENV["TESTING_OS_NAME"] || "ubuntu20" 25 | end 26 | 27 | # Execute the given command in a shell. 28 | def execute_cmd(cmd) 29 | puts cmd 30 | system cmd 31 | end 32 | 33 | # Assert that the given file contents matches the given string or regex. 34 | def assert_file_contents(path, expectations) 35 | contents = ::IO.read(path) 36 | Array(expectations).each do |expectation| 37 | unless expectation === contents 38 | flunk "File #{path} did not contain #{expectation.inspect}" 39 | end 40 | end 41 | contents 42 | end 43 | 44 | # Assert that execution of the given command produces a zero exit code. 45 | def assert_cmd_succeeds cmd 46 | puts cmd 47 | system cmd 48 | exit_code = $?.exitstatus 49 | if exit_code != 0 50 | flunk "Got exit code #{exit_code} when executing \"#{cmd}\"" 51 | end 52 | end 53 | 54 | # Assert that execution of the given command produces a nonzero exit code. 55 | def assert_cmd_fails cmd 56 | puts cmd 57 | system cmd 58 | exit_code = $?.exitstatus 59 | if exit_code == 0 60 | flunk "Got exit code #{exit_code} when executing \"#{cmd}\"" 61 | end 62 | end 63 | 64 | # Repeatedly execute the given command (with a pause between tries). 65 | # Flunks if it does not succeed and produce output matching the given 66 | # expectation (string or regex) within the given timeout in seconds. 67 | def assert_cmd_output(cmd, expectation, timeout=0) 68 | expectations = Array(expectation) 69 | actual = "" 70 | exit_code = 0 71 | 0.upto(timeout) do |iter| 72 | puts cmd 73 | actual = `#{cmd}` 74 | exit_code = $?.exitstatus 75 | return actual if exit_code == 0 && expectations.all? { |e| e === actual } 76 | puts("...expected result did not arrive yet (iteration #{iter})...") 77 | sleep(1) 78 | end 79 | yield if block_given? 80 | flunk "Expected #{expectation.inspect} but got \"#{actual}\"" + 81 | " (exit code #{exit_code}) when executing \"#{cmd}\"" 82 | end 83 | 84 | # Assert that the given docker run command produces the given output. 85 | # Automatically cleans up the generated container. 86 | def assert_docker_output(args, expectation, container_root="generic", &block) 87 | number = "%.08x" % rand(0x100000000) 88 | container = "ruby-test-container-#{container_root}-#{number}" 89 | begin 90 | assert_cmd_output("docker run --name #{container} #{args}", 91 | expectation, &block) 92 | ensure 93 | execute_cmd("docker rm #{container}") 94 | end 95 | end 96 | 97 | # Runs a docker container as a daemon. Yields the container name. 98 | # Automatically kills and removes the container afterward. 99 | def run_docker_daemon(args, container_root="generic") 100 | number = "%.08x" % rand(0x100000000) 101 | container = "ruby-test-container-#{container_root}-#{number}" 102 | begin 103 | assert_cmd_succeeds("docker run --name #{container} -d #{args}") 104 | yield container 105 | ensure 106 | execute_cmd("docker kill #{container}") 107 | execute_cmd("docker rm #{container}") 108 | end 109 | end 110 | 111 | # Build a docker image with the given arguments. Yields the image name. 112 | # Automatically cleans up the generated image afterward. 113 | def build_docker_image(args="", image_root="generic") 114 | number = "%.08x" % rand(0x100000000) 115 | image = "ruby-test-image-#{image_root}-#{number}" 116 | begin 117 | assert_cmd_succeeds("docker build -t #{image} #{args} .") 118 | yield image 119 | ensure 120 | execute_cmd("docker rmi #{image}") 121 | end 122 | end 123 | 124 | end 125 | -------------------------------------------------------------------------------- /test/sample_apps/rack_app/Gemfile: -------------------------------------------------------------------------------- 1 | source 'https://rubygems.org' 2 | gem 'rack', '>= 2.0' 3 | -------------------------------------------------------------------------------- /test/sample_apps/rack_app/Gemfile.lock: -------------------------------------------------------------------------------- 1 | GEM 2 | remote: https://rubygems.org/ 3 | specs: 4 | rack (2.0.6) 5 | 6 | PLATFORMS 7 | ruby 8 | 9 | DEPENDENCIES 10 | rack (>= 2.0) 11 | 12 | BUNDLED WITH 13 | 1.17.3 14 | -------------------------------------------------------------------------------- /test/sample_apps/rack_app/config.ru: -------------------------------------------------------------------------------- 1 | run Proc.new { |env| [200, {'Content-Type' => 'text/plain'}, ["Hello World!"]] } 2 | -------------------------------------------------------------------------------- /test/sample_apps/rails4_app/.gitignore: -------------------------------------------------------------------------------- 1 | # See https://help.github.com/articles/ignoring-files for more about ignoring files. 2 | # 3 | # If you find yourself ignoring temporary files generated by your text editor 4 | # or operating system, you probably want to add a global ignore instead: 5 | # git config --global core.excludesfile '~/.gitignore_global' 6 | 7 | # Ignore bundler config. 8 | /.bundle 9 | 10 | # Ignore all logfiles and tempfiles. 11 | /log/* 12 | !/log/.keep 13 | /tmp 14 | -------------------------------------------------------------------------------- /test/sample_apps/rails4_app/Gemfile: -------------------------------------------------------------------------------- 1 | source 'https://rubygems.org' 2 | 3 | 4 | # Bundle edge Rails instead: gem 'rails', github: 'rails/rails' 5 | gem 'rails', '4.2.11' 6 | # Use SCSS for stylesheets 7 | gem 'sass-rails', '~> 5.0' 8 | # Use Uglifier as compressor for JavaScript assets 9 | gem 'uglifier', '>= 1.3.0' 10 | # Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder 11 | gem 'jbuilder', '~> 2.0' 12 | # bundle exec rake doc:rails generates the API under doc/api. 13 | gem 'sdoc', '~> 0.4.0', group: :doc 14 | 15 | # Use ActiveModel has_secure_password 16 | # gem 'bcrypt', '~> 3.1.7' 17 | 18 | # Use Unicorn as the app server 19 | # gem 'unicorn' 20 | 21 | # Use Capistrano for deployment 22 | # gem 'capistrano-rails', group: :development 23 | 24 | group :development, :test do 25 | # Call 'byebug' anywhere in the code to stop execution and get a debugger console 26 | gem 'byebug' 27 | end 28 | 29 | group :development do 30 | # Access an IRB console on exception pages or by using <%= console %> in views 31 | gem 'web-console', '~> 2.0' 32 | end 33 | 34 | # Use Puma as the app server 35 | gem 'puma', '~> 3.0' 36 | -------------------------------------------------------------------------------- /test/sample_apps/rails4_app/Gemfile.lock: -------------------------------------------------------------------------------- 1 | GEM 2 | remote: https://rubygems.org/ 3 | specs: 4 | actionmailer (4.2.11) 5 | actionpack (= 4.2.11) 6 | actionview (= 4.2.11) 7 | activejob (= 4.2.11) 8 | mail (~> 2.5, >= 2.5.4) 9 | rails-dom-testing (~> 1.0, >= 1.0.5) 10 | actionpack (4.2.11) 11 | actionview (= 4.2.11) 12 | activesupport (= 4.2.11) 13 | rack (~> 1.6) 14 | rack-test (~> 0.6.2) 15 | rails-dom-testing (~> 1.0, >= 1.0.5) 16 | rails-html-sanitizer (~> 1.0, >= 1.0.2) 17 | actionview (4.2.11) 18 | activesupport (= 4.2.11) 19 | builder (~> 3.1) 20 | erubis (~> 2.7.0) 21 | rails-dom-testing (~> 1.0, >= 1.0.5) 22 | rails-html-sanitizer (~> 1.0, >= 1.0.3) 23 | activejob (4.2.11) 24 | activesupport (= 4.2.11) 25 | globalid (>= 0.3.0) 26 | activemodel (4.2.11) 27 | activesupport (= 4.2.11) 28 | builder (~> 3.1) 29 | activerecord (4.2.11) 30 | activemodel (= 4.2.11) 31 | activesupport (= 4.2.11) 32 | arel (~> 6.0) 33 | activesupport (4.2.11) 34 | i18n (~> 0.7) 35 | minitest (~> 5.1) 36 | thread_safe (~> 0.3, >= 0.3.4) 37 | tzinfo (~> 1.1) 38 | arel (6.0.4) 39 | binding_of_caller (0.8.0) 40 | debug_inspector (>= 0.0.1) 41 | builder (3.2.3) 42 | byebug (10.0.2) 43 | concurrent-ruby (1.1.4) 44 | crass (1.0.4) 45 | debug_inspector (0.0.3) 46 | erubis (2.7.0) 47 | execjs (2.7.0) 48 | ffi (1.9.25) 49 | globalid (0.4.1) 50 | activesupport (>= 4.2.0) 51 | i18n (0.9.5) 52 | concurrent-ruby (~> 1.0) 53 | jbuilder (2.8.0) 54 | activesupport (>= 4.2.0) 55 | multi_json (>= 1.2) 56 | json (1.8.6) 57 | loofah (2.2.3) 58 | crass (~> 1.0.2) 59 | nokogiri (>= 1.5.9) 60 | mail (2.7.1) 61 | mini_mime (>= 0.1.1) 62 | mini_mime (1.0.1) 63 | mini_portile2 (2.4.0) 64 | minitest (5.11.3) 65 | multi_json (1.13.1) 66 | nokogiri (1.9.1) 67 | mini_portile2 (~> 2.4.0) 68 | puma (3.12.0) 69 | rack (1.6.11) 70 | rack-test (0.6.3) 71 | rack (>= 1.0) 72 | rails (4.2.11) 73 | actionmailer (= 4.2.11) 74 | actionpack (= 4.2.11) 75 | actionview (= 4.2.11) 76 | activejob (= 4.2.11) 77 | activemodel (= 4.2.11) 78 | activerecord (= 4.2.11) 79 | activesupport (= 4.2.11) 80 | bundler (>= 1.3.0, < 2.0) 81 | railties (= 4.2.11) 82 | sprockets-rails 83 | rails-deprecated_sanitizer (1.0.3) 84 | activesupport (>= 4.2.0.alpha) 85 | rails-dom-testing (1.0.9) 86 | activesupport (>= 4.2.0, < 5.0) 87 | nokogiri (~> 1.6) 88 | rails-deprecated_sanitizer (>= 1.0.1) 89 | rails-html-sanitizer (1.0.4) 90 | loofah (~> 2.2, >= 2.2.2) 91 | railties (4.2.11) 92 | actionpack (= 4.2.11) 93 | activesupport (= 4.2.11) 94 | rake (>= 0.8.7) 95 | thor (>= 0.18.1, < 2.0) 96 | rake (12.3.2) 97 | rb-fsevent (0.10.3) 98 | rb-inotify (0.10.0) 99 | ffi (~> 1.0) 100 | rdoc (4.3.0) 101 | sass (3.7.2) 102 | sass-listen (~> 4.0.0) 103 | sass-listen (4.0.0) 104 | rb-fsevent (~> 0.9, >= 0.9.4) 105 | rb-inotify (~> 0.9, >= 0.9.7) 106 | sass-rails (5.0.7) 107 | railties (>= 4.0.0, < 6) 108 | sass (~> 3.1) 109 | sprockets (>= 2.8, < 4.0) 110 | sprockets-rails (>= 2.0, < 4.0) 111 | tilt (>= 1.1, < 3) 112 | sdoc (0.4.2) 113 | json (~> 1.7, >= 1.7.7) 114 | rdoc (~> 4.0) 115 | sprockets (3.7.2) 116 | concurrent-ruby (~> 1.0) 117 | rack (> 1, < 3) 118 | sprockets-rails (3.2.1) 119 | actionpack (>= 4.0) 120 | activesupport (>= 4.0) 121 | sprockets (>= 3.0.0) 122 | thor (0.20.3) 123 | thread_safe (0.3.6) 124 | tilt (2.0.9) 125 | tzinfo (1.2.5) 126 | thread_safe (~> 0.1) 127 | uglifier (4.1.20) 128 | execjs (>= 0.3.0, < 3) 129 | web-console (2.3.0) 130 | activemodel (>= 4.0) 131 | binding_of_caller (>= 0.7.2) 132 | railties (>= 4.0) 133 | sprockets-rails (>= 2.0, < 4.0) 134 | 135 | PLATFORMS 136 | ruby 137 | 138 | DEPENDENCIES 139 | byebug 140 | jbuilder (~> 2.0) 141 | puma (~> 3.0) 142 | rails (= 4.2.11) 143 | sass-rails (~> 5.0) 144 | sdoc (~> 0.4.0) 145 | uglifier (>= 1.3.0) 146 | web-console (~> 2.0) 147 | 148 | BUNDLED WITH 149 | 1.17.3 150 | -------------------------------------------------------------------------------- /test/sample_apps/rails4_app/Rakefile: -------------------------------------------------------------------------------- 1 | # Add your own tasks in files placed in lib/tasks ending in .rake, 2 | # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake. 3 | 4 | require File.expand_path('../config/application', __FILE__) 5 | 6 | Rails.application.load_tasks 7 | -------------------------------------------------------------------------------- /test/sample_apps/rails4_app/app/assets/images/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GoogleCloudPlatform/ruby-docker/d2dca08aa04430c3e00c1fe1a99e855ccffdd8a1/test/sample_apps/rails4_app/app/assets/images/.keep -------------------------------------------------------------------------------- /test/sample_apps/rails4_app/app/assets/stylesheets/application.css: -------------------------------------------------------------------------------- 1 | /* 2 | * This is a manifest file that'll be compiled into application.css, which will include all the files 3 | * listed below. 4 | * 5 | * Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets, 6 | * or any plugin's vendor/assets/stylesheets directory can be referenced here using a relative path. 7 | * 8 | * You're free to add application-wide styles to this file and they'll appear at the bottom of the 9 | * compiled file so the styles you add here take precedence over styles defined in any styles 10 | * defined in the other CSS/SCSS files in this directory. It is generally better to create a new 11 | * file per style scope. 12 | * 13 | *= require_tree . 14 | *= require_self 15 | */ 16 | -------------------------------------------------------------------------------- /test/sample_apps/rails4_app/app/controllers/application_controller.rb: -------------------------------------------------------------------------------- 1 | class ApplicationController < ActionController::Base 2 | # Prevent CSRF attacks by raising an exception. 3 | # For APIs, you may want to use :null_session instead. 4 | protect_from_forgery with: :exception 5 | end 6 | -------------------------------------------------------------------------------- /test/sample_apps/rails4_app/app/controllers/concerns/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GoogleCloudPlatform/ruby-docker/d2dca08aa04430c3e00c1fe1a99e855ccffdd8a1/test/sample_apps/rails4_app/app/controllers/concerns/.keep -------------------------------------------------------------------------------- /test/sample_apps/rails4_app/app/controllers/home_controller.rb: -------------------------------------------------------------------------------- 1 | class HomeController < ApplicationController 2 | def index 3 | unless Rails.env == "production" 4 | raise "Wrong Rails environment: #{Rails.env}" 5 | end 6 | render :text => "Hello World!" 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /test/sample_apps/rails4_app/app/helpers/application_helper.rb: -------------------------------------------------------------------------------- 1 | module ApplicationHelper 2 | end 3 | -------------------------------------------------------------------------------- /test/sample_apps/rails4_app/app/mailers/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GoogleCloudPlatform/ruby-docker/d2dca08aa04430c3e00c1fe1a99e855ccffdd8a1/test/sample_apps/rails4_app/app/mailers/.keep -------------------------------------------------------------------------------- /test/sample_apps/rails4_app/app/models/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GoogleCloudPlatform/ruby-docker/d2dca08aa04430c3e00c1fe1a99e855ccffdd8a1/test/sample_apps/rails4_app/app/models/.keep -------------------------------------------------------------------------------- /test/sample_apps/rails4_app/app/models/concerns/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GoogleCloudPlatform/ruby-docker/d2dca08aa04430c3e00c1fe1a99e855ccffdd8a1/test/sample_apps/rails4_app/app/models/concerns/.keep -------------------------------------------------------------------------------- /test/sample_apps/rails4_app/app/views/layouts/application.html.erb: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Rails4App 5 | <%= stylesheet_link_tag 'application', media: 'all' %> 6 | <%= csrf_meta_tags %> 7 | 8 | 9 | 10 | <%= yield %> 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /test/sample_apps/rails4_app/bin/bundle: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__) 3 | load Gem.bin_path('bundler', 'bundle') 4 | -------------------------------------------------------------------------------- /test/sample_apps/rails4_app/bin/rails: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | APP_PATH = File.expand_path('../../config/application', __FILE__) 3 | require_relative '../config/boot' 4 | require 'rails/commands' 5 | -------------------------------------------------------------------------------- /test/sample_apps/rails4_app/bin/rake: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | require_relative '../config/boot' 3 | require 'rake' 4 | Rake.application.run 5 | -------------------------------------------------------------------------------- /test/sample_apps/rails4_app/bin/setup: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | require 'pathname' 3 | 4 | # path to your application root. 5 | APP_ROOT = Pathname.new File.expand_path('../../', __FILE__) 6 | 7 | Dir.chdir APP_ROOT do 8 | # This script is a starting point to setup your application. 9 | # Add necessary setup steps to this file: 10 | 11 | puts "== Installing dependencies ==" 12 | system "gem install bundler --conservative" 13 | system "bundle check || bundle install" 14 | 15 | # puts "\n== Copying sample files ==" 16 | # unless File.exist?("config/database.yml") 17 | # system "cp config/database.yml.sample config/database.yml" 18 | # end 19 | 20 | puts "\n== Preparing database ==" 21 | system "bin/rake db:setup" 22 | 23 | puts "\n== Removing old logs and tempfiles ==" 24 | system "rm -f log/*" 25 | system "rm -rf tmp/cache" 26 | 27 | puts "\n== Restarting application server ==" 28 | system "touch tmp/restart.txt" 29 | end 30 | -------------------------------------------------------------------------------- /test/sample_apps/rails4_app/config.ru: -------------------------------------------------------------------------------- 1 | # This file is used by Rack-based servers to start the application. 2 | 3 | require ::File.expand_path('../config/environment', __FILE__) 4 | run Rails.application 5 | -------------------------------------------------------------------------------- /test/sample_apps/rails4_app/config/application.rb: -------------------------------------------------------------------------------- 1 | require File.expand_path('../boot', __FILE__) 2 | 3 | require "rails" 4 | # Pick the frameworks you want: 5 | require "active_model/railtie" 6 | require "active_job/railtie" 7 | # require "active_record/railtie" 8 | require "action_controller/railtie" 9 | require "action_mailer/railtie" 10 | require "action_view/railtie" 11 | require "sprockets/railtie" 12 | # require "rails/test_unit/railtie" 13 | 14 | # Require the gems listed in Gemfile, including any gems 15 | # you've limited to :test, :development, or :production. 16 | Bundler.require(*Rails.groups) 17 | 18 | module Rails4App 19 | class Application < Rails::Application 20 | # Settings in config/environments/* take precedence over those specified here. 21 | # Application configuration should go into files in config/initializers 22 | # -- all .rb files in that directory are automatically loaded. 23 | 24 | # Set Time.zone default to the specified zone and make Active Record auto-convert to this zone. 25 | # Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC. 26 | # config.time_zone = 'Central Time (US & Canada)' 27 | 28 | # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded. 29 | # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s] 30 | # config.i18n.default_locale = :de 31 | end 32 | end 33 | -------------------------------------------------------------------------------- /test/sample_apps/rails4_app/config/boot.rb: -------------------------------------------------------------------------------- 1 | ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__) 2 | 3 | require 'bundler/setup' # Set up gems listed in the Gemfile. 4 | -------------------------------------------------------------------------------- /test/sample_apps/rails4_app/config/environment.rb: -------------------------------------------------------------------------------- 1 | # Load the Rails application. 2 | require File.expand_path('../application', __FILE__) 3 | 4 | # Initialize the Rails application. 5 | Rails.application.initialize! 6 | -------------------------------------------------------------------------------- /test/sample_apps/rails4_app/config/environments/development.rb: -------------------------------------------------------------------------------- 1 | Rails.application.configure do 2 | # Settings specified here will take precedence over those in config/application.rb. 3 | 4 | # In the development environment your application's code is reloaded on 5 | # every request. This slows down response time but is perfect for development 6 | # since you don't have to restart the web server when you make code changes. 7 | config.cache_classes = false 8 | 9 | # Do not eager load code on boot. 10 | config.eager_load = false 11 | 12 | # Show full error reports and disable caching. 13 | config.consider_all_requests_local = true 14 | config.action_controller.perform_caching = false 15 | 16 | # Don't care if the mailer can't send. 17 | config.action_mailer.raise_delivery_errors = false 18 | 19 | # Print deprecation notices to the Rails logger. 20 | config.active_support.deprecation = :log 21 | 22 | # Debug mode disables concatenation and preprocessing of assets. 23 | # This option may cause significant delays in view rendering with a large 24 | # number of complex assets. 25 | config.assets.debug = true 26 | 27 | # Asset digests allow you to set far-future HTTP expiration dates on all assets, 28 | # yet still be able to expire them through the digest params. 29 | config.assets.digest = true 30 | 31 | # Adds additional error checking when serving assets at runtime. 32 | # Checks for improperly declared sprockets dependencies. 33 | # Raises helpful error messages. 34 | config.assets.raise_runtime_errors = true 35 | 36 | # Raises error for missing translations 37 | # config.action_view.raise_on_missing_translations = true 38 | end 39 | -------------------------------------------------------------------------------- /test/sample_apps/rails4_app/config/environments/production.rb: -------------------------------------------------------------------------------- 1 | Rails.application.configure do 2 | # Settings specified here will take precedence over those in config/application.rb. 3 | 4 | # Code is not reloaded between requests. 5 | config.cache_classes = true 6 | 7 | # Eager load code on boot. This eager loads most of Rails and 8 | # your application in memory, allowing both threaded web servers 9 | # and those relying on copy on write to perform better. 10 | # Rake tasks automatically ignore this option for performance. 11 | config.eager_load = true 12 | 13 | # Full error reports are disabled and caching is turned on. 14 | config.consider_all_requests_local = false 15 | config.action_controller.perform_caching = true 16 | 17 | # Enable Rack::Cache to put a simple HTTP cache in front of your application 18 | # Add `rack-cache` to your Gemfile before enabling this. 19 | # For large-scale production use, consider using a caching reverse proxy like 20 | # NGINX, varnish or squid. 21 | # config.action_dispatch.rack_cache = true 22 | 23 | # Disable serving static files from the `/public` folder by default since 24 | # Apache or NGINX already handles this. 25 | config.serve_static_files = ENV['RAILS_SERVE_STATIC_FILES'].present? 26 | 27 | # Compress JavaScripts and CSS. 28 | config.assets.js_compressor = :uglifier 29 | # config.assets.css_compressor = :sass 30 | 31 | # Do not fallback to assets pipeline if a precompiled asset is missed. 32 | config.assets.compile = false 33 | 34 | # Asset digests allow you to set far-future HTTP expiration dates on all assets, 35 | # yet still be able to expire them through the digest params. 36 | config.assets.digest = true 37 | 38 | # `config.assets.precompile` and `config.assets.version` have moved to config/initializers/assets.rb 39 | 40 | # Specifies the header that your server uses for sending files. 41 | # config.action_dispatch.x_sendfile_header = 'X-Sendfile' # for Apache 42 | # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for NGINX 43 | 44 | # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies. 45 | # config.force_ssl = true 46 | 47 | # Use the lowest log level to ensure availability of diagnostic information 48 | # when problems arise. 49 | config.log_level = :debug 50 | 51 | # Prepend all log lines with the following tags. 52 | # config.log_tags = [ :subdomain, :uuid ] 53 | 54 | # Use a different logger for distributed setups. 55 | # config.logger = ActiveSupport::TaggedLogging.new(SyslogLogger.new) 56 | 57 | # Use a different cache store in production. 58 | # config.cache_store = :mem_cache_store 59 | 60 | # Enable serving of images, stylesheets, and JavaScripts from an asset server. 61 | # config.action_controller.asset_host = 'http://assets.example.com' 62 | 63 | # Ignore bad email addresses and do not raise email delivery errors. 64 | # Set this to true and configure the email server for immediate delivery to raise delivery errors. 65 | # config.action_mailer.raise_delivery_errors = false 66 | 67 | # Enable locale fallbacks for I18n (makes lookups for any locale fall back to 68 | # the I18n.default_locale when a translation cannot be found). 69 | config.i18n.fallbacks = true 70 | 71 | # Send deprecation notices to registered listeners. 72 | config.active_support.deprecation = :notify 73 | 74 | # Use default logging formatter so that PID and timestamp are not suppressed. 75 | config.log_formatter = ::Logger::Formatter.new 76 | end 77 | -------------------------------------------------------------------------------- /test/sample_apps/rails4_app/config/environments/test.rb: -------------------------------------------------------------------------------- 1 | Rails.application.configure do 2 | # Settings specified here will take precedence over those in config/application.rb. 3 | 4 | # The test environment is used exclusively to run your application's 5 | # test suite. You never need to work with it otherwise. Remember that 6 | # your test database is "scratch space" for the test suite and is wiped 7 | # and recreated between test runs. Don't rely on the data there! 8 | config.cache_classes = true 9 | 10 | # Do not eager load code on boot. This avoids loading your whole application 11 | # just for the purpose of running a single test. If you are using a tool that 12 | # preloads Rails for running tests, you may have to set it to true. 13 | config.eager_load = false 14 | 15 | # Configure static file server for tests with Cache-Control for performance. 16 | config.serve_static_files = true 17 | config.static_cache_control = 'public, max-age=3600' 18 | 19 | # Show full error reports and disable caching. 20 | config.consider_all_requests_local = true 21 | config.action_controller.perform_caching = false 22 | 23 | # Raise exceptions instead of rendering exception templates. 24 | config.action_dispatch.show_exceptions = false 25 | 26 | # Disable request forgery protection in test environment. 27 | config.action_controller.allow_forgery_protection = false 28 | 29 | # Tell Action Mailer not to deliver emails to the real world. 30 | # The :test delivery method accumulates sent emails in the 31 | # ActionMailer::Base.deliveries array. 32 | config.action_mailer.delivery_method = :test 33 | 34 | # Randomize the order test cases are executed. 35 | config.active_support.test_order = :random 36 | 37 | # Print deprecation notices to the stderr. 38 | config.active_support.deprecation = :stderr 39 | 40 | # Raises error for missing translations 41 | # config.action_view.raise_on_missing_translations = true 42 | end 43 | -------------------------------------------------------------------------------- /test/sample_apps/rails4_app/config/initializers/assets.rb: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | # Version of your assets, change this if you want to expire all your assets. 4 | Rails.application.config.assets.version = '1.0' 5 | 6 | # Add additional assets to the asset load path 7 | # Rails.application.config.assets.paths << Emoji.images_path 8 | 9 | # Precompile additional assets. 10 | # application.js, application.css, and all non-JS/CSS in app/assets folder are already added. 11 | # Rails.application.config.assets.precompile += %w( search.js ) 12 | -------------------------------------------------------------------------------- /test/sample_apps/rails4_app/config/initializers/backtrace_silencers.rb: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | # You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces. 4 | # Rails.backtrace_cleaner.add_silencer { |line| line =~ /my_noisy_library/ } 5 | 6 | # You can also remove all the silencers if you're trying to debug a problem that might stem from framework code. 7 | # Rails.backtrace_cleaner.remove_silencers! 8 | -------------------------------------------------------------------------------- /test/sample_apps/rails4_app/config/initializers/cookies_serializer.rb: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | Rails.application.config.action_dispatch.cookies_serializer = :json 4 | -------------------------------------------------------------------------------- /test/sample_apps/rails4_app/config/initializers/filter_parameter_logging.rb: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | # Configure sensitive parameters which will be filtered from the log file. 4 | Rails.application.config.filter_parameters += [:password] 5 | -------------------------------------------------------------------------------- /test/sample_apps/rails4_app/config/initializers/inflections.rb: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | # Add new inflection rules using the following format. Inflections 4 | # are locale specific, and you may define rules for as many different 5 | # locales as you wish. All of these examples are active by default: 6 | # ActiveSupport::Inflector.inflections(:en) do |inflect| 7 | # inflect.plural /^(ox)$/i, '\1en' 8 | # inflect.singular /^(ox)en/i, '\1' 9 | # inflect.irregular 'person', 'people' 10 | # inflect.uncountable %w( fish sheep ) 11 | # end 12 | 13 | # These inflection rules are supported but not enabled by default: 14 | # ActiveSupport::Inflector.inflections(:en) do |inflect| 15 | # inflect.acronym 'RESTful' 16 | # end 17 | -------------------------------------------------------------------------------- /test/sample_apps/rails4_app/config/initializers/mime_types.rb: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | # Add new mime types for use in respond_to blocks: 4 | # Mime::Type.register "text/richtext", :rtf 5 | -------------------------------------------------------------------------------- /test/sample_apps/rails4_app/config/initializers/session_store.rb: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | Rails.application.config.session_store :cookie_store, key: '_rails4_app_session' 4 | -------------------------------------------------------------------------------- /test/sample_apps/rails4_app/config/initializers/to_time_preserves_timezone.rb: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | # Preserve the timezone of the receiver when calling to `to_time`. 4 | # Ruby 2.4 will change the behavior of `to_time` to preserve the timezone 5 | # when converting to an instance of `Time` instead of the previous behavior 6 | # of converting to the local system timezone. 7 | # 8 | # Rails 5.0 introduced this config option so that apps made with earlier 9 | # versions of Rails are not affected when upgrading. 10 | ActiveSupport.to_time_preserves_timezone = true 11 | -------------------------------------------------------------------------------- /test/sample_apps/rails4_app/config/initializers/wrap_parameters.rb: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | # This file contains settings for ActionController::ParamsWrapper which 4 | # is enabled by default. 5 | 6 | # Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array. 7 | ActiveSupport.on_load(:action_controller) do 8 | wrap_parameters format: [:json] if respond_to?(:wrap_parameters) 9 | end 10 | -------------------------------------------------------------------------------- /test/sample_apps/rails4_app/config/locales/en.yml: -------------------------------------------------------------------------------- 1 | # Files in the config/locales directory are used for internationalization 2 | # and are automatically loaded by Rails. If you want to use locales other 3 | # than English, add the necessary files in this directory. 4 | # 5 | # To use the locales, use `I18n.t`: 6 | # 7 | # I18n.t 'hello' 8 | # 9 | # In views, this is aliased to just `t`: 10 | # 11 | # <%= t('hello') %> 12 | # 13 | # To use a different locale, set it with `I18n.locale`: 14 | # 15 | # I18n.locale = :es 16 | # 17 | # This would use the information in config/locales/es.yml. 18 | # 19 | # To learn more, please read the Rails Internationalization guide 20 | # available at http://guides.rubyonrails.org/i18n.html. 21 | 22 | en: 23 | hello: "Hello world" 24 | -------------------------------------------------------------------------------- /test/sample_apps/rails4_app/config/routes.rb: -------------------------------------------------------------------------------- 1 | Rails.application.routes.draw do 2 | root 'home#index' 3 | end 4 | -------------------------------------------------------------------------------- /test/sample_apps/rails4_app/config/secrets.yml: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | # Your secret key is used for verifying the integrity of signed cookies. 4 | # If you change this key, all old signed cookies will become invalid! 5 | 6 | # Make sure the secret is at least 30 characters and all random, 7 | # no regular words or you'll be exposed to dictionary attacks. 8 | # You can use `rake secret` to generate a secure secret key. 9 | 10 | # Make sure the secrets in this file are kept private 11 | # if you're sharing your code publicly. 12 | 13 | development: 14 | secret_key_base: f0c7803d262f1cacb76a1576313a29cddf68034df6a19569e3d300778e081c233fa2eb45b5577fa3a50865c95aaecffef3e7c1536ac8ce920bec3ad3dae61651 15 | 16 | test: 17 | secret_key_base: 72aa307b8aab475ac1b0526f9370452362ecbfa5605e810c7df32ed76b06800bdb26f5cefa0f441ef81d158d622f5f78666447ea5e6126c5510342be88bab1f2 18 | 19 | # Do not keep production secrets in the repository, 20 | # instead read values from the environment. 21 | production: 22 | secret_key_base: <%= ENV["SECRET_KEY_BASE"] %> 23 | -------------------------------------------------------------------------------- /test/sample_apps/rails4_app/db/seeds.rb: -------------------------------------------------------------------------------- 1 | # This file should contain all the record creation needed to seed the database with its default values. 2 | # The data can then be loaded with the rake db:seed (or created alongside the db with db:setup). 3 | # 4 | # Examples: 5 | # 6 | # cities = City.create([{ name: 'Chicago' }, { name: 'Copenhagen' }]) 7 | # Mayor.create(name: 'Emanuel', city: cities.first) 8 | -------------------------------------------------------------------------------- /test/sample_apps/rails4_app/lib/assets/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GoogleCloudPlatform/ruby-docker/d2dca08aa04430c3e00c1fe1a99e855ccffdd8a1/test/sample_apps/rails4_app/lib/assets/.keep -------------------------------------------------------------------------------- /test/sample_apps/rails4_app/lib/tasks/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GoogleCloudPlatform/ruby-docker/d2dca08aa04430c3e00c1fe1a99e855ccffdd8a1/test/sample_apps/rails4_app/lib/tasks/.keep -------------------------------------------------------------------------------- /test/sample_apps/rails4_app/log/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GoogleCloudPlatform/ruby-docker/d2dca08aa04430c3e00c1fe1a99e855ccffdd8a1/test/sample_apps/rails4_app/log/.keep -------------------------------------------------------------------------------- /test/sample_apps/rails4_app/public/404.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | The page you were looking for doesn't exist (404) 5 | 6 | 55 | 56 | 57 | 58 | 59 |
60 |
61 |

The page you were looking for doesn't exist.

62 |

You may have mistyped the address or the page may have moved.

63 |
64 |

If you are the application owner check the logs for more information.

65 |
66 | 67 | 68 | -------------------------------------------------------------------------------- /test/sample_apps/rails4_app/public/422.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | The change you wanted was rejected (422) 5 | 6 | 55 | 56 | 57 | 58 | 59 |
60 |
61 |

The change you wanted was rejected.

62 |

Maybe you tried to change something you didn't have access to.

63 |
64 |

If you are the application owner check the logs for more information.

65 |
66 | 67 | 68 | -------------------------------------------------------------------------------- /test/sample_apps/rails4_app/public/500.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | We're sorry, but something went wrong (500) 5 | 6 | 55 | 56 | 57 | 58 | 59 |
60 |
61 |

We're sorry, but something went wrong.

62 |
63 |

If you are the application owner check the logs for more information.

64 |
65 | 66 | 67 | -------------------------------------------------------------------------------- /test/sample_apps/rails4_app/public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GoogleCloudPlatform/ruby-docker/d2dca08aa04430c3e00c1fe1a99e855ccffdd8a1/test/sample_apps/rails4_app/public/favicon.ico -------------------------------------------------------------------------------- /test/sample_apps/rails4_app/public/robots.txt: -------------------------------------------------------------------------------- 1 | # See http://www.robotstxt.org/robotstxt.html for documentation on how to use the robots.txt file 2 | # 3 | # To ban all spiders from the entire site uncomment the next two lines: 4 | # User-agent: * 5 | # Disallow: / 6 | -------------------------------------------------------------------------------- /test/sample_apps/rails4_app/vendor/assets/stylesheets/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GoogleCloudPlatform/ruby-docker/d2dca08aa04430c3e00c1fe1a99e855ccffdd8a1/test/sample_apps/rails4_app/vendor/assets/stylesheets/.keep -------------------------------------------------------------------------------- /test/sample_apps/rails5_app/.gitignore: -------------------------------------------------------------------------------- 1 | # See https://help.github.com/articles/ignoring-files for more about ignoring files. 2 | # 3 | # If you find yourself ignoring temporary files generated by your text editor 4 | # or operating system, you probably want to add a global ignore instead: 5 | # git config --global core.excludesfile '~/.gitignore_global' 6 | 7 | # Ignore bundler config. 8 | /.bundle 9 | 10 | # Ignore the default SQLite database. 11 | /db/*.sqlite3 12 | /db/*.sqlite3-journal 13 | 14 | # Ignore all logfiles and tempfiles. 15 | /log/* 16 | /tmp/* 17 | !/log/.keep 18 | !/tmp/.keep 19 | 20 | # Ignore Byebug command history file. 21 | .byebug_history 22 | -------------------------------------------------------------------------------- /test/sample_apps/rails5_app/Gemfile: -------------------------------------------------------------------------------- 1 | source 'https://rubygems.org' 2 | 3 | git_source(:github) do |repo_name| 4 | repo_name = "#{repo_name}/#{repo_name}" unless repo_name.include?("/") 5 | "https://github.com/#{repo_name}.git" 6 | end 7 | 8 | 9 | # Bundle edge Rails instead: gem 'rails', github: 'rails/rails' 10 | gem 'rails', '~> 5.0.7' 11 | # Use sqlite3 as the database for Active Record 12 | gem 'sqlite3' 13 | # Use Puma as the app server 14 | gem 'puma', '~> 3.0' 15 | # Use SCSS for stylesheets 16 | gem 'sass-rails', '~> 5.0' 17 | # Use Uglifier as compressor for JavaScript assets 18 | gem 'uglifier', '>= 1.3.0' 19 | # Use CoffeeScript for .coffee assets and views 20 | gem 'coffee-rails', '~> 4.2' 21 | # See https://github.com/rails/execjs#readme for more supported runtimes 22 | # gem 'therubyracer', platforms: :ruby 23 | 24 | # Use jquery as the JavaScript library 25 | gem 'jquery-rails' 26 | # Turbolinks makes navigating your web application faster. Read more: https://github.com/turbolinks/turbolinks 27 | gem 'turbolinks', '~> 5' 28 | # Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder 29 | gem 'jbuilder', '~> 2.5' 30 | # Use Redis adapter to run Action Cable in production 31 | # gem 'redis', '~> 3.0' 32 | # Use ActiveModel has_secure_password 33 | # gem 'bcrypt', '~> 3.1.7' 34 | 35 | # Use Capistrano for deployment 36 | # gem 'capistrano-rails', group: :development 37 | 38 | group :development, :test do 39 | # Call 'byebug' anywhere in the code to stop execution and get a debugger console 40 | gem 'byebug', platform: :mri 41 | end 42 | 43 | group :development do 44 | # Access an IRB console on exception pages or by using <%= console %> anywhere in the code. 45 | gem 'web-console', '>= 3.3.0' 46 | gem 'listen', '~> 3.0.5' 47 | # Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring 48 | gem 'spring' 49 | gem 'spring-watcher-listen', '~> 2.0.0' 50 | end 51 | 52 | # Windows does not include zoneinfo files, so bundle the tzinfo-data gem 53 | gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby] 54 | -------------------------------------------------------------------------------- /test/sample_apps/rails5_app/Gemfile.lock: -------------------------------------------------------------------------------- 1 | GEM 2 | remote: https://rubygems.org/ 3 | specs: 4 | actioncable (5.0.7.1) 5 | actionpack (= 5.0.7.1) 6 | nio4r (>= 1.2, < 3.0) 7 | websocket-driver (~> 0.6.1) 8 | actionmailer (5.0.7.1) 9 | actionpack (= 5.0.7.1) 10 | actionview (= 5.0.7.1) 11 | activejob (= 5.0.7.1) 12 | mail (~> 2.5, >= 2.5.4) 13 | rails-dom-testing (~> 2.0) 14 | actionpack (5.0.7.1) 15 | actionview (= 5.0.7.1) 16 | activesupport (= 5.0.7.1) 17 | rack (~> 2.0) 18 | rack-test (~> 0.6.3) 19 | rails-dom-testing (~> 2.0) 20 | rails-html-sanitizer (~> 1.0, >= 1.0.2) 21 | actionview (5.0.7.1) 22 | activesupport (= 5.0.7.1) 23 | builder (~> 3.1) 24 | erubis (~> 2.7.0) 25 | rails-dom-testing (~> 2.0) 26 | rails-html-sanitizer (~> 1.0, >= 1.0.3) 27 | activejob (5.0.7.1) 28 | activesupport (= 5.0.7.1) 29 | globalid (>= 0.3.6) 30 | activemodel (5.0.7.1) 31 | activesupport (= 5.0.7.1) 32 | activerecord (5.0.7.1) 33 | activemodel (= 5.0.7.1) 34 | activesupport (= 5.0.7.1) 35 | arel (~> 7.0) 36 | activesupport (5.0.7.1) 37 | concurrent-ruby (~> 1.0, >= 1.0.2) 38 | i18n (>= 0.7, < 2) 39 | minitest (~> 5.1) 40 | tzinfo (~> 1.1) 41 | arel (7.1.4) 42 | bindex (0.5.0) 43 | builder (3.2.3) 44 | byebug (10.0.2) 45 | coffee-rails (4.2.2) 46 | coffee-script (>= 2.2.0) 47 | railties (>= 4.0.0) 48 | coffee-script (2.4.1) 49 | coffee-script-source 50 | execjs 51 | coffee-script-source (1.12.2) 52 | concurrent-ruby (1.1.4) 53 | crass (1.0.4) 54 | erubis (2.7.0) 55 | execjs (2.7.0) 56 | ffi (1.9.25) 57 | globalid (0.4.1) 58 | activesupport (>= 4.2.0) 59 | i18n (1.4.0) 60 | concurrent-ruby (~> 1.0) 61 | jbuilder (2.8.0) 62 | activesupport (>= 4.2.0) 63 | multi_json (>= 1.2) 64 | jquery-rails (4.3.3) 65 | rails-dom-testing (>= 1, < 3) 66 | railties (>= 4.2.0) 67 | thor (>= 0.14, < 2.0) 68 | listen (3.0.8) 69 | rb-fsevent (~> 0.9, >= 0.9.4) 70 | rb-inotify (~> 0.9, >= 0.9.7) 71 | loofah (2.2.3) 72 | crass (~> 1.0.2) 73 | nokogiri (>= 1.5.9) 74 | mail (2.7.1) 75 | mini_mime (>= 0.1.1) 76 | method_source (0.9.2) 77 | mini_mime (1.0.1) 78 | mini_portile2 (2.4.0) 79 | minitest (5.11.3) 80 | multi_json (1.13.1) 81 | nio4r (2.3.1) 82 | nokogiri (1.9.1) 83 | mini_portile2 (~> 2.4.0) 84 | puma (3.12.0) 85 | rack (2.0.6) 86 | rack-test (0.6.3) 87 | rack (>= 1.0) 88 | rails (5.0.7.1) 89 | actioncable (= 5.0.7.1) 90 | actionmailer (= 5.0.7.1) 91 | actionpack (= 5.0.7.1) 92 | actionview (= 5.0.7.1) 93 | activejob (= 5.0.7.1) 94 | activemodel (= 5.0.7.1) 95 | activerecord (= 5.0.7.1) 96 | activesupport (= 5.0.7.1) 97 | bundler (>= 1.3.0) 98 | railties (= 5.0.7.1) 99 | sprockets-rails (>= 2.0.0) 100 | rails-dom-testing (2.0.3) 101 | activesupport (>= 4.2.0) 102 | nokogiri (>= 1.6) 103 | rails-html-sanitizer (1.0.4) 104 | loofah (~> 2.2, >= 2.2.2) 105 | railties (5.0.7.1) 106 | actionpack (= 5.0.7.1) 107 | activesupport (= 5.0.7.1) 108 | method_source 109 | rake (>= 0.8.7) 110 | thor (>= 0.18.1, < 2.0) 111 | rake (12.3.2) 112 | rb-fsevent (0.10.3) 113 | rb-inotify (0.10.0) 114 | ffi (~> 1.0) 115 | sass (3.7.2) 116 | sass-listen (~> 4.0.0) 117 | sass-listen (4.0.0) 118 | rb-fsevent (~> 0.9, >= 0.9.4) 119 | rb-inotify (~> 0.9, >= 0.9.7) 120 | sass-rails (5.0.7) 121 | railties (>= 4.0.0, < 6) 122 | sass (~> 3.1) 123 | sprockets (>= 2.8, < 4.0) 124 | sprockets-rails (>= 2.0, < 4.0) 125 | tilt (>= 1.1, < 3) 126 | spring (2.0.2) 127 | activesupport (>= 4.2) 128 | spring-watcher-listen (2.0.1) 129 | listen (>= 2.7, < 4.0) 130 | spring (>= 1.2, < 3.0) 131 | sprockets (3.7.2) 132 | concurrent-ruby (~> 1.0) 133 | rack (> 1, < 3) 134 | sprockets-rails (3.2.1) 135 | actionpack (>= 4.0) 136 | activesupport (>= 4.0) 137 | sprockets (>= 3.0.0) 138 | sqlite3 (1.3.13) 139 | thor (0.20.3) 140 | thread_safe (0.3.6) 141 | tilt (2.0.9) 142 | turbolinks (5.2.0) 143 | turbolinks-source (~> 5.2) 144 | turbolinks-source (5.2.0) 145 | tzinfo (1.2.5) 146 | thread_safe (~> 0.1) 147 | uglifier (4.1.20) 148 | execjs (>= 0.3.0, < 3) 149 | web-console (3.7.0) 150 | actionview (>= 5.0) 151 | activemodel (>= 5.0) 152 | bindex (>= 0.4.0) 153 | railties (>= 5.0) 154 | websocket-driver (0.6.5) 155 | websocket-extensions (>= 0.1.0) 156 | websocket-extensions (0.1.3) 157 | 158 | PLATFORMS 159 | ruby 160 | 161 | DEPENDENCIES 162 | byebug 163 | coffee-rails (~> 4.2) 164 | jbuilder (~> 2.5) 165 | jquery-rails 166 | listen (~> 3.0.5) 167 | puma (~> 3.0) 168 | rails (~> 5.0.7) 169 | sass-rails (~> 5.0) 170 | spring 171 | spring-watcher-listen (~> 2.0.0) 172 | sqlite3 173 | turbolinks (~> 5) 174 | tzinfo-data 175 | uglifier (>= 1.3.0) 176 | web-console (>= 3.3.0) 177 | 178 | BUNDLED WITH 179 | 1.17.3 180 | -------------------------------------------------------------------------------- /test/sample_apps/rails5_app/README.md: -------------------------------------------------------------------------------- 1 | # README 2 | 3 | This README would normally document whatever steps are necessary to get the 4 | application up and running. 5 | 6 | Things you may want to cover: 7 | 8 | * Ruby version 9 | 10 | * System dependencies 11 | 12 | * Configuration 13 | 14 | * Database creation 15 | 16 | * Database initialization 17 | 18 | * How to run the test suite 19 | 20 | * Services (job queues, cache servers, search engines, etc.) 21 | 22 | * Deployment instructions 23 | 24 | * ... 25 | -------------------------------------------------------------------------------- /test/sample_apps/rails5_app/Rakefile: -------------------------------------------------------------------------------- 1 | # Add your own tasks in files placed in lib/tasks ending in .rake, 2 | # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake. 3 | 4 | require_relative 'config/application' 5 | 6 | Rails.application.load_tasks 7 | -------------------------------------------------------------------------------- /test/sample_apps/rails5_app/app/assets/config/manifest.js: -------------------------------------------------------------------------------- 1 | //= link_tree ../images 2 | //= link_directory ../javascripts .js 3 | //= link_directory ../stylesheets .css 4 | -------------------------------------------------------------------------------- /test/sample_apps/rails5_app/app/assets/images/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GoogleCloudPlatform/ruby-docker/d2dca08aa04430c3e00c1fe1a99e855ccffdd8a1/test/sample_apps/rails5_app/app/assets/images/.keep -------------------------------------------------------------------------------- /test/sample_apps/rails5_app/app/assets/javascripts/application.js: -------------------------------------------------------------------------------- 1 | // This is a manifest file that'll be compiled into application.js, which will include all the files 2 | // listed below. 3 | // 4 | // Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts, 5 | // or any plugin's vendor/assets/javascripts directory can be referenced here using a relative path. 6 | // 7 | // It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the 8 | // compiled file. JavaScript code in this file should be added after the last require_* statement. 9 | // 10 | // Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details 11 | // about supported directives. 12 | // 13 | //= require jquery 14 | //= require jquery_ujs 15 | //= require turbolinks 16 | //= require_tree . 17 | -------------------------------------------------------------------------------- /test/sample_apps/rails5_app/app/assets/javascripts/cable.js: -------------------------------------------------------------------------------- 1 | // Action Cable provides the framework to deal with WebSockets in Rails. 2 | // You can generate new channels where WebSocket features live using the rails generate channel command. 3 | // 4 | //= require action_cable 5 | //= require_self 6 | //= require_tree ./channels 7 | 8 | (function() { 9 | this.App || (this.App = {}); 10 | 11 | App.cable = ActionCable.createConsumer(); 12 | 13 | }).call(this); 14 | -------------------------------------------------------------------------------- /test/sample_apps/rails5_app/app/assets/javascripts/channels/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GoogleCloudPlatform/ruby-docker/d2dca08aa04430c3e00c1fe1a99e855ccffdd8a1/test/sample_apps/rails5_app/app/assets/javascripts/channels/.keep -------------------------------------------------------------------------------- /test/sample_apps/rails5_app/app/assets/stylesheets/application.css: -------------------------------------------------------------------------------- 1 | /* 2 | * This is a manifest file that'll be compiled into application.css, which will include all the files 3 | * listed below. 4 | * 5 | * Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets, 6 | * or any plugin's vendor/assets/stylesheets directory can be referenced here using a relative path. 7 | * 8 | * You're free to add application-wide styles to this file and they'll appear at the bottom of the 9 | * compiled file so the styles you add here take precedence over styles defined in any other CSS/SCSS 10 | * files in this directory. Styles in this file should be added after the last require_* statement. 11 | * It is generally better to create a new file per style scope. 12 | * 13 | *= require_tree . 14 | *= require_self 15 | */ 16 | -------------------------------------------------------------------------------- /test/sample_apps/rails5_app/app/channels/application_cable/channel.rb: -------------------------------------------------------------------------------- 1 | module ApplicationCable 2 | class Channel < ActionCable::Channel::Base 3 | end 4 | end 5 | -------------------------------------------------------------------------------- /test/sample_apps/rails5_app/app/channels/application_cable/connection.rb: -------------------------------------------------------------------------------- 1 | module ApplicationCable 2 | class Connection < ActionCable::Connection::Base 3 | end 4 | end 5 | -------------------------------------------------------------------------------- /test/sample_apps/rails5_app/app/controllers/application_controller.rb: -------------------------------------------------------------------------------- 1 | class ApplicationController < ActionController::Base 2 | protect_from_forgery with: :exception 3 | end 4 | -------------------------------------------------------------------------------- /test/sample_apps/rails5_app/app/controllers/concerns/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GoogleCloudPlatform/ruby-docker/d2dca08aa04430c3e00c1fe1a99e855ccffdd8a1/test/sample_apps/rails5_app/app/controllers/concerns/.keep -------------------------------------------------------------------------------- /test/sample_apps/rails5_app/app/controllers/home_controller.rb: -------------------------------------------------------------------------------- 1 | class HomeController < ApplicationController 2 | 3 | def index 4 | unless Rails.env == "production" 5 | raise "Wrong Rails environment: #{Rails.env}" 6 | end 7 | render :text => "Hello World!" 8 | end 9 | 10 | end 11 | -------------------------------------------------------------------------------- /test/sample_apps/rails5_app/app/helpers/application_helper.rb: -------------------------------------------------------------------------------- 1 | module ApplicationHelper 2 | end 3 | -------------------------------------------------------------------------------- /test/sample_apps/rails5_app/app/jobs/application_job.rb: -------------------------------------------------------------------------------- 1 | class ApplicationJob < ActiveJob::Base 2 | end 3 | -------------------------------------------------------------------------------- /test/sample_apps/rails5_app/app/mailers/application_mailer.rb: -------------------------------------------------------------------------------- 1 | class ApplicationMailer < ActionMailer::Base 2 | default from: 'from@example.com' 3 | layout 'mailer' 4 | end 5 | -------------------------------------------------------------------------------- /test/sample_apps/rails5_app/app/models/application_record.rb: -------------------------------------------------------------------------------- 1 | class ApplicationRecord < ActiveRecord::Base 2 | self.abstract_class = true 3 | end 4 | -------------------------------------------------------------------------------- /test/sample_apps/rails5_app/app/models/concerns/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GoogleCloudPlatform/ruby-docker/d2dca08aa04430c3e00c1fe1a99e855ccffdd8a1/test/sample_apps/rails5_app/app/models/concerns/.keep -------------------------------------------------------------------------------- /test/sample_apps/rails5_app/app/views/layouts/application.html.erb: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Rails5App 5 | <%= csrf_meta_tags %> 6 | 7 | <%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track': 'reload' %> 8 | <%= javascript_include_tag 'application', 'data-turbolinks-track': 'reload' %> 9 | 10 | 11 | 12 | <%= yield %> 13 | 14 | 15 | -------------------------------------------------------------------------------- /test/sample_apps/rails5_app/app/views/layouts/mailer.html.erb: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 8 | 9 | 10 | 11 | <%= yield %> 12 | 13 | 14 | -------------------------------------------------------------------------------- /test/sample_apps/rails5_app/app/views/layouts/mailer.text.erb: -------------------------------------------------------------------------------- 1 | <%= yield %> 2 | -------------------------------------------------------------------------------- /test/sample_apps/rails5_app/bin/bundle: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__) 3 | load Gem.bin_path('bundler', 'bundle') 4 | -------------------------------------------------------------------------------- /test/sample_apps/rails5_app/bin/rails: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | begin 3 | load File.expand_path('../spring', __FILE__) 4 | rescue LoadError => e 5 | raise unless e.message.include?('spring') 6 | end 7 | APP_PATH = File.expand_path('../config/application', __dir__) 8 | require_relative '../config/boot' 9 | require 'rails/commands' 10 | -------------------------------------------------------------------------------- /test/sample_apps/rails5_app/bin/rake: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | begin 3 | load File.expand_path('../spring', __FILE__) 4 | rescue LoadError => e 5 | raise unless e.message.include?('spring') 6 | end 7 | require_relative '../config/boot' 8 | require 'rake' 9 | Rake.application.run 10 | -------------------------------------------------------------------------------- /test/sample_apps/rails5_app/bin/setup: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | require 'pathname' 3 | require 'fileutils' 4 | include FileUtils 5 | 6 | # path to your application root. 7 | APP_ROOT = Pathname.new File.expand_path('../../', __FILE__) 8 | 9 | def system!(*args) 10 | system(*args) || abort("\n== Command #{args} failed ==") 11 | end 12 | 13 | chdir APP_ROOT do 14 | # This script is a starting point to setup your application. 15 | # Add necessary setup steps to this file. 16 | 17 | puts '== Installing dependencies ==' 18 | system! 'gem install bundler --conservative' 19 | system('bundle check') || system!('bundle install') 20 | 21 | # puts "\n== Copying sample files ==" 22 | # unless File.exist?('config/database.yml') 23 | # cp 'config/database.yml.sample', 'config/database.yml' 24 | # end 25 | 26 | puts "\n== Preparing database ==" 27 | system! 'bin/rails db:setup' 28 | 29 | puts "\n== Removing old logs and tempfiles ==" 30 | system! 'bin/rails log:clear tmp:clear' 31 | 32 | puts "\n== Restarting application server ==" 33 | system! 'bin/rails restart' 34 | end 35 | -------------------------------------------------------------------------------- /test/sample_apps/rails5_app/bin/spring: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | 3 | # This file loads spring without using Bundler, in order to be fast. 4 | # It gets overwritten when you run the `spring binstub` command. 5 | 6 | unless defined?(Spring) 7 | require 'rubygems' 8 | require 'bundler' 9 | 10 | lockfile = Bundler::LockfileParser.new(Bundler.default_lockfile.read) 11 | if spring = lockfile.specs.detect { |spec| spec.name == "spring" } 12 | Gem.use_paths Gem.dir, Bundler.bundle_path.to_s, *Gem.path 13 | gem 'spring', spring.version 14 | require 'spring/binstub' 15 | end 16 | end 17 | -------------------------------------------------------------------------------- /test/sample_apps/rails5_app/bin/update: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | require 'pathname' 3 | require 'fileutils' 4 | include FileUtils 5 | 6 | # path to your application root. 7 | APP_ROOT = Pathname.new File.expand_path('../../', __FILE__) 8 | 9 | def system!(*args) 10 | system(*args) || abort("\n== Command #{args} failed ==") 11 | end 12 | 13 | chdir APP_ROOT do 14 | # This script is a way to update your development environment automatically. 15 | # Add necessary update steps to this file. 16 | 17 | puts '== Installing dependencies ==' 18 | system! 'gem install bundler --conservative' 19 | system('bundle check') || system!('bundle install') 20 | 21 | puts "\n== Updating database ==" 22 | system! 'bin/rails db:migrate' 23 | 24 | puts "\n== Removing old logs and tempfiles ==" 25 | system! 'bin/rails log:clear tmp:clear' 26 | 27 | puts "\n== Restarting application server ==" 28 | system! 'bin/rails restart' 29 | end 30 | -------------------------------------------------------------------------------- /test/sample_apps/rails5_app/config.ru: -------------------------------------------------------------------------------- 1 | # This file is used by Rack-based servers to start the application. 2 | 3 | require_relative 'config/environment' 4 | 5 | run Rails.application 6 | -------------------------------------------------------------------------------- /test/sample_apps/rails5_app/config/application.rb: -------------------------------------------------------------------------------- 1 | require_relative 'boot' 2 | 3 | require 'rails/all' 4 | 5 | # Require the gems listed in Gemfile, including any gems 6 | # you've limited to :test, :development, or :production. 7 | Bundler.require(*Rails.groups) 8 | 9 | module Rails5App 10 | class Application < Rails::Application 11 | # Settings in config/environments/* take precedence over those specified here. 12 | # Application configuration should go into files in config/initializers 13 | # -- all .rb files in that directory are automatically loaded. 14 | end 15 | end 16 | -------------------------------------------------------------------------------- /test/sample_apps/rails5_app/config/boot.rb: -------------------------------------------------------------------------------- 1 | ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__) 2 | 3 | require 'bundler/setup' # Set up gems listed in the Gemfile. 4 | -------------------------------------------------------------------------------- /test/sample_apps/rails5_app/config/cable.yml: -------------------------------------------------------------------------------- 1 | development: 2 | adapter: async 3 | 4 | test: 5 | adapter: async 6 | 7 | production: 8 | adapter: redis 9 | url: redis://localhost:6379/1 10 | -------------------------------------------------------------------------------- /test/sample_apps/rails5_app/config/database.yml: -------------------------------------------------------------------------------- 1 | # SQLite version 3.x 2 | # gem install sqlite3 3 | # 4 | # Ensure the SQLite 3 gem is defined in your Gemfile 5 | # gem 'sqlite3' 6 | # 7 | default: &default 8 | adapter: sqlite3 9 | pool: 5 10 | timeout: 5000 11 | 12 | development: 13 | <<: *default 14 | database: db/development.sqlite3 15 | 16 | # Warning: The database defined as "test" will be erased and 17 | # re-generated from your development database when you run "rake". 18 | # Do not set this db to the same as development or production. 19 | test: 20 | <<: *default 21 | database: db/test.sqlite3 22 | 23 | production: 24 | <<: *default 25 | database: db/production.sqlite3 26 | -------------------------------------------------------------------------------- /test/sample_apps/rails5_app/config/environment.rb: -------------------------------------------------------------------------------- 1 | # Load the Rails application. 2 | require_relative 'application' 3 | 4 | # Initialize the Rails application. 5 | Rails.application.initialize! 6 | -------------------------------------------------------------------------------- /test/sample_apps/rails5_app/config/environments/development.rb: -------------------------------------------------------------------------------- 1 | Rails.application.configure do 2 | # Settings specified here will take precedence over those in config/application.rb. 3 | 4 | # In the development environment your application's code is reloaded on 5 | # every request. This slows down response time but is perfect for development 6 | # since you don't have to restart the web server when you make code changes. 7 | config.cache_classes = false 8 | 9 | # Do not eager load code on boot. 10 | config.eager_load = false 11 | 12 | # Show full error reports. 13 | config.consider_all_requests_local = true 14 | 15 | # Enable/disable caching. By default caching is disabled. 16 | if Rails.root.join('tmp/caching-dev.txt').exist? 17 | config.action_controller.perform_caching = true 18 | 19 | config.cache_store = :memory_store 20 | config.public_file_server.headers = { 21 | 'Cache-Control' => 'public, max-age=172800' 22 | } 23 | else 24 | config.action_controller.perform_caching = false 25 | 26 | config.cache_store = :null_store 27 | end 28 | 29 | # Don't care if the mailer can't send. 30 | config.action_mailer.raise_delivery_errors = false 31 | 32 | config.action_mailer.perform_caching = false 33 | 34 | # Print deprecation notices to the Rails logger. 35 | config.active_support.deprecation = :log 36 | 37 | # Raise an error on page load if there are pending migrations. 38 | config.active_record.migration_error = :page_load 39 | 40 | # Debug mode disables concatenation and preprocessing of assets. 41 | # This option may cause significant delays in view rendering with a large 42 | # number of complex assets. 43 | config.assets.debug = true 44 | 45 | # Suppress logger output for asset requests. 46 | config.assets.quiet = true 47 | 48 | # Raises error for missing translations 49 | # config.action_view.raise_on_missing_translations = true 50 | 51 | # Use an evented file watcher to asynchronously detect changes in source code, 52 | # routes, locales, etc. This feature depends on the listen gem. 53 | config.file_watcher = ActiveSupport::EventedFileUpdateChecker 54 | end 55 | -------------------------------------------------------------------------------- /test/sample_apps/rails5_app/config/environments/production.rb: -------------------------------------------------------------------------------- 1 | Rails.application.configure do 2 | # Settings specified here will take precedence over those in config/application.rb. 3 | 4 | # Code is not reloaded between requests. 5 | config.cache_classes = true 6 | 7 | # Eager load code on boot. This eager loads most of Rails and 8 | # your application in memory, allowing both threaded web servers 9 | # and those relying on copy on write to perform better. 10 | # Rake tasks automatically ignore this option for performance. 11 | config.eager_load = true 12 | 13 | # Full error reports are disabled and caching is turned on. 14 | config.consider_all_requests_local = false 15 | config.action_controller.perform_caching = true 16 | 17 | # Disable serving static files from the `/public` folder by default since 18 | # Apache or NGINX already handles this. 19 | config.public_file_server.enabled = ENV['RAILS_SERVE_STATIC_FILES'].present? 20 | 21 | # Compress JavaScripts and CSS. 22 | config.assets.js_compressor = :uglifier 23 | # config.assets.css_compressor = :sass 24 | 25 | # Do not fallback to assets pipeline if a precompiled asset is missed. 26 | config.assets.compile = false 27 | 28 | # `config.assets.precompile` and `config.assets.version` have moved to config/initializers/assets.rb 29 | 30 | # Enable serving of images, stylesheets, and JavaScripts from an asset server. 31 | # config.action_controller.asset_host = 'http://assets.example.com' 32 | 33 | # Specifies the header that your server uses for sending files. 34 | # config.action_dispatch.x_sendfile_header = 'X-Sendfile' # for Apache 35 | # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for NGINX 36 | 37 | # Mount Action Cable outside main process or domain 38 | # config.action_cable.mount_path = nil 39 | # config.action_cable.url = 'wss://example.com/cable' 40 | # config.action_cable.allowed_request_origins = [ 'http://example.com', /http:\/\/example.*/ ] 41 | 42 | # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies. 43 | # config.force_ssl = true 44 | 45 | # Use the lowest log level to ensure availability of diagnostic information 46 | # when problems arise. 47 | config.log_level = :debug 48 | 49 | # Prepend all log lines with the following tags. 50 | config.log_tags = [ :request_id ] 51 | 52 | # Use a different cache store in production. 53 | # config.cache_store = :mem_cache_store 54 | 55 | # Use a real queuing backend for Active Job (and separate queues per environment) 56 | # config.active_job.queue_adapter = :resque 57 | # config.active_job.queue_name_prefix = "rails5_app_#{Rails.env}" 58 | config.action_mailer.perform_caching = false 59 | 60 | # Ignore bad email addresses and do not raise email delivery errors. 61 | # Set this to true and configure the email server for immediate delivery to raise delivery errors. 62 | # config.action_mailer.raise_delivery_errors = false 63 | 64 | # Enable locale fallbacks for I18n (makes lookups for any locale fall back to 65 | # the I18n.default_locale when a translation cannot be found). 66 | config.i18n.fallbacks = true 67 | 68 | # Send deprecation notices to registered listeners. 69 | config.active_support.deprecation = :notify 70 | 71 | # Use default logging formatter so that PID and timestamp are not suppressed. 72 | config.log_formatter = ::Logger::Formatter.new 73 | 74 | # Use a different logger for distributed setups. 75 | # require 'syslog/logger' 76 | # config.logger = ActiveSupport::TaggedLogging.new(Syslog::Logger.new 'app-name') 77 | 78 | if ENV["RAILS_LOG_TO_STDOUT"].present? 79 | logger = ActiveSupport::Logger.new(STDOUT) 80 | logger.formatter = config.log_formatter 81 | config.logger = ActiveSupport::TaggedLogging.new(logger) 82 | end 83 | 84 | # Do not dump schema after migrations. 85 | config.active_record.dump_schema_after_migration = false 86 | end 87 | -------------------------------------------------------------------------------- /test/sample_apps/rails5_app/config/environments/test.rb: -------------------------------------------------------------------------------- 1 | Rails.application.configure do 2 | # Settings specified here will take precedence over those in config/application.rb. 3 | 4 | # The test environment is used exclusively to run your application's 5 | # test suite. You never need to work with it otherwise. Remember that 6 | # your test database is "scratch space" for the test suite and is wiped 7 | # and recreated between test runs. Don't rely on the data there! 8 | config.cache_classes = true 9 | 10 | # Do not eager load code on boot. This avoids loading your whole application 11 | # just for the purpose of running a single test. If you are using a tool that 12 | # preloads Rails for running tests, you may have to set it to true. 13 | config.eager_load = false 14 | 15 | # Configure public file server for tests with Cache-Control for performance. 16 | config.public_file_server.enabled = true 17 | config.public_file_server.headers = { 18 | 'Cache-Control' => 'public, max-age=3600' 19 | } 20 | 21 | # Show full error reports and disable caching. 22 | config.consider_all_requests_local = true 23 | config.action_controller.perform_caching = false 24 | 25 | # Raise exceptions instead of rendering exception templates. 26 | config.action_dispatch.show_exceptions = false 27 | 28 | # Disable request forgery protection in test environment. 29 | config.action_controller.allow_forgery_protection = false 30 | config.action_mailer.perform_caching = false 31 | 32 | # Tell Action Mailer not to deliver emails to the real world. 33 | # The :test delivery method accumulates sent emails in the 34 | # ActionMailer::Base.deliveries array. 35 | config.action_mailer.delivery_method = :test 36 | 37 | # Print deprecation notices to the stderr. 38 | config.active_support.deprecation = :stderr 39 | 40 | # Raises error for missing translations 41 | # config.action_view.raise_on_missing_translations = true 42 | end 43 | -------------------------------------------------------------------------------- /test/sample_apps/rails5_app/config/initializers/application_controller_renderer.rb: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | # ApplicationController.renderer.defaults.merge!( 4 | # http_host: 'example.org', 5 | # https: false 6 | # ) 7 | -------------------------------------------------------------------------------- /test/sample_apps/rails5_app/config/initializers/assets.rb: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | # Version of your assets, change this if you want to expire all your assets. 4 | Rails.application.config.assets.version = '1.0' 5 | 6 | # Add additional assets to the asset load path 7 | # Rails.application.config.assets.paths << Emoji.images_path 8 | 9 | # Precompile additional assets. 10 | # application.js, application.css, and all non-JS/CSS in app/assets folder are already added. 11 | # Rails.application.config.assets.precompile += %w( search.js ) 12 | -------------------------------------------------------------------------------- /test/sample_apps/rails5_app/config/initializers/backtrace_silencers.rb: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | # You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces. 4 | # Rails.backtrace_cleaner.add_silencer { |line| line =~ /my_noisy_library/ } 5 | 6 | # You can also remove all the silencers if you're trying to debug a problem that might stem from framework code. 7 | # Rails.backtrace_cleaner.remove_silencers! 8 | -------------------------------------------------------------------------------- /test/sample_apps/rails5_app/config/initializers/cookies_serializer.rb: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | # Specify a serializer for the signed and encrypted cookie jars. 4 | # Valid options are :json, :marshal, and :hybrid. 5 | Rails.application.config.action_dispatch.cookies_serializer = :json 6 | -------------------------------------------------------------------------------- /test/sample_apps/rails5_app/config/initializers/filter_parameter_logging.rb: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | # Configure sensitive parameters which will be filtered from the log file. 4 | Rails.application.config.filter_parameters += [:password] 5 | -------------------------------------------------------------------------------- /test/sample_apps/rails5_app/config/initializers/inflections.rb: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | # Add new inflection rules using the following format. Inflections 4 | # are locale specific, and you may define rules for as many different 5 | # locales as you wish. All of these examples are active by default: 6 | # ActiveSupport::Inflector.inflections(:en) do |inflect| 7 | # inflect.plural /^(ox)$/i, '\1en' 8 | # inflect.singular /^(ox)en/i, '\1' 9 | # inflect.irregular 'person', 'people' 10 | # inflect.uncountable %w( fish sheep ) 11 | # end 12 | 13 | # These inflection rules are supported but not enabled by default: 14 | # ActiveSupport::Inflector.inflections(:en) do |inflect| 15 | # inflect.acronym 'RESTful' 16 | # end 17 | -------------------------------------------------------------------------------- /test/sample_apps/rails5_app/config/initializers/mime_types.rb: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | # Add new mime types for use in respond_to blocks: 4 | # Mime::Type.register "text/richtext", :rtf 5 | -------------------------------------------------------------------------------- /test/sample_apps/rails5_app/config/initializers/new_framework_defaults.rb: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | # 3 | # This file contains migration options to ease your Rails 5.0 upgrade. 4 | # 5 | # Read the Guide for Upgrading Ruby on Rails for more info on each option. 6 | 7 | # Enable per-form CSRF tokens. Previous versions had false. 8 | Rails.application.config.action_controller.per_form_csrf_tokens = true 9 | 10 | # Enable origin-checking CSRF mitigation. Previous versions had false. 11 | Rails.application.config.action_controller.forgery_protection_origin_check = true 12 | 13 | # Make Ruby 2.4 preserve the timezone of the receiver when calling `to_time`. 14 | # Previous versions had false. 15 | ActiveSupport.to_time_preserves_timezone = true 16 | 17 | # Require `belongs_to` associations by default. Previous versions had false. 18 | Rails.application.config.active_record.belongs_to_required_by_default = true 19 | 20 | # Do not halt callback chains when a callback returns false. Previous versions had true. 21 | ActiveSupport.halt_callback_chains_on_return_false = false 22 | 23 | # Configure SSL options to enable HSTS with subdomains. Previous versions had false. 24 | Rails.application.config.ssl_options = { hsts: { subdomains: true } } 25 | -------------------------------------------------------------------------------- /test/sample_apps/rails5_app/config/initializers/session_store.rb: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | Rails.application.config.session_store :cookie_store, key: '_rails5_app_session' 4 | -------------------------------------------------------------------------------- /test/sample_apps/rails5_app/config/initializers/wrap_parameters.rb: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | # This file contains settings for ActionController::ParamsWrapper which 4 | # is enabled by default. 5 | 6 | # Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array. 7 | ActiveSupport.on_load(:action_controller) do 8 | wrap_parameters format: [:json] 9 | end 10 | 11 | # To enable root element in JSON for ActiveRecord objects. 12 | # ActiveSupport.on_load(:active_record) do 13 | # self.include_root_in_json = true 14 | # end 15 | -------------------------------------------------------------------------------- /test/sample_apps/rails5_app/config/locales/en.yml: -------------------------------------------------------------------------------- 1 | # Files in the config/locales directory are used for internationalization 2 | # and are automatically loaded by Rails. If you want to use locales other 3 | # than English, add the necessary files in this directory. 4 | # 5 | # To use the locales, use `I18n.t`: 6 | # 7 | # I18n.t 'hello' 8 | # 9 | # In views, this is aliased to just `t`: 10 | # 11 | # <%= t('hello') %> 12 | # 13 | # To use a different locale, set it with `I18n.locale`: 14 | # 15 | # I18n.locale = :es 16 | # 17 | # This would use the information in config/locales/es.yml. 18 | # 19 | # To learn more, please read the Rails Internationalization guide 20 | # available at http://guides.rubyonrails.org/i18n.html. 21 | 22 | en: 23 | hello: "Hello world" 24 | -------------------------------------------------------------------------------- /test/sample_apps/rails5_app/config/puma.rb: -------------------------------------------------------------------------------- 1 | # Puma can serve each request in a thread from an internal thread pool. 2 | # The `threads` method setting takes two numbers a minimum and maximum. 3 | # Any libraries that use thread pools should be configured to match 4 | # the maximum value specified for Puma. Default is set to 5 threads for minimum 5 | # and maximum, this matches the default thread size of Active Record. 6 | # 7 | threads_count = ENV.fetch("RAILS_MAX_THREADS") { 5 }.to_i 8 | threads threads_count, threads_count 9 | 10 | # Specifies the `port` that Puma will listen on to receive requests, default is 3000. 11 | # 12 | port ENV.fetch("PORT") { 3000 } 13 | 14 | # Specifies the `environment` that Puma will run in. 15 | # 16 | environment ENV.fetch("RAILS_ENV") { "development" } 17 | 18 | # Specifies the number of `workers` to boot in clustered mode. 19 | # Workers are forked webserver processes. If using threads and workers together 20 | # the concurrency of the application would be max `threads` * `workers`. 21 | # Workers do not work on JRuby or Windows (both of which do not support 22 | # processes). 23 | # 24 | # workers ENV.fetch("WEB_CONCURRENCY") { 2 } 25 | 26 | # Use the `preload_app!` method when specifying a `workers` number. 27 | # This directive tells Puma to first boot the application and load code 28 | # before forking the application. This takes advantage of Copy On Write 29 | # process behavior so workers use less memory. If you use this option 30 | # you need to make sure to reconnect any threads in the `on_worker_boot` 31 | # block. 32 | # 33 | # preload_app! 34 | 35 | # The code in the `on_worker_boot` will be called if you are using 36 | # clustered mode by specifying a number of `workers`. After each worker 37 | # process is booted this block will be run, if you are using `preload_app!` 38 | # option you will want to use this block to reconnect to any threads 39 | # or connections that may have been created at application boot, Ruby 40 | # cannot share connections between processes. 41 | # 42 | # on_worker_boot do 43 | # ActiveRecord::Base.establish_connection if defined?(ActiveRecord) 44 | # end 45 | 46 | # Allow puma to be restarted by `rails restart` command. 47 | plugin :tmp_restart 48 | -------------------------------------------------------------------------------- /test/sample_apps/rails5_app/config/routes.rb: -------------------------------------------------------------------------------- 1 | Rails.application.routes.draw do 2 | root 'home#index' 3 | end 4 | -------------------------------------------------------------------------------- /test/sample_apps/rails5_app/config/secrets.yml: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | # Your secret key is used for verifying the integrity of signed cookies. 4 | # If you change this key, all old signed cookies will become invalid! 5 | 6 | # Make sure the secret is at least 30 characters and all random, 7 | # no regular words or you'll be exposed to dictionary attacks. 8 | # You can use `rails secret` to generate a secure secret key. 9 | 10 | # Make sure the secrets in this file are kept private 11 | # if you're sharing your code publicly. 12 | 13 | development: 14 | secret_key_base: c5a6d110e7f807886b7271d80fff7041d9ec2368b9e3ed43a36ff672d4b35e9409571e018957419492d018add1659f5c65d8dcc74e979dfd8aac39d17221b74a 15 | 16 | test: 17 | secret_key_base: 1bf32d11648023ec2a58142a70769f4d69033a6d7f4e77d5e8a645a6dafb476bc9572725a3a5e8f2f3a6c9116eab525c49f97975b111f59d009075d6b3503bcc 18 | 19 | # Do not keep production secrets in the repository, 20 | # instead read values from the environment. 21 | production: 22 | secret_key_base: <%= ENV["SECRET_KEY_BASE"] %> 23 | -------------------------------------------------------------------------------- /test/sample_apps/rails5_app/config/spring.rb: -------------------------------------------------------------------------------- 1 | %w( 2 | .ruby-version 3 | .rbenv-vars 4 | tmp/restart.txt 5 | tmp/caching-dev.txt 6 | ).each { |path| Spring.watch(path) } 7 | -------------------------------------------------------------------------------- /test/sample_apps/rails5_app/db/seeds.rb: -------------------------------------------------------------------------------- 1 | # This file should contain all the record creation needed to seed the database with its default values. 2 | # The data can then be loaded with the rails db:seed command (or created alongside the database with db:setup). 3 | # 4 | # Examples: 5 | # 6 | # movies = Movie.create([{ name: 'Star Wars' }, { name: 'Lord of the Rings' }]) 7 | # Character.create(name: 'Luke', movie: movies.first) 8 | -------------------------------------------------------------------------------- /test/sample_apps/rails5_app/lib/assets/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GoogleCloudPlatform/ruby-docker/d2dca08aa04430c3e00c1fe1a99e855ccffdd8a1/test/sample_apps/rails5_app/lib/assets/.keep -------------------------------------------------------------------------------- /test/sample_apps/rails5_app/lib/tasks/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GoogleCloudPlatform/ruby-docker/d2dca08aa04430c3e00c1fe1a99e855ccffdd8a1/test/sample_apps/rails5_app/lib/tasks/.keep -------------------------------------------------------------------------------- /test/sample_apps/rails5_app/log/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GoogleCloudPlatform/ruby-docker/d2dca08aa04430c3e00c1fe1a99e855ccffdd8a1/test/sample_apps/rails5_app/log/.keep -------------------------------------------------------------------------------- /test/sample_apps/rails5_app/public/404.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | The page you were looking for doesn't exist (404) 5 | 6 | 55 | 56 | 57 | 58 | 59 |
60 |
61 |

The page you were looking for doesn't exist.

62 |

You may have mistyped the address or the page may have moved.

63 |
64 |

If you are the application owner check the logs for more information.

65 |
66 | 67 | 68 | -------------------------------------------------------------------------------- /test/sample_apps/rails5_app/public/422.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | The change you wanted was rejected (422) 5 | 6 | 55 | 56 | 57 | 58 | 59 |
60 |
61 |

The change you wanted was rejected.

62 |

Maybe you tried to change something you didn't have access to.

63 |
64 |

If you are the application owner check the logs for more information.

65 |
66 | 67 | 68 | -------------------------------------------------------------------------------- /test/sample_apps/rails5_app/public/500.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | We're sorry, but something went wrong (500) 5 | 6 | 55 | 56 | 57 | 58 | 59 |
60 |
61 |

We're sorry, but something went wrong.

62 |
63 |

If you are the application owner check the logs for more information.

64 |
65 | 66 | 67 | -------------------------------------------------------------------------------- /test/sample_apps/rails5_app/public/apple-touch-icon-precomposed.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GoogleCloudPlatform/ruby-docker/d2dca08aa04430c3e00c1fe1a99e855ccffdd8a1/test/sample_apps/rails5_app/public/apple-touch-icon-precomposed.png -------------------------------------------------------------------------------- /test/sample_apps/rails5_app/public/apple-touch-icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GoogleCloudPlatform/ruby-docker/d2dca08aa04430c3e00c1fe1a99e855ccffdd8a1/test/sample_apps/rails5_app/public/apple-touch-icon.png -------------------------------------------------------------------------------- /test/sample_apps/rails5_app/public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GoogleCloudPlatform/ruby-docker/d2dca08aa04430c3e00c1fe1a99e855ccffdd8a1/test/sample_apps/rails5_app/public/favicon.ico -------------------------------------------------------------------------------- /test/sample_apps/rails5_app/public/robots.txt: -------------------------------------------------------------------------------- 1 | # See http://www.robotstxt.org/robotstxt.html for documentation on how to use the robots.txt file 2 | # 3 | # To ban all spiders from the entire site uncomment the next two lines: 4 | # User-agent: * 5 | # Disallow: / 6 | -------------------------------------------------------------------------------- /test/sample_apps/rails5_app/test/controllers/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GoogleCloudPlatform/ruby-docker/d2dca08aa04430c3e00c1fe1a99e855ccffdd8a1/test/sample_apps/rails5_app/test/controllers/.keep -------------------------------------------------------------------------------- /test/sample_apps/rails5_app/test/fixtures/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GoogleCloudPlatform/ruby-docker/d2dca08aa04430c3e00c1fe1a99e855ccffdd8a1/test/sample_apps/rails5_app/test/fixtures/.keep -------------------------------------------------------------------------------- /test/sample_apps/rails5_app/test/fixtures/files/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GoogleCloudPlatform/ruby-docker/d2dca08aa04430c3e00c1fe1a99e855ccffdd8a1/test/sample_apps/rails5_app/test/fixtures/files/.keep -------------------------------------------------------------------------------- /test/sample_apps/rails5_app/test/helpers/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GoogleCloudPlatform/ruby-docker/d2dca08aa04430c3e00c1fe1a99e855ccffdd8a1/test/sample_apps/rails5_app/test/helpers/.keep -------------------------------------------------------------------------------- /test/sample_apps/rails5_app/test/integration/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GoogleCloudPlatform/ruby-docker/d2dca08aa04430c3e00c1fe1a99e855ccffdd8a1/test/sample_apps/rails5_app/test/integration/.keep -------------------------------------------------------------------------------- /test/sample_apps/rails5_app/test/mailers/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GoogleCloudPlatform/ruby-docker/d2dca08aa04430c3e00c1fe1a99e855ccffdd8a1/test/sample_apps/rails5_app/test/mailers/.keep -------------------------------------------------------------------------------- /test/sample_apps/rails5_app/test/models/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GoogleCloudPlatform/ruby-docker/d2dca08aa04430c3e00c1fe1a99e855ccffdd8a1/test/sample_apps/rails5_app/test/models/.keep -------------------------------------------------------------------------------- /test/sample_apps/rails5_app/test/test_helper.rb: -------------------------------------------------------------------------------- 1 | ENV['RAILS_ENV'] ||= 'test' 2 | require File.expand_path('../../config/environment', __FILE__) 3 | require 'rails/test_help' 4 | 5 | class ActiveSupport::TestCase 6 | # Setup all fixtures in test/fixtures/*.yml for all tests in alphabetical order. 7 | fixtures :all 8 | 9 | # Add more helper methods to be used by all tests here... 10 | end 11 | -------------------------------------------------------------------------------- /test/sample_apps/rails5_app/tmp/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GoogleCloudPlatform/ruby-docker/d2dca08aa04430c3e00c1fe1a99e855ccffdd8a1/test/sample_apps/rails5_app/tmp/.keep -------------------------------------------------------------------------------- /test/sample_apps/rails5_app/vendor/assets/javascripts/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GoogleCloudPlatform/ruby-docker/d2dca08aa04430c3e00c1fe1a99e855ccffdd8a1/test/sample_apps/rails5_app/vendor/assets/javascripts/.keep -------------------------------------------------------------------------------- /test/sample_apps/rails5_app/vendor/assets/stylesheets/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GoogleCloudPlatform/ruby-docker/d2dca08aa04430c3e00c1fe1a99e855ccffdd8a1/test/sample_apps/rails5_app/vendor/assets/stylesheets/.keep -------------------------------------------------------------------------------- /test/sample_apps/sinatra1_app/Dockerfile.in: -------------------------------------------------------------------------------- 1 | FROM ${STAGING_IMAGE} 2 | 3 | COPY . /app/ 4 | 5 | RUN cd /app && bundle install 6 | 7 | ENTRYPOINT bundle exec ruby /app/myapp.rb 8 | 9 | -------------------------------------------------------------------------------- /test/sample_apps/sinatra1_app/Gemfile: -------------------------------------------------------------------------------- 1 | source 'https://rubygems.org' 2 | 3 | gem 'sinatra', '~> 2.0' 4 | -------------------------------------------------------------------------------- /test/sample_apps/sinatra1_app/Gemfile.lock: -------------------------------------------------------------------------------- 1 | GEM 2 | remote: https://rubygems.org/ 3 | specs: 4 | mustermann (1.0.3) 5 | rack (2.0.6) 6 | rack-protection (2.0.5) 7 | rack 8 | sinatra (2.0.5) 9 | mustermann (~> 1.0) 10 | rack (~> 2.0) 11 | rack-protection (= 2.0.5) 12 | tilt (~> 2.0) 13 | tilt (2.0.9) 14 | 15 | PLATFORMS 16 | ruby 17 | 18 | DEPENDENCIES 19 | sinatra (~> 2.0) 20 | 21 | BUNDLED WITH 22 | 1.17.3 23 | -------------------------------------------------------------------------------- /test/sample_apps/sinatra1_app/app.yaml: -------------------------------------------------------------------------------- 1 | runtime: custom 2 | env: flex 3 | 4 | -------------------------------------------------------------------------------- /test/sample_apps/sinatra1_app/myapp.rb: -------------------------------------------------------------------------------- 1 | require 'sinatra' 2 | 3 | set :environment, :production 4 | set :bind, "0.0.0.0" 5 | set :port, 8080 6 | set :show_exceptions, true 7 | 8 | get '/' do 9 | "Hello World!" 10 | end 11 | -------------------------------------------------------------------------------- /test/test_app_engine_exec_wrapper.rb: -------------------------------------------------------------------------------- 1 | # Copyright 2017 Google Inc. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | require_relative "helper" 16 | 17 | class TestAppEngineExecWrapper < ::Minitest::Test 18 | include Helper 19 | 20 | def test_simple 21 | run_test "simple", {VAR1: "value1", VAR2: "value2"}, "sql:1:2:3" 22 | end 23 | 24 | def test_no_cloudsql 25 | run_test "no_cloudsql", {VAR1: "value1", VAR2: "value2"} 26 | end 27 | 28 | WRAPPER_TESTS_DIR = "#{::File.dirname __FILE__}/app_engine_exec_wrapper" 29 | 30 | def run_test test_case, env, sql_instances=nil 31 | ::Dir.chdir "#{WRAPPER_TESTS_DIR}/#{test_case}" do 32 | build_docker_image("--no-cache") do |image| 33 | env_params = env.map{ |k, v| "-e #{k}=#{v}" }.join " " 34 | sql_params = Array(sql_instances).map{ |s| "-s #{s}" }.join ' ' 35 | assert_cmd_succeeds "docker run --rm" + 36 | " --volume=/var/run/docker.sock:/var/run/docker.sock" + 37 | " app-engine-exec-harness" + 38 | " -i #{image} #{env_params} #{sql_params}" + 39 | " -x -P -n default" 40 | end 41 | end 42 | end 43 | end 44 | -------------------------------------------------------------------------------- /test/test_base_image_sample_apps.rb: -------------------------------------------------------------------------------- 1 | # Copyright 2017 Google Inc. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | require_relative "helper" 16 | 17 | # Tests of a bunch of sample apps. Treats every subdirectory of the test 18 | # directory that contains a Dockerfile as a sample app. Builds the docker 19 | # image, runs the server, and hits the root of the server, expecting the 20 | # string "Hello World!" to be returned. 21 | # 22 | # This is supposed to exercise the base image extended in various ways, so 23 | # the sample app Dockerfiles should all inherit FROM the base image, which 24 | # will be called "ruby-base". 25 | 26 | class TestBaseImageSampleApps < ::Minitest::Test 27 | include Helper 28 | 29 | TEST_DIR = ::File.dirname __FILE__ 30 | APPS_DIR = ::File.join TEST_DIR, "sample_apps" 31 | TMP_DIR = ::File.join TEST_DIR, "tmp" 32 | 33 | 34 | unless ::ENV["FASTER_TESTS"] 35 | 36 | def test_rack_app 37 | run_app_test "rack_app", <<~DOCKERFILE 38 | FROM ruby-base 39 | COPY . /app/ 40 | RUN bundle install && rbenv rehash 41 | ENTRYPOINT bundle exec rackup -p 8080 -E production config.ru 42 | DOCKERFILE 43 | end 44 | 45 | end 46 | 47 | def test_rails5_app 48 | run_app_test "rails5_app", <<~DOCKERFILE 49 | FROM ruby-base 50 | COPY . /app/ 51 | RUN bundle install && rbenv rehash 52 | ENV SECRET_KEY_BASE=a12345 53 | ENTRYPOINT bundle exec bin/rails server -p 8080 54 | DOCKERFILE 55 | end 56 | 57 | def test_sinatra1_app 58 | run_app_test "sinatra1_app", <<~DOCKERFILE 59 | FROM ruby-base 60 | COPY . /app/ 61 | RUN bundle install && rbenv rehash 62 | ENV GOOGLE_CLOUD_PROJECT="" 63 | ENTRYPOINT bundle exec ruby myapp.rb -p 8080 64 | DOCKERFILE 65 | end 66 | 67 | 68 | def run_app_test app_name, dockerfile 69 | puts "**** Testing app for base image: #{app_name}" 70 | 71 | app_dir = ::File.join APPS_DIR, app_name 72 | assert_cmd_succeeds "rm -rf #{TMP_DIR}" 73 | assert_cmd_succeeds "cp -r #{app_dir} #{TMP_DIR}" 74 | dockerfile_path = ::File.join TMP_DIR, "Dockerfile" 75 | ::File.open dockerfile_path, "w" do |file| 76 | file.write dockerfile 77 | end 78 | 79 | ::Dir.chdir TMP_DIR do |dir| 80 | build_docker_image "", app_name do |image| 81 | run_docker_daemon "-p 8080:8080 #{image}" do |container| 82 | assert_cmd_output \ 83 | "docker exec #{container} curl -s -S http://127.0.0.1:8080", 84 | "Hello World!", 10 85 | end 86 | end 87 | end 88 | end 89 | 90 | end 91 | -------------------------------------------------------------------------------- /test/test_base_image_structure.rb: -------------------------------------------------------------------------------- 1 | # Copyright 2017 Google Inc. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | require_relative "helper" 16 | require "json" 17 | 18 | # Runs structure tests defined in test_base_image.json locally. 19 | 20 | class TestBaseImageStructure < ::Minitest::Test 21 | include Helper 22 | 23 | BASE_DIR = ::File.dirname ::File.dirname __FILE__ 24 | CONFIG_FILE = ::File.join BASE_DIR, "ruby-base/structure-test.json" 25 | CONFIG_DATA = ::JSON.load ::IO.read CONFIG_FILE 26 | 27 | CONFIG_DATA["commandTests"].each do |test_config| 28 | define_method test_config["name"] do 29 | command_array = test_config["command"] 30 | binary = command_array.shift 31 | command = command_array.map{ |a| "'#{a}'" }.join(" ") 32 | expectations = test_config["expectedOutput"].map { |e| ::Regexp.new e } 33 | assert_docker_output \ 34 | "--entrypoint=#{binary} ruby-base #{command}", 35 | expectations 36 | end 37 | end 38 | 39 | end 40 | -------------------------------------------------------------------------------- /test/test_base_ruby_versions.rb: -------------------------------------------------------------------------------- 1 | # Copyright 2017 Google Inc. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | require_relative "helper" 16 | 17 | # Tests of the supported ruby versions. Ensures that all supported ruby 18 | # versions can be installed and will execute. 19 | 20 | class TestRubyVersions < ::Minitest::Test 21 | PREBUILT_RUBY_VERSIONS = ::ENV["PREBUILT_RUBY_VERSIONS"].to_s.split(",") 22 | PRIMARY_RUBY_VERSIONS = ::ENV["PRIMARY_RUBY_VERSIONS"].to_s.split(",") 23 | PREBUILT_RUBY_IMAGE_BASE = ::ENV["PREBUILT_RUBY_IMAGE_BASE"] 24 | PREBUILT_RUBY_IMAGE_TAG = ::ENV["PREBUILT_RUBY_IMAGE_TAG"] 25 | BUNDLER1_VERSION = ::ENV["BUNDLER1_VERSION"] 26 | BUNDLER2_VERSION = ::ENV["BUNDLER2_VERSION"] 27 | 28 | if ::ENV["FASTER_TESTS"] || ::ENV["USE_LOCAL_PREBUILT"] 29 | VERSIONS = PRIMARY_RUBY_VERSIONS & PREBUILT_RUBY_VERSIONS 30 | else 31 | # Out of the prebuilt list, choose all patches of current versions (i.e. 32 | # whose minor version is reflected in the primaries) but only the latest 33 | # patch of all other versions. Also add 2.0.0-p648 to test patchlevel 34 | # notation and installation from source. 35 | VERSIONS = PREBUILT_RUBY_VERSIONS.map do |version| 36 | if version =~ /^(\d+\.\d+)/ 37 | minor = Regexp.last_match[1] 38 | next version if PRIMARY_RUBY_VERSIONS.any? { |v| v.start_with? minor } 39 | PREBUILT_RUBY_VERSIONS.map do |v| 40 | if v.start_with? minor 41 | Gem::Version.new v 42 | end 43 | end.compact.sort.last.to_s 44 | end 45 | end.compact.uniq + ["2.0.0-p648"] 46 | end 47 | 48 | DOCKERFILE_SELFBUILT = <<~DOCKERFILE_CONTENT 49 | FROM $OS_IMAGE 50 | ARG ruby_version 51 | COPY --from=ruby-build-tools /opt/gems/ /opt/gems/ 52 | RUN rbenv install -s ${ruby_version} \ 53 | && rbenv global ${ruby_version} \ 54 | && rbenv rehash \ 55 | && (gem install /opt/gems/bundler-#{BUNDLER1_VERSION}.gem ; \ 56 | gem install /opt/gems/bundler-#{BUNDLER2_VERSION}.gem ; \ 57 | rbenv rehash) 58 | CMD ruby --version 59 | DOCKERFILE_CONTENT 60 | 61 | DOCKERFILE_PREBUILT = <<~DOCKERFILE_CONTENT 62 | FROM ruby-#{Helper.os_name} 63 | ARG ruby_version 64 | COPY --from=ruby-build-tools /opt/gems/ /opt/gems/ 65 | COPY --from=$PREBUILT_RUBY_IMAGE \ 66 | /opt/rbenv/versions/${ruby_version} \ 67 | /opt/rbenv/versions/${ruby_version} 68 | RUN rbenv global ${ruby_version} \ 69 | && rbenv rehash \ 70 | && (gem install /opt/gems/bundler-#{BUNDLER1_VERSION}.gem ; \ 71 | gem install /opt/gems/bundler-#{BUNDLER2_VERSION}.gem ; \ 72 | rbenv rehash) 73 | CMD ruby --version 74 | DOCKERFILE_CONTENT 75 | 76 | include Helper 77 | 78 | TMP_DIR = ::File.join __dir__, "tmp" 79 | 80 | VERSIONS.each do |version| 81 | mangled_version = version.gsub(".", "_").gsub("-", "_") 82 | mangled_version = "default_version" if mangled_version == "" 83 | define_method("test_#{mangled_version}") do 84 | run_version_test(version, mangled_version) 85 | end 86 | end 87 | 88 | 89 | def run_version_test(version, mangled_version) 90 | puts("**** Testing ruby version: #{version}") 91 | version_output = version.gsub("-", "").gsub(".", "\\.") 92 | assert_cmd_succeeds "rm -rf #{TMP_DIR}" 93 | assert_cmd_succeeds "mkdir -p #{TMP_DIR}" 94 | dockerfile_path = ::File.join TMP_DIR, "Dockerfile" 95 | ::File.open dockerfile_path, "w" do |file| 96 | if PREBUILT_RUBY_VERSIONS.include? version 97 | prebuilt_image = "#{PREBUILT_RUBY_IMAGE_BASE}#{version}:#{PREBUILT_RUBY_IMAGE_TAG}" 98 | file.write DOCKERFILE_PREBUILT.sub("$PREBUILT_RUBY_IMAGE", prebuilt_image) 99 | else 100 | os_image = "ruby-#{Helper.os_name}" 101 | os_image = "#{os_image}-ssl10" if version < "2.4" 102 | file.write DOCKERFILE_SELFBUILT.sub("$OS_IMAGE", os_image) 103 | end 104 | end 105 | ::Dir.chdir TMP_DIR do |dir| 106 | build_docker_image( 107 | "--build-arg ruby_version=#{version}", 108 | mangled_version) do |image| 109 | assert_docker_output(image, /ruby\s#{version_output}/, "ruby-#{mangled_version}") 110 | assert_docker_output("#{image} bundle version", /Bundler version/, "bundler-#{mangled_version}") 111 | end 112 | end 113 | end 114 | 115 | end 116 | -------------------------------------------------------------------------------- /test/test_build_tools.rb: -------------------------------------------------------------------------------- 1 | # Copyright 2017 Google Inc. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | require_relative "helper" 16 | 17 | class TestBuildTools < ::Minitest::Test 18 | include Helper 19 | 20 | TEST_DIR = ::File.dirname __FILE__ 21 | TMP_DIR = ::File.join TEST_DIR, "tmp" 22 | 23 | DOCKERFILE = <<~DOCKERFILE_CONTENT 24 | FROM ruby-base 25 | COPY --from=ruby-build-tools /opt/ /opt/ 26 | ENV PATH /opt/bin:/opt/google-cloud-sdk/bin:/opt/nodejs/bin:/opt/yarn/bin:${PATH} 27 | DOCKERFILE_CONTENT 28 | 29 | def test_build_tools 30 | assert_cmd_succeeds "rm -rf #{TMP_DIR}" 31 | assert_cmd_succeeds "mkdir -p #{TMP_DIR}" 32 | dockerfile_path = ::File.join TMP_DIR, "Dockerfile" 33 | ::File.open dockerfile_path, "w" do |file| 34 | file.write DOCKERFILE 35 | end 36 | ::Dir.chdir TMP_DIR do 37 | build_docker_image "--no-cache" do |image| 38 | assert_docker_output "#{image} /opt/nodejs/bin/node --version", 39 | /^v\d+\.\d+/ 40 | assert_docker_output "#{image} /opt/yarn/bin/yarn --version", 41 | /^\d+\.\d+/ 42 | assert_docker_output "#{image} /opt/bin/cloud_sql_proxy --version", 43 | /Cloud SQL (?:Proxy|Auth proxy)/ 44 | assert_docker_output \ 45 | "#{image} /opt/google-cloud-sdk/bin/gcloud --version", 46 | /Google Cloud SDK/ 47 | assert_docker_output \ 48 | "#{image} /opt/bin/access_cloud_sql --lenient && echo OK", 49 | /OK/ 50 | end 51 | end 52 | end 53 | 54 | end 55 | -------------------------------------------------------------------------------- /test/test_sample_app_builds.rb: -------------------------------------------------------------------------------- 1 | # Copyright 2016 Google Inc. All rights reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | require_relative "helper" 16 | require "fileutils" 17 | 18 | class TestSampleAppBuilds < ::Minitest::Test 19 | include Helper 20 | 21 | CASES_DIR = ::File.join __dir__, "builder_cases" 22 | APPS_DIR = ::File.join __dir__, "sample_apps" 23 | TMP_DIR = ::File.join __dir__, "tmp" 24 | 25 | unless ::ENV["FASTER_TESTS"] 26 | 27 | def test_rack_app 28 | run_app_test "rack_app" do |image| 29 | assert_docker_output "#{image} test ! -d /app/public/assets", nil 30 | end 31 | end 32 | 33 | end 34 | 35 | def test_sinatra1_app 36 | run_app_test "sinatra1_app" do |image| 37 | assert_docker_output "#{image} test ! -d /app/public/assets", nil 38 | end 39 | end 40 | 41 | def test_rails5_app 42 | run_app_test "rails5_app" do |image| 43 | assert_docker_output "#{image} test -d /app/public/assets", nil 44 | end 45 | end 46 | 47 | def run_app_test app_name 48 | puts "**** Testing app: #{app_name}" 49 | 50 | app_dir = ::File.join APPS_DIR, app_name 51 | case_dir = ::File.join CASES_DIR, app_name 52 | ::FileUtils.rm_rf TMP_DIR 53 | ::FileUtils.cp_r app_dir, TMP_DIR 54 | ::Dir.glob "#{case_dir}/*", ::File::FNM_DOTMATCH do |path| 55 | ::FileUtils.cp_r path, TMP_DIR unless ::File.basename(path) =~ /^\.\.?$/ 56 | end 57 | 58 | assert_docker_output \ 59 | "-v #{TMP_DIR}:/workspace -w /workspace ruby-generate-dockerfile" \ 60 | " -t --base-image=ruby-#{Helper.os_name} --build-tools-image=ruby-build-tools", 61 | nil 62 | ::Dir.chdir TMP_DIR do 63 | build_docker_image "--no-cache" do |image| 64 | yield image 65 | run_docker_daemon "-p 8080:8080 #{image}" do |container| 66 | assert_cmd_output( 67 | "docker exec #{container} curl -s -S http://127.0.0.1:8080", 68 | "Hello World!", 10) do 69 | puts "**** server logs" 70 | execute_cmd("docker logs #{container}") 71 | end 72 | end 73 | end 74 | end 75 | end 76 | end 77 | -------------------------------------------------------------------------------- /test/test_ubuntu_image_structure.rb: -------------------------------------------------------------------------------- 1 | # Copyright 2017 Google Inc. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | require_relative "helper" 16 | require "json" 17 | 18 | # Runs structure tests defined in test_base_image.json locally. 19 | 20 | class TestUbuntuImageStructure < ::Minitest::Test 21 | include Helper 22 | 23 | BASE_DIR = ::File.dirname ::File.dirname __FILE__ 24 | CONFIG_FILE = ::File.join BASE_DIR, "ruby-#{Helper.os_name}/structure-test.json" 25 | CONFIG_DATA = ::JSON.load ::IO.read CONFIG_FILE 26 | 27 | CONFIG_DATA["commandTests"].each do |test_config| 28 | define_method test_config["name"] do 29 | command_array = test_config["command"] 30 | binary = command_array.shift 31 | command = command_array.map{ |a| "'#{a}'" }.join(" ") 32 | expectations = test_config["expectedOutput"].map { |e| ::Regexp.new e } 33 | assert_docker_output \ 34 | "--entrypoint=#{binary} ruby-#{Helper.os_name} #{command}", 35 | expectations 36 | end 37 | end 38 | 39 | end 40 | -------------------------------------------------------------------------------- /tools/ci-scripts/binary-build.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | export KOKORO_GITHUB_DIR=${KOKORO_ROOT}/src/github 3 | source ${KOKORO_GFILE_DIR}/kokoro/common.sh 4 | 5 | 6 | if [ -z "${TAG}" ]; then 7 | TAG=`date +%Y-%m-%d-%H%M%S` 8 | fi 9 | 10 | STAGING_FLAG= 11 | if [ "${UPLOAD_TO_STAGING}" = "true" ]; then 12 | STAGING_FLAG="-s" 13 | fi 14 | 15 | 16 | if [ -z "$RUBY_VERSIONS" ]; then 17 | echo "**** No Ruby versions specified." 18 | echo "**** You must set the RUBY_VERSIONS environment variable to a colon-delimited list." 19 | exit 1 20 | fi 21 | 22 | RUBY_VERSIONS=$( echo "$RUBY_VERSIONS" | tr : , ) 23 | 24 | cd ${KOKORO_GITHUB_DIR}/ruby-docker 25 | ./build-ruby-binary-images.sh -p $BUILDER_PROJECT -t $TAG $STAGING_FLAG -c $RUBY_VERSIONS -y 26 | -------------------------------------------------------------------------------- /tools/ci-scripts/deploy_check.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -ex 4 | 5 | export KOKORO_GITHUB_DIR=${KOKORO_ROOT}/src/github 6 | source ${KOKORO_GFILE_DIR}/kokoro/common.sh 7 | 8 | cd ${KOKORO_GITHUB_DIR}/${SAMPLE_APP_DIRECTORY} 9 | if [ -n "${RUNTIME_SPEC}" -a -f app.yaml.in ]; then 10 | sed "s|\${RUNTIME_SPEC}|${RUNTIME_SPEC}|" app.yaml.in > app.yaml 11 | fi 12 | 13 | cd ${KOKORO_GFILE_DIR}/appengine/integration_tests 14 | 15 | sudo /usr/local/bin/pip install --trusted-host pypi.org --trusted-host files.pythonhosted.org --upgrade -r requirements.txt 16 | 17 | if [ -f ${KOKORO_GITHUB_DIR}/${SAMPLE_APP_DIRECTORY}/requirements.txt ] 18 | then 19 | sudo /usr/local/bin/pip install --trusted-host pypi.org --trusted-host files.pythonhosted.org --upgrade -r ${KOKORO_GITHUB_DIR}/${SAMPLE_APP_DIRECTORY}/requirements.txt 20 | fi 21 | 22 | export DEPLOY_LATENCY_PROJECT='cloud-deploy-latency' 23 | 24 | skip_flag="" 25 | 26 | if [ "${SKIP_CUSTOM_LOGGING_TESTS}" = "true" -o "${SKIP_BUILDERS}" = "true" ]; then 27 | skip_flag="$skip_flag --skip-builders" 28 | fi 29 | 30 | if [ "${SKIP_XRT}" = "true" ]; then 31 | skip_flag="$skip_flag --skip-xrt" 32 | fi 33 | 34 | python deploy_check.py -d ${KOKORO_GITHUB_DIR}/${SAMPLE_APP_DIRECTORY} -l ${LANGUAGE} ${skip_flag} 35 | -------------------------------------------------------------------------------- /tools/ci-scripts/integration-test.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -ex 4 | 5 | export KOKORO_GITHUB_DIR=${KOKORO_ROOT}/src/github 6 | source ${KOKORO_GFILE_DIR}/kokoro/common.sh 7 | 8 | export GOOGLE_CLOUD_PROJECT=gcp-runtimes 9 | 10 | sudo /usr/local/bin/pip install --trusted-host pypi.org --trusted-host files.pythonhosted.org --upgrade -r ${KOKORO_GFILE_DIR}/appengine/integration_tests/requirements.txt 11 | 12 | if [ -f ${KOKORO_GITHUB_DIR}/${SAMPLE_APP_DIRECTORY}/requirements.txt ] 13 | then 14 | sudo /usr/local/bin/pip install --trusted-host pypi.org --trusted-host files.pythonhosted.org --upgrade -r ${KOKORO_GITHUB_DIR}/${SAMPLE_APP_DIRECTORY}/requirements.txt 15 | fi 16 | 17 | export GOPATH=${KOKORO_GITHUB_DIR}/${SAMPLE_APP_DIRECTORY} 18 | 19 | flags="" 20 | 21 | if [ -n "${STAGING_IMAGE}" ]; then 22 | flags="$flags -i ${STAGING_IMAGE}" 23 | fi 24 | 25 | if [ "${SKIP_STANDARD_LOGGING_TESTS}" = "true" ]; then 26 | flags="$flags --skip-standard-logging-tests" 27 | fi 28 | 29 | if [ "${SKIP_CUSTOM_LOGGING_TESTS}" = "true" ]; then 30 | flags="$flags --skip-custom-logging-tests" 31 | fi 32 | 33 | if [ "${SKIP_MONITORING_TESTS}" = "true" ]; then 34 | flags="$flags --skip-monitoring-tests" 35 | fi 36 | 37 | if [ "${SKIP_EXCEPTION_TESTS}" = "true" ]; then 38 | flags="$flags --skip-exception-tests" 39 | fi 40 | 41 | if [ "${SKIP_CUSTOM_TESTS}" = "true" ]; then 42 | flags="$flags --skip-custom-tests" 43 | fi 44 | 45 | if [ -n "${URL}" ]; then 46 | flags="$flags --url ${URL}" 47 | fi 48 | 49 | if [ -n "${BUILDER}" ]; then 50 | flags="$flags --builder ${BUILDER}" 51 | gcloud config set app/use_runtime_builders True 52 | gcloud config set app/runtime_builders_root file://${KOKORO_GITHUB_DIR}/${SAMPLE_APP_DIRECTORY} 53 | fi 54 | 55 | if [ -n "${YAML}" ]; then 56 | flags="$flags --yaml ${KOKORO_GITHUB_DIR}/${YAML}" 57 | fi 58 | 59 | 60 | chmod a+x ${KOKORO_GFILE_DIR}/appengine/integration_tests/testsuite/driver.py 61 | ${KOKORO_GFILE_DIR}/appengine/integration_tests/testsuite/driver.py -d ${KOKORO_GITHUB_DIR}/${SAMPLE_APP_DIRECTORY} ${flags} 62 | -------------------------------------------------------------------------------- /tools/ci-scripts/release.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | export KOKORO_GITHUB_DIR=${KOKORO_ROOT}/src/github 3 | source ${KOKORO_GFILE_DIR}/kokoro/common.sh 4 | 5 | RUNTIME_NAME="ruby" 6 | 7 | if [ -z "${TAG}" ]; then 8 | TAG=`date +%Y-%m-%d-%H%M%S` 9 | fi 10 | 11 | STAGING_FLAG= 12 | if [ "${UPLOAD_TO_STAGING}" = "true" ]; then 13 | STAGING_FLAG="-s" 14 | fi 15 | 16 | 17 | cd ${KOKORO_GITHUB_DIR}/ruby-docker 18 | ./build-ruby-runtime-images.sh -i -p $BUILDER_PROJECT -t $TAG $STAGING_FLAG -y 19 | 20 | METADATA=${KOKORO_GITHUB_DIR}/ruby_docker/METADATA 21 | cd ${KOKORO_GFILE_DIR}/kokoro 22 | python note.py ruby -m ${METADATA} -t ${TAG} 23 | --------------------------------------------------------------------------------