Skip to content

Commit

Permalink
chore: bundle install so we can fetch src
Browse files Browse the repository at this point in the history
  • Loading branch information
YOU54F committed Aug 17, 2023
1 parent 7a71e36 commit aaaf2b2
Show file tree
Hide file tree
Showing 11 changed files with 143 additions and 33 deletions.
2 changes: 1 addition & 1 deletion .cirrus.yml
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ macos_arm_task:
deps_script: |
brew install automake texinfo libtool squashfs bison
get_ruby_source_and_patch_script: |
./patch_ruby_source.sh
bundle install && bundle exec rake patch_ruby_source
build_script: |
bin/rubyc bin/rubyc -o rubyc --openssl-dir=/opt/homebrew/opt/openssl@1.1
test_script: |
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ jobs:
# run: bundle install
# - name: "[Enclose.IO] Rake"
# run: bundle exec rake
- name: "Install bundle"
run: bundle install
- name: "Download and Patch ruby source"
run: bundle exec rake patch_ruby_source
- name: "Build rubyc"
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/macos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ jobs:
# run: bundle exec rake
# - name: "[Enclose.IO] Rake"
# run: bundle exec rake
- name: "Install bundle"
run: bundle install
- name: "Download and Patch ruby source"
run: bundle exec rake patch_ruby_source
# - name: "Unlink openssl" # this is unlinked after downloading the patch as curl needs openssl@3
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ jobs:
# mkdir C:\rubyc_tmp
# bundle exec rake
# shell: cmd
- name: "Install bundle"
run: bundle install
- name: "Download and Patch ruby source"
run: bundle exec rake patch_ruby_source
- name: "Package rubyc"
Expand Down
6 changes: 4 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,10 @@ RUN ruby --version
RUN bundler --version
WORKDIR /app
COPY . .
RUN ./patch_ruby_source.sh
RUN bin/rubyc bin/rubyc -o rubyc
RUN bundle install
RUN bundle exec rake patch_ruby_source
RUN bundle exec rake rubyc
# RUN bin/rubyc bin/rubyc -o rubyc
RUN LD_LIBRARY_PATH=/tmp/rubyc/local/lib:$LD_LIBRARY_PATH ./rubyc --help


Expand Down
86 changes: 86 additions & 0 deletions Dockerfile.pact.alpine
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@

ARG ALPINE_VERSION=3.18
FROM alpine:${ALPINE_VERSION} as stage1
ARG ALPINE_VERSION=3.18
ENV ALPINE_VERSION=$ALPINE_VERSION
ARG RUBY_VERSION=3.2.2
ENV RUBY_VERSION=${RUBY_VERSION}
# open ssl 1.1 from 3.16 and below
# open ssl 3.0 support only added in linux 3.17 onwards https://debugpointnews.com/alpine-linux-3-17/
# open ssl 3.1 from 3.18

# Setup build environment for rubyc
RUN apk add --no-cache \
build-base \
openssl-dev \
readline-dev \
zlib-dev \
yaml-dev \
libffi-dev \
gdbm-dev \
ncurses-dev \
procps \
wget \
tar \
squashfs-tools \
git \
mariadb-dev \
postgresql-dev \
sqlite sqlite-dev sqlite-libs \
autoconf \
xz && \
apk cache clean && \
rm -rf /var/cache/apk/* && \
rm -rf /tmp/* && \
rm -rf /var/log/*

# gcompat && \ # only required for pact broker due to nokogiri

## Install ruby from source
RUN wget https://cache.ruby-lang.org/pub/ruby/$(echo $RUBY_VERSION | cut -d '.' -f 1,2)/ruby-${RUBY_VERSION}.tar.gz && \
tar -xzvf ruby-${RUBY_VERSION}.tar.gz && \
rm -rf ruby-${RUBY_VERSION}.tar.gz && \
cd ruby-${RUBY_VERSION} && \
OPENSSL_DIR=$(pkg-config --variable=prefix openssl) ./configure \
--disable-shared \
--enable-static \
--prefix=/usr/local/ruby-${RUBY_VERSION} \
--with-openssl-dir=$(pkg-config --variable=prefix openssl) && \
make && \
make install
ENV PATH="/usr/local/ruby-${RUBY_VERSION}/bin:$PATH"
RUN ruby -v

WORKDIR /app
COPY ruby-enclose ./ruby-enclose
COPY vendor-enclose ./vendor-enclose
COPY ruby-enclose-${RUBY_VERSION}-patch ./ruby-enclose-${RUBY_VERSION}-patch
COPY bin ./bin
COPY lib ./lib
COPY rakelib ./rakelib
COPY Gemfile .
COPY Rakefile .
COPY test ./test
RUN bundle install
RUN if [ "$(echo $ALPINE_VERSION | cut -d '.' -f 2)" -le "16" ] ; then OPENSSL_VERSION=1.1.1v bundle exec rake patch_ruby_source; fi
RUN if [ "$(echo $ALPINE_VERSION | cut -d '.' -f 2)" -eq "17" ] ; then OPENSSL_VERSION=3.0.10 bundle exec rake patch_ruby_source; fi
RUN if [ "$(echo $ALPINE_VERSION | cut -d '.' -f 2)" -ge "18" ] ; then OPENSSL_VERSION=3.1.2 bundle exec rake patch_ruby_source; fi
# RUN bundle exec rake patch_ruby_source
WORKDIR /app/examples/pact
COPY examples/pact .
RUN bundle lock --add-platform aarch64-linux-musl && \
bundle install
RUN bundle exec pact-mock-service help
RUN ruby pact-cli.rb
RUN /app/bin/rubyc pact-cli.rb -o pact-cli
RUN mv /app/examples/pact/pact-cli /usr/local/bin/pact-cli
ENTRYPOINT [ "pact-cli" ]
CMD [ "--help" ]

FROM alpine:3.18 as stage2

COPY --from=stage1 /usr/local/bin/pact-cli /usr/local/bin/pact-cli
WORKDIR /app
COPY examples/pact .
ENTRYPOINT [ "pact-cli" ]
CMD [ "--help" ]
21 changes: 13 additions & 8 deletions Dockerfile.pact_builder.alpine
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
FROM alpine:3.17 as stage1
FROM alpine:3.18 as stage1
# open ssl 3.0 support only added in linux 3.17 onwards https://debugpointnews.com/alpine-linux-3-17/

ENV OPENSSL_VERSION=3.1.2
ENV RUBY_VERSION=3.2.2
ENV RUBY_MAJOR_MINOR_VERSION=3.2

RUN apk add --no-cache \
build-base \
openssl-dev \
Expand All @@ -18,20 +22,21 @@ RUN apk add --no-cache \
mariadb-dev \
postgresql-dev \
sqlite sqlite-dev sqlite-libs \
xz \
autoconf
# gcompat # only required for pact broker due to nokogiri

RUN wget https://cache.ruby-lang.org/pub/ruby/3.2/ruby-3.2.2.tar.gz && \
tar -xzvf ruby-3.2.2.tar.gz && \
cd ruby-3.2.2 && \
RUN wget https://cache.ruby-lang.org/pub/ruby/${RUBY_MAJOR_VERSION}/ruby-${RUBY_VERSION}.tar.gz && \
tar -xzvf ruby-${RUBY_VERSION}.tar.gz && \
cd ruby-${RUBY_VERSION} && \
OPENSSL_DIR=$(pkg-config --variable=prefix openssl) ./configure \
--disable-shared \
--enable-static \
--prefix=/usr/local/ruby-3.2.2 \
--prefix=/usr/local/ruby-${RUBY_VERSION} \
--with-openssl-dir=$(pkg-config --variable=prefix openssl) && \
make && \
make install
ENV PATH="/usr/local/ruby-3.2.2/bin:$PATH"
ENV PATH="/usr/local/ruby-${RUBY_VERSION}/bin:$PATH"
RUN ruby -v
WORKDIR /rubyc_wrkdir

Expand All @@ -42,7 +47,7 @@ WORKDIR /rubyc_wrkdir

COPY ruby-enclose ./ruby-enclose
COPY vendor-enclose ./vendor-enclose
COPY ruby-enclose-3.2.2-patch ./ruby-enclose-3.2.2-patch
COPY ruby-enclose-${RUBY_VERSION}-patch ./ruby-enclose-${RUBY_VERSION}-patch
COPY bin ./bin
COPY lib ./lib
COPY rakelib ./rakelib
Expand All @@ -52,7 +57,7 @@ COPY test ./test
RUN bundle install
RUN bundle exec rake patch_ruby_source
RUN bundle exec rake rubyc
RUN rubyc --version
RUN ./rubyc --version
RUN mv rubyc /usr/local/bin/rubyc
WORKDIR /app

Expand Down
39 changes: 31 additions & 8 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -1,14 +1,37 @@
# frozen_string_literal: true

LIBGDBM_VERSION = '1.23'
LIBFFI_VERSION = '3.4.4'
LIBYAML_VERSION = '0.2.5'
OPENSSL_VERSION = '3.0.10'
NCURSES_VERSION = '6.4'
ZLIB_VERSION = '1.2.13'
READLINE_VERSION = '8.2'
SQLITE3_VERSION = '3420000'
RP_RUBY_VERSION = ENV['RP_RUBY_VERSION'] || '3.2.2'
# Note, you can use different ruby versions, but you will need to create
# a ruby-enclose-x.x.x-patch folder with the patch files for that version.
# You need to take the original ruby source, and apply entries
# with [Enclose.IO Hack start] from the ruby-enclose-3.2.2-patch
# You need to retain the original source code, for that version.
LIBGDBM_VERSION = ENV['LIBGDBM_VERSION'] || '1.23'
# LIBGDBM_VERSION=1.13 # Original version as of pmq20 source
# has a vendored patch. Note these pmq20 original source patches two files
# however since updating to 1.23, only one file is included in source and therefore is the
# only one patched
LIBFFI_VERSION = ENV['LIBFFI_VERSION'] || '3.4.4'
# LIBFFI_VERSION=3.2.1 # Original version as of pmq20 source, Note also update in compiler.rb
# https://github.com/libffi/libffi
LIBYAML_VERSION = ENV['LIBYAML_VERSION'] || '0.2.5'
# LIBYAML_VERSION=0.1.7 # Original version as of pmq20 source
# https://pyyaml.org/wiki/LibYAML
OPENSSL_VERSION = ENV['OPENSSL_VERSION'] || '3.0.10'
# https://www.openssl.org/source/
# OPENSSL_VERSION=1.1.1g # Original version as of pmq20 source
# OPENSSL_VERSION=1.1.1v # Latest to date of 1.1.x # Pre Alpine 3.17
# OPENSSL_VERSION=3.0.10 # Latest to date of 3.0.x # Alpine 3.17
# OPENSSL_VERSION=3.1.2 # Latest to date of 3.1.x # Alpine 3.18
NCURSES_VERSION = ENV['NCURSES_VERSION'] || '6.4'
# NCURSES_VERSION=6.0 # Original version as of pmq20 source
# https://ftp.gnu.org/gnu/ncurses/
ZLIB_VERSION = ENV['ZLIB_VERSION'] || '1.2.13'
# ZLIB_VERSION=1.2.13 # Original version as of pmq20 source, https://zlib.net/
READLINE_VERSION = ENV['READLINE_VERSION'] || '8.2'
# READLINE_VERSION=7.0 # Original version as of pmq20 source
# https://ftp.gnu.org/gnu/readline/
SQLITE3_VERSION = ENV['SQLITE3_VERSION'] || '3420000' # Unsure if this is needed atm.
RUBY_MAJOR = RP_RUBY_VERSION.split('.')[0]
RUBY_MINOR = RP_RUBY_VERSION.split('.')[1]
RUBY_PATCH = RP_RUBY_VERSION.split('.')[2].split('-')[0]
Expand Down
2 changes: 1 addition & 1 deletion examples/pact/Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ gem 'pact-provider-verifier', '1.36.1'
# gem "json", "2.6.3"
# gem 'ffi'
gem 'pact_broker', '2.107.1'
gem 'pact-ffi', '0.0.3'
# gem 'pact-ffi', '0.0.3'
gem 'sucker_punch', git: 'https://github.com/pact-foundation/sucker_punch.git', ref: 'fix/rename-is-singleton-class-method-2'

## Native extension gems
Expand Down
12 changes: 0 additions & 12 deletions examples/pact/Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,6 @@ GEM
faraday-retry (1.0.3)
faraday_middleware (1.2.0)
faraday (~> 1.0)
ffi (1.15.5)
find_a_port (1.0.1)
haml (5.2.2)
temple (>= 0.8.0)
Expand Down Expand Up @@ -111,16 +110,6 @@ GEM
term-ansicolor (~> 1.0)
thor (>= 0.20, < 2.0)
webrick (~> 1.3)
pact-ffi (0.0.3-aarch64-linux)
ffi (~> 1.15)
pact-ffi (0.0.3-arm64-darwin)
ffi (~> 1.15)
pact-ffi (0.0.3-x64-mingw-ucrt)
ffi (~> 1.15)
pact-ffi (0.0.3-x86_64-darwin)
ffi (~> 1.15)
pact-ffi (0.0.3-x86_64-linux)
ffi (~> 1.15)
pact-message (0.11.1)
pact-mock_service (~> 3.1)
pact-support (~> 1.8)
Expand Down Expand Up @@ -282,7 +271,6 @@ PLATFORMS
DEPENDENCIES
nokogiri (= 1.15.3)
pact (= 1.63.0)
pact-ffi (= 0.0.3)
pact-message (= 0.11.1)
pact-mock_service (= 3.11.2)
pact-provider-verifier (= 1.36.1)
Expand Down
2 changes: 1 addition & 1 deletion lib/compiler.rb
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ def local_toolchain_bundle
@utils.run_allow_failures(local_toolchain_env, @gem, 'env')
@utils.run_allow_failures(local_toolchain_env, @bundle, 'env')
# @utils.run_allow_failures(local_toolchain_env, @bundle, 'install') # This should be user configurable, whether to include or not
@utils.run(local_toolchain_env, @bundle, 'install', '--without', 'development', 'test')
@utils.run_allow_failures(local_toolchain_env, @bundle, 'install', '--without', 'development', 'test')
# detect Rails
if @utils.run_allow_failures(local_toolchain_env, @bundle, 'show', 'rails').exitstatus.zero?
log '=> Detected a Rails project'
Expand Down

0 comments on commit aaaf2b2

Please sign in to comment.