Skip to content

Commit ff52762

Browse files
committed
Try this
1 parent 756a70a commit ff52762

File tree

3 files changed

+32
-0
lines changed

3 files changed

+32
-0
lines changed

lib/cibuildgem/cli.rb

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
require "thor"
44
require "rake/extensiontask"
5+
require_relative "container"
56

67
module Cibuildgem
78
class CLI < Thor
@@ -27,6 +28,9 @@ def exit_on_failure?
2728
to the compilation.
2829
MSG
2930
def compile
31+
32+
# return run_in_container if Gem::Platform.local.os == "linux"
33+
3034
run_rake_tasks!("cibuildgem:setup", :compile)
3135
end
3236

@@ -44,6 +48,8 @@ def compile
4448
MSG
4549
method_option "gemspec", type: "string", required: false, desc: "The gemspec to use. Defaults to the gemspec from the current working directory."
4650
def package
51+
return run_in_container
52+
4753
ENV["RUBY_CC_VERSION"] ||= compilation_task.ruby_cc_version
4854

4955
run_rake_tasks!("cibuildgem:setup", :cross, :native, :gem)
@@ -148,5 +154,9 @@ def compilation_task
148154

149155
Kernel.exit(false)
150156
end
157+
158+
def run_in_container
159+
Container.execute("cibuildgem package", runtime_ruby: RUBY_VERSION)
160+
end
151161
end
152162
end

lib/cibuildgem/container.rb

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# frozen_string_literal: true
2+
3+
require "open3"
4+
5+
module Cibuildgem
6+
module Container
7+
extend self
8+
9+
def execute(command, runtime_ruby:)
10+
dockerfile = File.expand_path("../docker/Dockerfile", __FILE__)
11+
system("podman image build -t cibuildgem -f #{dockerfile}", exception: true)
12+
13+
puts ENV["RUNNER_TEMP"]
14+
# system("podman container run -it -v /Users/edouard/Documents/rubies:/opt/rubies -v /Users/edouard/Documents/config.yml:/root/.rake-compiler/config.yml cibuildgem /bin/bash")
15+
end
16+
17+
def cpu
18+
Gem::Platform.local.cpu
19+
end
20+
end
21+
end

Dockerfile renamed to lib/cibuildgem/docker/Dockerfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,6 @@ RUN cd chruby-0.3.9 && ./scripts/setup.sh
77
RUN mkdir -p /opt/rubies
88
RUN curl -L https://github.com/Shopify/cibuildgem/releases/download/ruby-builder/ruby-3.4.7.zip -O
99
RUN unzip ruby-3.4.7.zip -d /opt/rubies
10+
RUN bash -c "source /usr/local/share/chruby/chruby.sh && chruby 3.4.7 && gem install cibuildgem"
1011
RUN echo "source /usr/local/share/chruby/chruby.sh" >> ~/.bashrc
1112
RUN echo "chruby 3.4.7" >> ~/.bashrc

0 commit comments

Comments
 (0)