Skip to content

Commit 2e20766

Browse files
committed
Dynamically load the possible distributions from the config for docker images
1 parent 1b0b1b3 commit 2e20766

File tree

2 files changed

+19
-10
lines changed

2 files changed

+19
-10
lines changed

doc/contributor/docker.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,14 @@ jt docker test --graalvm graalvm-ee.tar.gz llvm-toolchain-installable.jar:ruby-i
2222
jt docker test --standalone truffleruby-linux-amd64.tar.gz --test release_branch
2323
```
2424

25-
## Distributions
25+
To run tests on a specific distribution:
26+
```bash
27+
DOCKER=podman jt docker build --ubuntu1804 --standalone ~/Downloads/truffleruby-21.2.0-linux-amd64.tar.gz --test release/graal-vm/21.2
28+
```
2629

27-
Pick one of:
30+
## Distributions
2831

29-
* Oracle Linux 7, `--ol7` (default)
30-
* Ubuntu 18.04 `--ubuntu1804`
31-
* Ubuntu 16.04 `--ubuntu1604`
32-
* Fedora 28, `--fedora28`
32+
Pick one of the distributions in [docker-configs.yaml](../../tool/docker-configs.yaml).
3333

3434
## Methods of installing
3535

tool/docker.rb

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
require 'yaml'
2+
13
class JT
24
class Docker
35
include Utilities
@@ -18,6 +20,14 @@ def docker(*args)
1820
end
1921
end
2022

23+
private def docker_config
24+
@config ||= YAML.load_file(File.join(TRUFFLERUBY_DIR, 'tool', 'docker-configs.yaml'))
25+
end
26+
27+
private def docker_distros
28+
docker_config.each_pair.select { |_name, details| details.key?('base') }.map(&:first).map { |distro| "--#{distro}" }
29+
end
30+
2131
private def docker_build(*args)
2232
if args.first.nil? || args.first.start_with?('--')
2333
image_name = 'truffleruby-test'
@@ -30,7 +40,7 @@ def docker(*args)
3040
end
3141

3242
private def docker_test(*args)
33-
distros = ['--ol7', '--ubuntu1804', '--ubuntu1604', '--fedora28']
43+
distros = docker_distros
3444

3545
distros.each do |distro|
3646
puts '**********************************'
@@ -50,8 +60,7 @@ def docker(*args)
5060
end
5161

5262
private def dockerfile(*args)
53-
require 'yaml'
54-
config = @config ||= YAML.load_file(File.join(TRUFFLERUBY_DIR, 'tool', 'docker-configs.yaml'))
63+
config = docker_config
5564

5665
distro = 'ol7'
5766
install_method = nil
@@ -65,7 +74,7 @@ def docker(*args)
6574
until args.empty?
6675
arg = args.shift
6776
case arg
68-
when '--ol7', '--ubuntu1804', '--ubuntu1604', '--fedora28'
77+
when *docker_distros
6978
distro = arg[2..-1]
7079
when '--graalvm'
7180
install_method = :graalvm

0 commit comments

Comments
 (0)