-
Notifications
You must be signed in to change notification settings - Fork 249
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for google cloud #3821
Changes from 16 commits
2d3d35e
68a6f3c
e50ad2f
2af0232
716e724
f7beb29
e0a4cc9
3494e95
82b4d96
574f22b
2cac03e
3525561
05720ae
9c3d4c9
075473a
6511686
1871831
3c61abc
4190278
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
ruby-3.0.4 | ||
ruby-3.0.5 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,41 +1,66 @@ | ||
FROM ruby:3.0.4 as base | ||
# Use the official Ruby image from Docker Hub | ||
# https://hub.docker.com/_/ruby | ||
|
||
RUN curl -sL https://deb.nodesource.com/setup_16.x | bash - | ||
RUN apt-get update -qq && apt-get install -y build-essential \ | ||
libpq-dev nodejs \ | ||
libqt5webkit5-dev dos2unix \ | ||
gstreamer1.0-plugins-base gstreamer1.0-tools gstreamer1.0-x | ||
# [START cloudrun_rails_base_image] | ||
# Pinning the OS to buster because the nodejs install script is buster-specific. | ||
# Be sure to update the nodejs install command if the base image OS is updated. | ||
FROM ruby:3.0-buster as base | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. are we running 3.0.5 here with this? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes. I think they keep 'buster' up with the 'stable' version of ruby 3.0.x |
||
# [END cloudrun_rails_base_image] | ||
|
||
RUN (curl -sS https://deb.nodesource.com/gpgkey/nodesource.gpg.key | gpg --dearmor | apt-key add -) && \ | ||
echo "deb https://deb.nodesource.com/node_14.x buster main" > /etc/apt/sources.list.d/nodesource.list && \ | ||
apt-get update && apt-get install -y nodejs lsb-release | ||
|
||
RUN (curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add -) && \ | ||
echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list && \ | ||
apt-get update && apt-get install -y yarn | ||
|
||
RUN apt-get update -qq && apt-get install -y dos2unix postgresql-client | ||
|
||
RUN mkdir /WebsiteOne | ||
WORKDIR /WebsiteOne | ||
|
||
COPY Gemfile /WebsiteOne/Gemfile | ||
COPY Gemfile.lock /WebsiteOne/Gemfile.lock | ||
|
||
COPY ./docker-entrypoint.sh / | ||
RUN chmod +x /docker-entrypoint.sh | ||
ENTRYPOINT ["/docker-entrypoint.sh"] | ||
|
||
#OPENSSL_CONF is set to /dev/null since not able to determine how to | ||
#set it "correctly" for now. perhaps replace phantomjs with something else? | ||
ENV BUNDLE_PATH=/bundle \ | ||
BUNDLE_BIN=/bundle/bin \ | ||
GEM_HOME=/bundle | ||
# OPENSSL_CONF=/dev/null | ||
ENV PATH="${BUNDLE_BIN}:${PATH}" | ||
|
||
RUN bundle install | ||
#Production or staging, use middle 2 config lines below when bundling | ||
RUN gem install bundler && \ | ||
# bundle config set --local deployment 'true' && \ | ||
# bundle config set --local without 'development test' && \ | ||
bundle install | ||
|
||
COPY package.json /WebsiteOne/package.json | ||
COPY scripts /WebsiteOne/scripts | ||
COPY vendor/assets/javascripts /WebsiteOne/assets/javascripts | ||
|
||
FROM base | ||
|
||
RUN dos2unix scripts/copy_javascript_dependencies.js | ||
RUN npm install -g yarn | ||
# To execute tests, install chrome below | ||
RUN wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add - \ | ||
&& echo "deb http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google.list | ||
RUN apt-get update && apt-get -y install google-chrome-stable | ||
|
||
RUN dos2unix scripts/copy_javascript_dependencies.js | ||
RUN yarn install | ||
COPY . /WebsiteOne | ||
RUN bundle exec rake assets:precompile | ||
|
||
#Production or staging, take out 'bundle' line above and use the following | ||
# ENV RAILS_ENV=production | ||
# ENV RAILS_SERVE_STATIC_FILES=true | ||
# # Redirect Rails log to STDOUT for Cloud Run to capture | ||
# ENV RAILS_LOG_TO_STDOUT=true | ||
# # [START cloudrun_rails_dockerfile_key] | ||
# ARG MASTER_KEY | ||
# ENV RAILS_MASTER_KEY=${MASTER_KEY} | ||
# # [END cloudrun_rails_dockerfile_key] | ||
|
||
# # pre-compile Rails assets with master key | ||
# RUN bundle exec rake assets:precompile | ||
# EXPOSE 8080 | ||
# CMD ["bin/rails", "server", "-b", "0.0.0.0", "-p", "8080"] | ||
|
||
# Also add lines below to database.yml under 'production:' | ||
# username: av | ||
# password: <%= Rails.application.credentials.gcp[:db_password] %> | ||
# host: /cloudsql/av-wso:us-central1:postgres |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,7 @@ | |
|
||
source 'https://rubygems.org' | ||
|
||
ruby '3.0.4' | ||
ruby '3.0.5' | ||
|
||
# Rather than loading the entire Rails framework, we charry pick the parts we use | ||
gem 'actionmailer', '~> 6.1.7' | ||
|
@@ -36,6 +36,7 @@ gem 'faker' | |
gem 'font-awesome-rails' | ||
gem 'friendly_id' | ||
gem 'geocoder' | ||
gem 'google-cloud-storage' | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. do we need this in this pr? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'll try taking all of the cloud storage stuff out. There's a chance that it's necessary for asset pipeline, but hopefully not. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I took it out. |
||
# gem 'ice_cube', '0.16.3' | ||
gem 'jquery-rails' | ||
gem 'jquery-turbolinks', '2.1.0' | ||
|
@@ -86,6 +87,10 @@ gem 'will_paginate-bootstrap' | |
gem 'youtube_rails' | ||
gem 'rack-timeout' | ||
|
||
group :production do | ||
gem 'mini_racer' # for environment without pre-existing js runtimes | ||
end | ||
|
||
group :test do | ||
gem 'capybara' | ||
gem 'capybara-screenshot' | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
|
||
# [START cloudrun_rails_cloudbuild] | ||
steps: | ||
- id: "build image" | ||
name: "gcr.io/cloud-builders/docker" | ||
entrypoint: 'bash' | ||
args: ["-c", "docker build --build-arg MASTER_KEY=${_RAILS_KEY} -t gcr.io/${PROJECT_ID}/${_SERVICE_NAME} . "] | ||
# secretEnv: ["_RAILS_KEY"] | ||
|
||
- id: "push image" | ||
name: "gcr.io/cloud-builders/docker" | ||
args: ["push", "gcr.io/${PROJECT_ID}/${_SERVICE_NAME}"] | ||
|
||
- id: "apply migrations" | ||
name: "gcr.io/google-appengine/exec-wrapper" | ||
entrypoint: "bash" | ||
args: | ||
[ | ||
"-c", | ||
"/buildstep/execute.sh -i gcr.io/${PROJECT_ID}/${_SERVICE_NAME} -s ${PROJECT_ID}:${_REGION}:${_INSTANCE_NAME} -e RAILS_MASTER_KEY=${_RAILS_KEY} -- bundle exec rails db:migrate" | ||
] | ||
|
||
# Use seed step below only on first deploy if you want sample data | ||
# - id: "seed some display data" | ||
# name: "gcr.io/google-appengine/exec-wrapper" | ||
# entrypoint: "bash" | ||
# args: | ||
# [ | ||
# "-c", | ||
# "/buildstep/execute.sh -i gcr.io/${PROJECT_ID}/${_SERVICE_NAME} -s ${PROJECT_ID}:${_REGION}:${_INSTANCE_NAME} -e RAILS_MASTER_KEY=${_RAILS_KEY} -- bundle exec rake db:seed" | ||
# ] | ||
# secretEnv: ["_RAILS_KEY"] | ||
|
||
substitutions: | ||
_REGION: us-central1 | ||
_SERVICE_NAME: av-wso | ||
_INSTANCE_NAME: postgres | ||
# _SECRET_NAME: rails-master-key | ||
# Do not put the key here for any official site as it will expose secrets and passwords. | ||
# Instead, use the availableSecrets section below and put the key in google cloud secrets. | ||
_RAILS_KEY: 79c9bca5ff743a515be994095fd41a3a | ||
|
||
|
||
# availableSecrets: | ||
# secretManager: | ||
# - versionName: projects/${PROJECT_ID}/secrets/${_SECRET_NAME}/versions/latest | ||
# env: RAILS_KEY | ||
|
||
images: | ||
- "gcr.io/${PROJECT_ID}/${_SERVICE_NAME}" | ||
# [END cloudrun_rails_cloudbuild] |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,7 @@ | |
|
||
require_relative 'boot' | ||
require 'rails' | ||
require "active_storage/engine" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. do we end up needing this? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I took it out. |
||
|
||
%w( | ||
active_record/railtie | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
xxXTi2v2HMRD6dcSX6qpaUByfveL15gulGj/KfDKWfsNwHQXPSObiQqjWgtkWw9gjUhDSK1dJbBR8FA2MtbJJPNSMiSOP7csIFAIvMw/T7dNSQas+ilhGCjYVrnW6sZl4vc+GKKea569HaAuWTuC518pzD8eQI97w9+C0o5P9IpxPXGrLTB3Hm43uEzTxQD35e9mRW0VzSjvDjJCruKx+vbPF2O81Ap3XeWF4oOd2rw9xyPzbbTDVKB8dxApGLvkGtD5jKavS8Ne/+Iny5Miwg81H6wWqAdKrWg9rnZ8k4dkbGg0/7ZU0fFSyM6/UVwr6BbU/TV7U2mTFkLgsB05S4KJgx90pIiAZbTavME9rlPFPI1B5gI2G5JHNWINcuwY7D3WqNNA7Yg2NZMIDeB3qE0w+eSdditHkIfJZI3sPDJz63NVH0EQK135V3iYEaM/sQkz--IwmpHfU6ig9OgiMI--AvQyzBX9AUqeqe6stOPuXA== |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is it necessary to put this re-enabling of vcr in this pr?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
actually looks like I just accidentally removed the last blank line, which doesn't seem to hurt anything