Skip to content

Commit 51219ad

Browse files
committed
Bump buildpack author guide to ruby 3
Use the latest Heroku provided ruby, which includes bundle. This simplifies some of the code and explanation. Signed-off-by: Aidan Delaney <[email protected]>
1 parent ba5030d commit 51219ad

16 files changed

+1090
-146
lines changed

content/docs/buildpack-author-guide/create-buildpack/adding-bill-of-materials.md

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ First, annotate the `buildpack.toml` to specify that it emits CycloneDX:
4545
<!-- test:file=ruby-buildpack/buildpack.toml -->
4646
```toml
4747
# Buildpack API version
48-
api = "0.7"
48+
api = "0.8"
4949

5050
# Buildpack ID and metadata
5151
[buildpack]
@@ -141,11 +141,7 @@ echo -e '[types]\nlaunch = true' > "$layersdir/ruby.toml"
141141
export PATH="$rubylayer"/bin:$PATH
142142
export LD_LIBRARY_PATH=${LD_LIBRARY_PATH:+${LD_LIBRARY_PATH}:}"$rubylayer/lib"
143143

144-
# 6. INSTALL BUNDLER
145-
echo "---> Installing bundler"
146-
gem install bundler --no-ri --no-rdoc
147-
148-
# 7. INSTALL GEMS
144+
# 6. INSTALL GEMS
149145
# Compares previous Gemfile.lock checksum to the current Gemfile.lock
150146
bundlerlayer="$layersdir/bundler"
151147
local_bundler_checksum=$((sha256sum Gemfile.lock || echo 'DOES_NOT_EXIST') | cut -d ' ' -f 1)
@@ -170,7 +166,7 @@ EOL
170166
171167
fi
172168
173-
# 8. SET DEFAULT START COMMAND
169+
# 7. SET DEFAULT START COMMAND
174170
cat > "$layersdir/launch.toml" << EOL
175171
# our web process
176172
[[processes]]
@@ -185,7 +181,7 @@ command = "bundle exec ruby worker.rb"
185181
EOL
186182
187183
# ========== ADDED ===========
188-
# 9. ADD A SBOM
184+
# 8. ADD A SBOM
189185
rubybom="${layersdir}/ruby.sbom.cdx.json"
190186
cat >> ${rubybom} << EOL
191187
{
@@ -249,7 +245,7 @@ You should find that the included `ruby` version is `2.5.0` as expected.
249245
{
250246
"type": "library",
251247
"name": "ruby",
252-
"version": "2.5.0"
248+
"version": "3.1.0"
253249
},
254250
...
255251
]

content/docs/buildpack-author-guide/create-buildpack/build-app.md

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ Next, we'll download the Ruby runtime and install it into the layer directory. A
4040
<!-- file=ruby-buildpack/bin/build data-target=append -->
4141
```bash
4242
echo "---> Downloading and extracting Ruby"
43-
ruby_url=https://s3-external-1.amazonaws.com/heroku-buildpack-ruby/heroku-18/ruby-2.5.1.tgz
43+
ruby_url=https://s3-external-1.amazonaws.com/heroku-buildpack-ruby/heroku-18/ruby-3.1.3.tgz
4444
wget -q -O - "$ruby_url" | tar -xzf - -C "$rubylayer"
4545
```
4646

@@ -67,9 +67,6 @@ Now we can install Bundler, a dependency manager for Ruby, and run the `bundle i
6767

6868
<!-- file=ruby-buildpack/bin/build data-target=append -->
6969
```bash
70-
echo "---> Installing bundler"
71-
gem install bundler --no-ri --no-rdoc
72-
7370
echo "---> Installing gems"
7471
bundle install
7572
```
@@ -97,7 +94,7 @@ mkdir -p "$rubylayer"
9794

9895
# 3. DOWNLOAD RUBY
9996
echo "---> Downloading and extracting Ruby"
100-
ruby_url=https://s3-external-1.amazonaws.com/heroku-buildpack-ruby/heroku-18/ruby-2.5.1.tgz
97+
ruby_url=https://s3-external-1.amazonaws.com/heroku-buildpack-ruby/heroku-18/ruby-3.1.3.tgz
10198
wget -q -O - "$ruby_url" | tar -xzf - -C "$rubylayer"
10299

103100
# 4. MAKE RUBY AVAILABLE DURING LAUNCH
@@ -107,11 +104,7 @@ echo -e '[types]\nlaunch = true' > "$layersdir/ruby.toml"
107104
export PATH="$rubylayer"/bin:$PATH
108105
export LD_LIBRARY_PATH=${LD_LIBRARY_PATH:+${LD_LIBRARY_PATH}:}"$rubylayer/lib"
109106

110-
# 6. INSTALL BUNDLER
111-
echo "---> Installing bundler"
112-
gem install bundler --no-ri --no-rdoc
113-
114-
# 7. INSTALL GEMS
107+
# 6. INSTALL GEMS
115108
echo "---> Installing gems"
116109
bundle install
117110
```
@@ -133,8 +126,6 @@ You will see the following output:
133126
===> BUILDING
134127
---> Ruby Buildpack
135128
---> Downloading and extracting Ruby
136-
---> Installing bundler
137-
...
138129
---> Installing gems
139130
...
140131
===> EXPORTING

content/docs/buildpack-author-guide/create-buildpack/building-blocks-cnb.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ Example:
1717
<!-- test:exec -->
1818
```bash
1919
pack buildpack new examples/ruby \
20-
--api 0.7 \
20+
--api 0.8 \
2121
--path ruby-buildpack \
2222
--version 0.0.1 \
2323
--stacks io.buildpacks.samples.stacks.bionic
@@ -41,7 +41,7 @@ You will have `ruby-buildpack/buildpack.toml`<!--+"{{open}}"+--> in your buildpa
4141
<!-- test:file=ruby-buildpack/buildpack.toml -->
4242
```toml
4343
# Buildpack API version
44-
api = "0.7"
44+
api = "0.8"
4545

4646
# Buildpack ID and metadata
4747
[buildpack]

content/docs/buildpack-author-guide/create-buildpack/caching.md

Lines changed: 6 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ mkdir -p "$rubylayer"
4545

4646
# 3. DOWNLOAD RUBY
4747
echo "---> Downloading and extracting Ruby"
48-
ruby_url=https://s3-external-1.amazonaws.com/heroku-buildpack-ruby/heroku-18/ruby-2.5.1.tgz
48+
ruby_url=https://s3-external-1.amazonaws.com/heroku-buildpack-ruby/heroku-18/ruby-3.1.3.tgz
4949
wget -q -O - "$ruby_url" | tar -xzf - -C "$rubylayer"
5050

5151
# 4. MAKE RUBY AVAILABLE DURING LAUNCH
@@ -55,19 +55,15 @@ echo -e '[types]\nlaunch = true' > "$layersdir/ruby.toml"
5555
export PATH="$rubylayer"/bin:$PATH
5656
export LD_LIBRARY_PATH=${LD_LIBRARY_PATH:+${LD_LIBRARY_PATH}:}"$rubylayer/lib"
5757

58-
# 6. INSTALL BUNDLER
59-
echo "---> Installing bundler"
60-
gem install bundler --no-ri --no-rdoc
61-
6258
# ======= MODIFIED =======
63-
# 7. INSTALL GEMS
59+
# 6. INSTALL GEMS
6460
echo "---> Installing gems"
6561
bundlerlayer="$layersdir/bundler"
6662
mkdir -p "$bundlerlayer"
6763
echo -e '[types]\ncache = true\nlaunch = true' > "$layersdir/bundler.toml"
6864
bundle config set --local path "$bundlerlayer" && bundle install && bundle binstubs --all --path "$bundlerlayer/bin"
6965

70-
# 8. SET DEFAULT START COMMAND
66+
# 7. SET DEFAULT START COMMAND
7167
cat > "$layersdir/launch.toml" << EOL
7268
# our web process
7369
[[processes]]
@@ -196,7 +192,7 @@ mkdir -p "$rubylayer"
196192
197193
# 3. DOWNLOAD RUBY
198194
echo "---> Downloading and extracting Ruby"
199-
ruby_url=https://s3-external-1.amazonaws.com/heroku-buildpack-ruby/heroku-18/ruby-2.5.1.tgz
195+
ruby_url=https://s3-external-1.amazonaws.com/heroku-buildpack-ruby/heroku-18/ruby-3.1.3.tgz
200196
wget -q -O - "$ruby_url" | tar -xzf - -C "$rubylayer"
201197
202198
# 4. MAKE RUBY AVAILABLE DURING LAUNCH
@@ -206,12 +202,8 @@ echo -e '[types]\nlaunch = true' > "$layersdir/ruby.toml"
206202
export PATH="$rubylayer"/bin:$PATH
207203
export LD_LIBRARY_PATH=${LD_LIBRARY_PATH:+${LD_LIBRARY_PATH}:}"$rubylayer/lib"
208204
209-
# 6. INSTALL BUNDLER
210-
echo "---> Installing bundler"
211-
gem install bundler --no-ri --no-rdoc
212-
213205
# ======= MODIFIED =======
214-
# 7. INSTALL GEMS
206+
# 6. INSTALL GEMS
215207
# Compares previous Gemfile.lock checksum to the current Gemfile.lock
216208
bundlerlayer="$layersdir/bundler"
217209
local_bundler_checksum=$((sha256sum Gemfile.lock || echo 'DOES_NOT_EXIST') | cut -d ' ' -f 1)
@@ -236,7 +228,7 @@ EOL
236228
237229
fi
238230
239-
# 8. SET DEFAULT START COMMAND
231+
# 7. SET DEFAULT START COMMAND
240232
cat > "$layersdir/launch.toml" << EOL
241233
# our web process
242234
[[processes]]
@@ -266,8 +258,6 @@ it will download the gems:
266258
===> BUILDING
267259
---> Ruby Buildpack
268260
---> Downloading and extracting Ruby
269-
---> Installing bundler
270-
...
271261
---> Installing gems
272262
```
273263
@@ -286,8 +276,6 @@ you will see the new caching logic at work during the `BUILDING` phase:
286276
===> BUILDING
287277
---> Ruby Buildpack
288278
---> Downloading and extracting Ruby
289-
---> Installing bundler
290-
...
291279
---> Reusing gems
292280
```
293281

content/docs/buildpack-author-guide/create-buildpack/make-app-runnable.md

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ mkdir -p "$rubylayer"
4040

4141
# 3. DOWNLOAD RUBY
4242
echo "---> Downloading and extracting Ruby"
43-
ruby_url=https://s3-external-1.amazonaws.com/heroku-buildpack-ruby/heroku-18/ruby-2.5.1.tgz
43+
ruby_url=https://s3-external-1.amazonaws.com/heroku-buildpack-ruby/heroku-18/ruby-3.1.3.tgz
4444
wget -q -O - "$ruby_url" | tar -xzf - -C "$rubylayer"
4545

4646
# 4. MAKE RUBY AVAILABLE DURING LAUNCH
@@ -50,16 +50,12 @@ echo -e '[types]\nlaunch = true' > "$layersdir/ruby.toml"
5050
export PATH="$rubylayer"/bin:$PATH
5151
export LD_LIBRARY_PATH=${LD_LIBRARY_PATH:+${LD_LIBRARY_PATH}:}"$rubylayer/lib"
5252

53-
# 6. INSTALL BUNDLER
54-
echo "---> Installing bundler"
55-
gem install bundler --no-ri --no-rdoc
56-
57-
# 7. INSTALL GEMS
53+
# 6. INSTALL GEMS
5854
echo "---> Installing gems"
5955
bundle install
6056

6157
# ========== ADDED ===========
62-
# 8. SET DEFAULT START COMMAND
58+
# 7. SET DEFAULT START COMMAND
6359
cat > "$layersdir/launch.toml" << EOL
6460
[[processes]]
6561
type = "web"

content/docs/buildpack-author-guide/create-buildpack/make-buildpack-configurable.md

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ fi
2424

2525
# ======= ADDED =======
2626
plan=$2
27-
version=2.5.1
27+
version=3.1.3
2828

2929
if [[ -f .ruby-version ]]; then
3030
version=$(cat .ruby-version | tr -d '[:space:]')
@@ -69,11 +69,7 @@ echo -e '[types]\nlaunch = true' > "$layersdir/ruby.toml"
6969
export PATH="$rubylayer"/bin:$PATH
7070
export LD_LIBRARY_PATH=${LD_LIBRARY_PATH:+${LD_LIBRARY_PATH}:}"$rubylayer/lib"
7171

72-
# 6. INSTALL BUNDLER
73-
echo "---> Installing bundler"
74-
gem install bundler --no-ri --no-rdoc
75-
76-
# 7. INSTALL GEMS
72+
# 6. INSTALL GEMS
7773
# Compares previous Gemfile.lock checksum to the current Gemfile.lock
7874
bundlerlayer="$layersdir/bundler"
7975
local_bundler_checksum=$((sha256sum Gemfile.lock || echo 'DOES_NOT_EXIST') | cut -d ' ' -f 1)
@@ -98,7 +94,7 @@ EOL
9894
9995
fi
10096
101-
# 8. SET DEFAULT START COMMAND
97+
# 7. SET DEFAULT START COMMAND
10298
cat > "$layersdir/launch.toml" << EOL
10399
# our web process
104100
[[processes]]
@@ -117,7 +113,7 @@ Finally, create a file `ruby-sample-app/.ruby-version` with the following conten
117113
118114
<!-- test:file=ruby-sample-app/.ruby-version -->
119115
```
120-
2.5.0
116+
3.1.0
121117
```
122118
123119
Now when you run:
@@ -134,7 +130,7 @@ You will notice that version of Ruby specified in the app's `.ruby-version` file
134130
```text
135131
===> BUILDING
136132
---> Ruby Buildpack
137-
---> Downloading and extracting Ruby 2.5.0
133+
---> Downloading and extracting Ruby 3.1.0
138134
```
139135
140136
Next, let's see how buildpacks can store information about the dependencies provided in the output app image for introspection.

content/docs/buildpack-author-guide/create-buildpack/specify-multiple-process-types.md

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ mkdir -p "$rubylayer"
5757

5858
# 3. DOWNLOAD RUBY
5959
echo "---> Downloading and extracting Ruby"
60-
ruby_url=https://s3-external-1.amazonaws.com/heroku-buildpack-ruby/heroku-18/ruby-2.5.1.tgz
60+
ruby_url=https://s3-external-1.amazonaws.com/heroku-buildpack-ruby/heroku-18/ruby-3.1.3.tgz
6161
wget -q -O - "$ruby_url" | tar -xzf - -C "$rubylayer"
6262

6363
# 4. MAKE RUBY AVAILABLE DURING LAUNCH
@@ -67,16 +67,12 @@ echo -e '[types]\nlaunch = true' > "$layersdir/ruby.toml"
6767
export PATH="$rubylayer"/bin:$PATH
6868
export LD_LIBRARY_PATH=${LD_LIBRARY_PATH:+${LD_LIBRARY_PATH}:}"$rubylayer/lib"
6969

70-
# 6. INSTALL BUNDLER
71-
echo "---> Installing bundler"
72-
gem install bundler --no-ri --no-rdoc
73-
74-
# 7. INSTALL GEMS
70+
# 6. INSTALL GEMS
7571
echo "---> Installing gems"
7672
bundle install
7773

7874
# ========== MODIFIED ===========
79-
# 8. SET DEFAULT START COMMAND
75+
# 7. SET DEFAULT START COMMAND
8076
cat > "$layersdir/launch.toml" << EOL
8177
# our web process
8278
[[processes]]

katacoda/scenarios/buildpack-author-guide/adding-bill-of-materials.md

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ First, annotate the `buildpack.toml` to specify that it emits CycloneDX:
4141
<!-- test:file=ruby-buildpack/buildpack.toml -->
4242
<pre class="file" data-filename="ruby-buildpack/buildpack.toml" data-target="replace">
4343
# Buildpack API version
44-
api = "0.7"
44+
api = "0.8"
4545

4646
# Buildpack ID and metadata
4747
[buildpack]
@@ -137,11 +137,7 @@ echo -e '[types]\nlaunch = true' > "$layersdir/ruby.toml"
137137
export PATH="$rubylayer"/bin:$PATH
138138
export LD_LIBRARY_PATH=${LD_LIBRARY_PATH:+${LD_LIBRARY_PATH}:}"$rubylayer/lib"
139139

140-
# 6. INSTALL BUNDLER
141-
echo "---> Installing bundler"
142-
gem install bundler --no-ri --no-rdoc
143-
144-
# 7. INSTALL GEMS
140+
# 6. INSTALL GEMS
145141
# Compares previous Gemfile.lock checksum to the current Gemfile.lock
146142
bundlerlayer="$layersdir/bundler"
147143
local_bundler_checksum=$((sha256sum Gemfile.lock || echo 'DOES_NOT_EXIST') | cut -d ' ' -f 1)
@@ -166,7 +162,7 @@ EOL
166162

167163
fi
168164

169-
# 8. SET DEFAULT START COMMAND
165+
# 7. SET DEFAULT START COMMAND
170166
cat > "$layersdir/launch.toml" << EOL
171167
# our web process
172168
[[processes]]
@@ -181,7 +177,7 @@ command = "bundle exec ruby worker.rb"
181177
EOL
182178

183179
# ========== ADDED ===========
184-
# 9. ADD A SBOM
180+
# 8. ADD A SBOM
185181
rubybom="${layersdir}/ruby.sbom.cdx.json"
186182
cat >> ${rubybom} << EOL
187183
{
@@ -243,7 +239,7 @@ You should find that the included `ruby` version is `2.5.0` as expected.
243239
{
244240
"type": "library",
245241
"name": "ruby",
246-
"version": "2.5.0"
242+
"version": "3.1.0"
247243
},
248244
...
249245
]

0 commit comments

Comments
 (0)