Skip to content
This repository was archived by the owner on Apr 19, 2026. It is now read-only.

Commit dc8eab7

Browse files
authored
Fixes for Bundler 2.0 and Rails's ruby-version syntax (#163)
1 parent b2b5acc commit dc8eab7

18 files changed

Lines changed: 114 additions & 60 deletions

Gemfile.lock

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ GEM
66
minitest (>= 4, < 6)
77
minitest-rg (5.2.0)
88
minitest (~> 5.0)
9-
rake (12.3.1)
9+
rake (12.3.2)
1010

1111
PLATFORMS
1212
ruby
@@ -18,4 +18,4 @@ DEPENDENCIES
1818
rake (~> 12.0)
1919

2020
BUNDLED WITH
21-
1.16.5
21+
1.17.3

Rakefile

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,11 @@
1515
::Dir.chdir __dir__
1616

1717
RUNTIME_PROJECT="gcp-runtimes"
18-
BUNDLER_VERSION="1.16.6"
18+
BUNDLER1_VERSION="1.17.3"
19+
BUNDLER2_VERSION="2.0.1"
1920
DEFAULT_RUBY_VERSION="2.3.8"
20-
NODEJS_VERSION="8.12.0"
21-
GCLOUD_VERSION="221.0.0"
21+
NODEJS_VERSION="10.15.1"
22+
GCLOUD_VERSION="232.0.0"
2223
OS_NAME="ubuntu16"
2324

2425
LOCAL_PREBUILT_RUBY_VERSIONS=["2.3.8", "2.4.5", "2.5.3", "2.6.0"]
@@ -45,6 +46,8 @@ end
4546
::ENV["PREBUILT_RUBY_VERSIONS"] = PREBUILT_RUBY_VERSIONS.join(",")
4647
::ENV["PREBUILT_RUBY_IMAGE_BASE"] = PREBUILT_RUBY_IMAGE_BASE
4748
::ENV["PREBUILT_RUBY_IMAGE_TAG"] = PREBUILT_RUBY_IMAGE_TAG
49+
::ENV["BUNDLER1_VERSION"] = BUNDLER1_VERSION
50+
::ENV["BUNDLER2_VERSION"] = BUNDLER2_VERSION
4851

4952
PREBUILT_RUBY_IMAGES = PREBUILT_RUBY_VERSIONS.map do |v|
5053
"#{v}=#{PREBUILT_RUBY_IMAGE_BASE}#{v}:#{PREBUILT_RUBY_IMAGE_TAG}"
@@ -55,7 +58,7 @@ require "rake/testtask"
5558
desc "Build local docker image for ubuntu16 image"
5659
task "build:ubuntu16" do |t, args|
5760
sh "docker build --pull --no-cache -t ruby-ubuntu16" \
58-
" --build-arg bundler_version=#{BUNDLER_VERSION}" \
61+
" --build-arg bundler_version=#{BUNDLER2_VERSION}" \
5962
" --build-arg nodejs_version=#{NODEJS_VERSION}" \
6063
" ruby-ubuntu16"
6164
end
@@ -89,13 +92,17 @@ task "build:base" do |t, args|
8992
" ruby-base/Dockerfile-#{image_type}.in > ruby-base/Dockerfile"
9093
sh "docker build --no-cache -t ruby-base" \
9194
" --build-arg ruby_version=#{DEFAULT_RUBY_VERSION}" \
95+
" --build-arg bundler1_version=#{BUNDLER1_VERSION}" \
96+
" --build-arg bundler2_version=#{BUNDLER2_VERSION}" \
9297
" ruby-base"
9398
end
9499

95100
desc "Build local docker image for build-tools image"
96101
task "build:build-tools" do |t, args|
97102
sh "docker build --no-cache -t ruby-build-tools" \
98103
" --build-arg gcloud_version=#{GCLOUD_VERSION}" \
104+
" --build-arg bundler1_version=#{BUNDLER1_VERSION}" \
105+
" --build-arg bundler2_version=#{BUNDLER2_VERSION}" \
99106
" ruby-build-tools"
100107
end
101108

@@ -106,6 +113,8 @@ task "build:generate-dockerfile" do |t, args|
106113
" --build-arg build_tools_image=ruby-build-tools" \
107114
" --build-arg prebuilt_ruby_images=#{PREBUILT_RUBY_IMAGES}" \
108115
" --build-arg default_ruby_version=#{DEFAULT_RUBY_VERSION}" \
116+
" --build-arg bundler1_version=#{BUNDLER1_VERSION}" \
117+
" --build-arg bundler2_version=#{BUNDLER2_VERSION}" \
109118
" ruby-generate-dockerfile"
110119
end
111120

build-ruby-runtime-images.sh

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,10 @@
2020
# version used by the runtime by default if one is not specified by the app.
2121
BASIC_RUBY_VERSION=2.3.8
2222

23-
DEFAULT_BUNDLER_VERSION=1.16.6
24-
NODEJS_VERSION=8.12.0
25-
GCLOUD_VERSION=221.0.0
23+
BUNDLER1_VERSION=1.17.3
24+
BUNDLER2_VERSION=2.0.1
25+
NODEJS_VERSION=10.15.1
26+
GCLOUD_VERSION=232.0.0
2627

2728

2829
set -e
@@ -134,7 +135,7 @@ echo
134135

135136
gcloud builds submit ${DIRNAME}/ruby-${OS_NAME} \
136137
--config ${DIRNAME}/ruby-${OS_NAME}/cloudbuild.yaml --project ${PROJECT} \
137-
--substitutions _IMAGE=${OS_BASE_IMAGE},_TAG=${IMAGE_TAG},_BUNDLER_VERSION=${DEFAULT_BUNDLER_VERSION},_NODEJS_VERSION=${NODEJS_VERSION}
138+
--substitutions _IMAGE=${OS_BASE_IMAGE},_TAG=${IMAGE_TAG},_BUNDLER_VERSION=${BUNDLER2_VERSION},_NODEJS_VERSION=${NODEJS_VERSION}
138139
echo "**** Built image: ${OS_BASE_IMAGE}:${IMAGE_TAG}"
139140
if [ "${STAGING_FLAG}" = "true" ]; then
140141
gcloud container images add-tag --project ${PROJECT} \
@@ -146,7 +147,7 @@ sed -e "s|@@RUBY_OS_IMAGE@@|ruby-${OS_NAME}|g; s|@@PREBUILT_RUBY_IMAGE@@|${PREBU
146147
< ${DIRNAME}/ruby-base/Dockerfile-${BASE_IMAGE_DOCKERFILE}.in > ${DIRNAME}/ruby-base/Dockerfile
147148
gcloud builds submit ${DIRNAME}/ruby-base \
148149
--config ${DIRNAME}/ruby-base/cloudbuild.yaml --project ${PROJECT} --timeout 20m \
149-
--substitutions _OS_NAME=${OS_NAME},_OS_BASE_IMAGE=${OS_BASE_IMAGE},_IMAGE=${RUBY_BASIC_IMAGE},_TAG=${IMAGE_TAG},_RUBY_VERSION=${BASIC_RUBY_VERSION}
150+
--substitutions _OS_NAME=${OS_NAME},_OS_BASE_IMAGE=${OS_BASE_IMAGE},_IMAGE=${RUBY_BASIC_IMAGE},_TAG=${IMAGE_TAG},_RUBY_VERSION=${BASIC_RUBY_VERSION},_BUNDLER1_VERSION=${BUNDLER1_VERSION},_BUNDLER2_VERSION=${BUNDLER2_VERSION}
150151
echo "**** Built image: ${RUBY_BASIC_IMAGE}:${IMAGE_TAG}"
151152
if [ "${STAGING_FLAG}" = "true" ]; then
152153
gcloud container images add-tag --project ${PROJECT} \
@@ -156,7 +157,7 @@ fi
156157

157158
gcloud builds submit ${DIRNAME}/ruby-build-tools \
158159
--config ${DIRNAME}/ruby-build-tools/cloudbuild.yaml --project ${PROJECT} \
159-
--substitutions _BASE_IMAGE=${RUBY_BASIC_IMAGE},_IMAGE=${BUILD_TOOLS_IMAGE},_TAG=${IMAGE_TAG},_GCLOUD_VERSION=${GCLOUD_VERSION}
160+
--substitutions _BASE_IMAGE=${RUBY_BASIC_IMAGE},_IMAGE=${BUILD_TOOLS_IMAGE},_TAG=${IMAGE_TAG},_GCLOUD_VERSION=${GCLOUD_VERSION},_BUNDLER1_VERSION=${BUNDLER1_VERSION},_BUNDLER2_VERSION=${BUNDLER2_VERSION}
160161
echo "**** Built image: ${BUILD_TOOLS_IMAGE}:${IMAGE_TAG}"
161162
if [ "${STAGING_FLAG}" = "true" ]; then
162163
gcloud container images add-tag --project ${PROJECT} \
@@ -166,7 +167,7 @@ fi
166167

167168
gcloud builds submit ${DIRNAME}/ruby-generate-dockerfile \
168169
--config ${DIRNAME}/ruby-generate-dockerfile/cloudbuild.yaml --project ${PROJECT} \
169-
--substitutions _BASE_IMAGE=${RUBY_BASIC_IMAGE},_IMAGE=${GENERATE_DOCKERFILE_IMAGE},_TAG=${IMAGE_TAG}
170+
--substitutions _BASE_IMAGE=${RUBY_BASIC_IMAGE},_IMAGE=${GENERATE_DOCKERFILE_IMAGE},_TAG=${IMAGE_TAG},_BUNDLER1_VERSION=${BUNDLER1_VERSION},_BUNDLER2_VERSION=${BUNDLER2_VERSION}
170171
echo "**** Built image: ${GENERATE_DOCKERFILE_IMAGE}:${IMAGE_TAG}"
171172
if [ "${STAGING_FLAG}" = "true" ]; then
172173
gcloud container images add-tag --project ${PROJECT} \

release-ruby-binary-images.sh

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -33,17 +33,24 @@ fi
3333
show_usage() {
3434
echo 'Usage: release-ruby-binary-images.sh [flags...]' >&2
3535
echo 'Flags:' >&2
36+
echo ' -c <versions>: comma separated prebuilt ruby versions (defaults to prebuilt-versions.txt)' >&2
3637
echo ' -n <name>: set the runtime name (defaults to `ruby`)' >&2
3738
echo ' -o <osname>: build against the given os base image (defaults to ubuntu16)' >&2
3839
echo ' -p <project>: set the project (defaults to current gcloud config setting)' >&2
39-
echo ' -r <versions>: comma separated prebuilt ruby versions (defaults to prebuilt-versions.txt)' >&2
4040
echo ' -t <tag>: the image tag to release (defaults to `staging`)' >&2
4141
echo ' -y: automatically confirm' >&2
4242
}
4343

4444
OPTIND=1
45-
while getopts ":n:o:p:r:t:yh" opt; do
45+
while getopts ":c:n:o:p:t:yh" opt; do
4646
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+
;;
4754
n)
4855
RUNTIME_NAME=${OPTARG}
4956
;;
@@ -53,13 +60,6 @@ while getopts ":n:o:p:r:t:yh" opt; do
5360
p)
5461
PROJECT=${OPTARG}
5562
;;
56-
r)
57-
if [ "${OPTARG}" = "none" ]; then
58-
PREBUILT_VERSIONS=()
59-
else
60-
IFS=',' read -r -a PREBUILT_VERSIONS <<< "${OPTARG}"
61-
fi
62-
;;
6363
t)
6464
IMAGE_TAG=${OPTARG}
6565
;;

ruby-base/Dockerfile-default.in

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,15 @@
1919
FROM @@RUBY_OS_IMAGE@@
2020

2121
ARG ruby_version
22+
ARG bundler1_version
23+
ARG bundler2_version
2224

2325
ENV DEFAULT_RUBY_VERSION=${ruby_version}
2426

2527
# Install Ruby, set default Ruby version, and install Bundler
2628
RUN rbenv install -s ${ruby_version} \
2729
&& rbenv global ${ruby_version} \
2830
&& rbenv rehash \
29-
&& (bundle version > /dev/null 2>&1 \
30-
|| gem install bundler --version ${DEFAULT_BUNDLER_VERSION}) \
31-
&& rbenv rehash
31+
&& (gem install bundler --version ${bundler1_version} ; \
32+
gem install bundler --version ${bundler2_version} ; \
33+
rbenv rehash)

ruby-base/Dockerfile-prebuilt.in

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919
FROM @@RUBY_OS_IMAGE@@
2020

2121
ARG ruby_version
22+
ARG bundler1_version
23+
ARG bundler2_version
2224

2325
ENV DEFAULT_RUBY_VERSION=${ruby_version}
2426

@@ -30,6 +32,6 @@ COPY --from=@@PREBUILT_RUBY_IMAGE@@ \
3032
# Set default Ruby version and install Bundler
3133
RUN rbenv global ${ruby_version} \
3234
&& rbenv rehash \
33-
&& (bundle version > /dev/null 2>&1 \
34-
|| gem install bundler --version ${DEFAULT_BUNDLER_VERSION}) \
35-
&& rbenv rehash
35+
&& (gem install bundler --version ${bundler1_version} ; \
36+
gem install bundler --version ${bundler2_version} ; \
37+
rbenv rehash)

ruby-base/cloudbuild.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ steps:
66
- name: 'gcr.io/cloud-builders/docker'
77
args: ['build', '-t', '$_IMAGE:$_TAG',
88
'--build-arg', 'ruby_version=$_RUBY_VERSION',
9+
'--build-arg', 'bundler1_version=$_BUNDLER1_VERSION',
10+
'--build-arg', 'bundler2_version=$_BUNDLER2_VERSION',
911
'.']
1012
- name: 'gcr.io/gcp-runtimes/structure_test'
1113
args: ['--image', '$_IMAGE:$_TAG', '-v',

ruby-build-tools/Dockerfile

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ FROM ruby-base AS builder
2020

2121
# Versions
2222
ARG gcloud_version
23+
ARG bundler1_version
24+
ARG bundler2_version
2325

2426
RUN mkdir -p /app/bin
2527

@@ -41,10 +43,13 @@ RUN mkdir /app/google-cloud-sdk \
4143
&& (curl -s https://dl.google.com/dl/cloudsdk/channels/rapid/downloads/google-cloud-sdk-${gcloud_version}-linux-x86_64.tar.gz \
4244
| tar xzf - --directory=/app/google-cloud-sdk --strip-components=1)
4345

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}
4451

4552
# Generate a minimal image with only the tool files themselves. This image
4653
# can be downloaded quickly and the files copied into a build image.
47-
4854
FROM scratch
49-
5055
COPY --from=builder /app/ /opt/

ruby-build-tools/cloudbuild.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ steps:
66
- name: 'gcr.io/cloud-builders/docker'
77
args: ['build', '-t', '$_IMAGE:$_TAG',
88
'--build-arg', 'gcloud_version=$_GCLOUD_VERSION',
9+
'--build-arg', 'bundler1_version=$_BUNDLER1_VERSION',
10+
'--build-arg', 'bundler2_version=$_BUNDLER2_VERSION',
911
'.']
1012

1113
images:

ruby-generate-dockerfile/Dockerfile

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,15 @@ ARG base_image=""
1919
ARG build_tools_image=""
2020
ARG prebuilt_ruby_images=""
2121
ARG default_ruby_version=""
22+
ARG bundler1_version=""
23+
ARG bundler2_version=""
2224

2325
ENV DEFAULT_RUBY_BASE_IMAGE=${base_image} \
2426
DEFAULT_RUBY_BUILD_TOOLS_IMAGE=${build_tools_image} \
2527
DEFAULT_PREBUILT_RUBY_IMAGES=${prebuilt_ruby_images} \
26-
DEFAULT_RUBY_VERSION=${default_ruby_version}
28+
DEFAULT_RUBY_VERSION=${default_ruby_version} \
29+
PROVIDED_BUNDLER1_VERSION=${bundler1_version} \
30+
PROVIDED_BUNDLER2_VERSION=${bundler2_version}
2731

2832
# Install the Dockerfile generation script and template.
2933
COPY app/ /app/

0 commit comments

Comments
 (0)