Skip to content

Commit

Permalink
Merge pull request #2 from YOU54F/alpine
Browse files Browse the repository at this point in the history
Alpine
  • Loading branch information
YOU54F authored Feb 15, 2024
2 parents 642ce92 + 5448298 commit 30774c2
Show file tree
Hide file tree
Showing 45 changed files with 1,492 additions and 44 deletions.
43 changes: 42 additions & 1 deletion .cirrus.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
env:
REPO: you54f/traveling-ruby
PKG_DATE: 20240205
PKG_DATE: 20240215
NEXT_TAG: rel-$PKG_DATE
GITHUB_TOKEN: ENCRYPTED[7f3663f35400d0e1f8e0fec456af6b75a07b0fd2d0632fe1697b8fb73af5e78245144216288d88d2daa681ccd159e07d]

Expand Down Expand Up @@ -110,6 +110,15 @@ RUBY_VERSIONS_MATRIX_LINUX: &RUBY_VERSIONS_MATRIX_LINUX
# RUBY_VERSIONS: 3.0.6
# RUBY_VERSIONS: 2.7.8

RUBY_VERSIONS_MATRIX_LINUX_ALPINE: &RUBY_VERSIONS_MATRIX_LINUX_ALPINE
RUBY_VERSIONS: 3.3.0
RUBY_VERSIONS: 3.2.3
RUBY_VERSIONS: 3.1.4
# RUBY_VERSIONS: 3.0.4
# RUBY_VERSIONS: 2.6.10
# # RUBY_VERSIONS: 3.0.6
# # RUBY_VERSIONS: 2.7.8

rake_package_and_test: &rake_package_and_test
package_script: cd $PLATFORM && rake
package_full_script: cd $PLATFORM && rake package_full
Expand Down Expand Up @@ -218,6 +227,38 @@ linux_x64_matrix_docker_builder:
<<: *UPLOAD_TASK
<<: *BINARY_ATRIFACTS

linux_arm64_alpine_matrix_docker_builder:
cpu: 4
memory: 4G
only_if: $CIRRUS_CHANGE_TITLE =~ 'ci\(matrix-linux-musl-arm64\).*' || $CIRRUS_CHANGE_TITLE =~ 'ci\(alpine\).*' || $CIRRUS_CHANGE_TITLE =~ 'ci\(matrix\).*' || $CIRRUS_BRANCH =~ 'main'
env:
CIRRUS_ARCH: arm64
PLATFORM: alpine
ARCHITECTURES: arm64
matrix:
*RUBY_VERSIONS_MATRIX_LINUX_ALPINE
<<: *ENV_CHECK_SCRIPT
<<: *rake_package_and_test_docker
<<: *INSTALL_GH_CLI
<<: *UPLOAD_TASK
<<: *BINARY_ATRIFACTS

linux_x64_alpine_matrix_docker_builder:
cpu: 4
memory: 4G
only_if: $CIRRUS_CHANGE_TITLE =~ 'ci\(matrix-linux-musl-x86_64\).*' || $CIRRUS_CHANGE_TITLE =~ 'ci\(alpine\).*' || $CIRRUS_CHANGE_TITLE =~ 'ci\(matrix\).*' || $CIRRUS_BRANCH =~ 'main'
env:
CIRRUS_ARCH: amd64
PLATFORM: alpine
ARCHITECTURES: x86_64
matrix:
*RUBY_VERSIONS_MATRIX_LINUX_ALPINE
<<: *ENV_CHECK_SCRIPT
<<: *rake_package_and_test_docker
<<: *INSTALL_GH_CLI
<<: *UPLOAD_TASK
<<: *BINARY_ATRIFACTS

# ========================================
# MacOS
# ========================================
Expand Down
51 changes: 51 additions & 0 deletions .github/workflows/alpine-arm64.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: Alpine Musl - arm64 - build from dockerhub builder
# Broken on GitHub Actions with QEMU
on:
workflow_dispatch:
push:
branches: [ main, alpine ]
# pull_request:
# branches: [ main ]

env:
PKG_DATE: 20240215

jobs:
make-alpine-arm64:
strategy:
matrix:
os: [ubuntu-latest]
ruby-version: [3.1.4, 3.2.3, 3.3.0]
fail-fast: false
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v3
- name: "Set up Ruby"
uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby-version }}
- name: package
run: |
docker run --privileged --rm tonistiigi/binfmt --install all
cd alpine
rake
ls
env:
ARCHITECTURES: "arm64"
RUBY_VERSIONS: ${{ matrix.ruby-version }}
- name: package gems
run: ./scripts/package-gems.sh
env:
PLATFORM: alpine
- name: 'Upload Artifact - linux arm64'
uses: actions/upload-artifact@v3
with:
name: traveling-ruby-${{ env.PKG_DATE }}-${{ matrix.ruby-version }}-linux-musl-arm64.tar.gz
path: alpine/traveling-ruby*.tar.gz
- name: test
run: |
cd alpine
rake test_docker
env:
ARCHITECTURES: "arm64"
RUBY_VERSIONS: ${{ matrix.ruby-version }}
49 changes: 49 additions & 0 deletions .github/workflows/alpine-x86_64.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: Alpine Musl - x86_64 - build from dockerhub builder

on:
push:
branches: [ main, alpine ]
pull_request:
branches: [ main ]

env:
PKG_DATE: 20240215

jobs:
make-alpine-x86_64:
strategy:
matrix:
os: [ubuntu-latest]
ruby-version: [3.1.4, 3.2.3, 3.3.0]
fail-fast: false
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v3
- name: "Set up Ruby"
uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby-version }}
- name: package
run: |
cd alpine
rake
ls
env:
ARCHITECTURES: "x86_64"
RUBY_VERSIONS: ${{ matrix.ruby-version }}
- name: package gems
run: ./scripts/package-gems.sh
env:
PLATFORM: alpine
- name: 'Upload Artifact - linux x86_64'
uses: actions/upload-artifact@v3
with:
name: traveling-ruby-${{ env.PKG_DATE }}-${{ matrix.ruby-version }}-linux-musl-x86_64.tar.gz
path: alpine/traveling-ruby*.tar.gz
- name: test
run: |
cd alpine
rake test_docker
env:
ARCHITECTURES: "x86_64"
RUBY_VERSIONS: ${{ matrix.ruby-version }}
6 changes: 1 addition & 5 deletions .github/workflows/osx-arm64.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ on:
branches: [ main ]

env:
PKG_DATE: 20240205
PKG_DATE: 20240215
PLATFORM: osx
ARCHITECTURES: arm64
DEVELOPER_DIR: /Applications/Xcode_14.3.1.app/Contents/Developer
Expand All @@ -22,10 +22,6 @@ jobs:
fail-fast: false
runs-on: ${{ matrix.os }}
steps:
# - name: Cancel Previous Runs
# uses: styfle/[email protected]
# with:
# all_but_latest: true
- uses: actions/checkout@v3
- name: download osx arm64 runtime
run: ./scripts/download-osx-runtime.sh
Expand Down
6 changes: 1 addition & 5 deletions .github/workflows/osx-x86_64.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ on:
branches: [ main ]

env:
PKG_DATE: 20240205
PKG_DATE: 20240215
PLATFORM: osx
ARCHITECTURES: x86_64
DEVELOPER_DIR: /Applications/Xcode_14.2.app/Contents/Developer
Expand All @@ -22,10 +22,6 @@ jobs:
fail-fast: false
runs-on: ${{ matrix.os }}
steps:
# - name: Cancel Previous Runs
# uses: styfle/[email protected]
# with:
# all_but_latest: true
- uses: actions/checkout@v3
- name: download osx x86_64 runtime
run: ./scripts/download-osx-runtime.sh
Expand Down
4 changes: 0 additions & 4 deletions .github/workflows/ubuntu-arm64-image-builder.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,6 @@ jobs:
fail-fast: false
runs-on: ${{ matrix.os }}
steps:
# - name: Cancel Previous Runs
# uses: styfle/[email protected]
# with:
# all_but_latest: true
- uses: actions/checkout@v3
- name: "Set up Ruby"
uses: ruby/setup-ruby@v1
Expand Down
6 changes: 1 addition & 5 deletions .github/workflows/ubuntu-arm64.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ on:
# branches: [ main ]

env:
PKG_DATE: 20240205
PKG_DATE: 20240215

jobs:
make-ubuntu-arm64:
Expand All @@ -19,10 +19,6 @@ jobs:
fail-fast: false
runs-on: ${{ matrix.os }}
steps:
# - name: Cancel Previous Runs
# uses: styfle/[email protected]
# with:
# all_but_latest: true
- uses: actions/checkout@v3
- name: "Set up Ruby"
uses: ruby/setup-ruby@v1
Expand Down
4 changes: 0 additions & 4 deletions .github/workflows/ubuntu-x86_64-image-builder.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,6 @@ jobs:
fail-fast: false
runs-on: ${{ matrix.os }}
steps:
# - name: Cancel Previous Runs
# uses: styfle/[email protected]
# with:
# all_but_latest: true
- uses: actions/checkout@v3
- name: "Set up Ruby"
uses: ruby/setup-ruby@v1
Expand Down
6 changes: 1 addition & 5 deletions .github/workflows/ubuntu-x86_64.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ on:
branches: [ main ]

env:
PKG_DATE: 20240205
PKG_DATE: 20240215

jobs:
make-ubuntu-x86_64:
Expand All @@ -18,10 +18,6 @@ jobs:
fail-fast: false
runs-on: ${{ matrix.os }}
steps:
# - name: Cancel Previous Runs
# uses: styfle/[email protected]
# with:
# all_but_latest: true
- uses: actions/checkout@v3
- name: "Set up Ruby"
uses: ruby/setup-ruby@v1
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/win.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ on:
branches: [ main ]

env:
PKG_DATE: 20240205
PKG_DATE: 20240215

jobs:
make-windows:
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
/linux/runtime
/linux/output
/linux/traveling-ruby-gems*
/alpine/runtime
/alpine/output
/alpine/traveling-ruby-gems*
/osx/traveling-ruby-gems*
/windows/traveling-ruby-gems*
/osx/runtime*
Expand Down
1 change: 1 addition & 0 deletions .ruby-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.2.3
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ RUN apt-get update && \
apt-get clean && rm -rf /var/lib/apt/lists

ARG TRAVELING_RUBY_VERSION=2.6.10
ARG TRAVELING_RUBY_PKG_DATE=20240205
ARG TRAVELING_RUBY_PKG_DATE=20240215
ARG TRAVELING_RUBY_GH_SOURCE=YOU54F/traveling-ruby

ENV PATH="/home/.traveling-ruby/bin:$PATH"
Expand Down
2 changes: 1 addition & 1 deletion VERSION.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
20240205
20240215
2 changes: 1 addition & 1 deletion action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ inputs:
release:
description: 'Date of the package to install'
required: false
default: '20240205'
default: '20240215'
gems:
description: 'List of gems and optionally versions, white space seperated (e.g. "nokogiri-1.10.10 rails")'
required: false
Expand Down
3 changes: 3 additions & 0 deletions alpine/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
runtime
output
*.tar.gz
42 changes: 42 additions & 0 deletions alpine/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# Traveling Ruby Linux build system

The `linux/` directory contains the build system for building Traveling Ruby binaries for Linux.

## Building binaries

The build system requires Docker and Rake. To build binaries, run:

cd linux
rake

This will produce a `traveling-ruby-XXXXX.tar.gz` file which contains the Ruby binaries, and a `traveling-ruby-gems-XXXXX` directory which contains the native extensions.

## How it works

### Build environment (Docker image)

The build system runs inside a Docker container. The Docker image is called [phusion/traveling-ruby-builder](https://registry.hub.docker.com/r/phusion/traveling-ruby-builder/), and it's built from the sources in `linux/image/`.

The image contains a controlled build environment with a specific compiler toolchain and specific libraries, allowing us to compile binaries that can run on a large number of Linux systems. It's based on [Holy Build Box](http://FooBarWidget.github.io/holy-build-box/).

The image can be built with `rake image`.

### Build script

The build script is the component that actually compiles Ruby. It assumes that the build environment is already available.

The build script consists of two parts:

1. `linux/build-ruby.sh` is the entrypoint for users. It spawns a Docker container, based on the build environment Docker image. Inside the container, it runs `linux/internal/build-ruby.sh`.

2. `linux/internal/build-ruby.sh` is the script that contains most of the actual build logic. It:

* Builds Ruby. It extracts the Ruby source tarball and runs `./configure`, `make` and `make install`.
* Builds the native extensions that Traveling Ruby supports. It runs `bundle install` on the Gemfile located in the `shared/` directory in the Traveling Ruby repository.
* Performs various postprocessing tasks, such as stripping debugging symbols from the binaries and running various sanity checks.

You can kick off the build script with `rake build`. The build outputs are saved to the `output` directory.

### Package script

Once binaries are compiled, once can package the files by invoking `rake package`. This script packages files inside the `output` directory into various tarballs.
Loading

0 comments on commit 30774c2

Please sign in to comment.