Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multi-architecture Linux & macOS builds #44

Draft
wants to merge 7 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 20 additions & 4 deletions tools/tools.sh
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,31 @@ set -o errexit -o pipefail -o noclobber -o nounset
: "${CMAKE_VERSION:=3.24.4-1}"
: "${RUBY_VERSION:=3.1.6}"
: "${RUBY_INSTALL_VERSION:=0.9.3}"
: "${ARCH:=x64}"

install_cmake() {
echo "Running install_cmake for CMake version ${CMAKE_VERSION} for ${ARCH}"
echo "Running install_cmake for CMake version ${CMAKE_VERSION}"

# Detect system architecture and resolve cmake_arch
case "$(uname -m)" in
x86_64)
cmake_arch="x64"
;;
arm64 | aarch64)
cmake_arch="arm64"
;;
*)
echo "Unsupported architecture: $(uname -m)"
exit 1
;;
esac

echo "Detected architecture: $(uname -m), resolved cmake_arch: ${cmake_arch}"

local cmake_install=${LOCAL_BUILDS}/cmake
mkdir -p ${cmake_install}
pushd ${cmake_install}
wget -nv https://github.com/xpack-dev-tools/cmake-xpack/releases/download/v${CMAKE_VERSION}/xpack-cmake-${CMAKE_VERSION}-linux-${ARCH}.tar.gz
tar -zxf xpack-cmake-${CMAKE_VERSION}-linux-${ARCH}.tar.gz --directory /usr --strip-components=1 --skip-old-files
wget -nv https://github.com/xpack-dev-tools/cmake-xpack/releases/download/v${CMAKE_VERSION}/xpack-cmake-${CMAKE_VERSION}-linux-${cmake_arch}.tar.gz
tar -zxf xpack-cmake-${CMAKE_VERSION}-linux-${cmake_arch}.tar.gz --directory /usr --strip-components=1 --skip-old-files
popd
rm -rf ${cmake_install}
}
Expand Down
48 changes: 37 additions & 11 deletions ubuntu-20.04.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,10 @@
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.

FROM ubuntu:focal
FROM ubuntu:focal AS base

ENV DEBIAN_FRONTEND=noninteractive
ENV TZ=Etc/UTC
ENV ARCH=x64

RUN apt-get -y update && \
apt-get -y install sudo wget git make pkg-config clang-12 clang++-12 \
Expand All @@ -47,6 +46,11 @@ COPY tools /opt/tools
RUN /opt/tools/tools.sh install_cmake && \
/opt/tools/tools.sh install_ruby

# This is needed to deal with gems created by `bundler gem` that are
# being packaged by `tebako press` inside of a container. More at
# https://github.com/tamatebako/tebako/issues/233#issuecomment-2593760210.
RUN git config --global --add safe.directory '*'

# https://github.com/actions/checkout/issues/1014
# RUN adduser --disabled-password --gecos "" --home $HOME tebako && \
# printf "\ntebako\tALL=(ALL)\tNOPASSWD:\tALL" > /etc/sudoers.d/tebako
Expand All @@ -56,16 +60,38 @@ RUN /opt/tools/tools.sh install_cmake && \
# So we are running as root, HOME=/root, tebako prefix (default) /root/.tebako

ENV TEBAKO_PREFIX=/root/.tebako

# Ruby Setup Layer
FROM base AS base-ruby
LABEL stage="base-ruby"

# Default build-time argument
ARG ruby_version=3.3.6

# Persistent environment variable
ENV TEBAKO_RUBY_VERSION=$ruby_version

# Set macOS-specific flags and install Ruby
# RUN /opt/tools/tools.sh set_macos_host_flags "$macos_host_arch" && \
# gem install tebako && \
# tebako setup -R $TEBAKO_RUBY_VERSION

RUN gem install tebako -v 0.12.2.rc1 && \
tebako setup -R "$TEBAKO_RUBY_VERSION"

# Test Layer
FROM base-ruby AS test
LABEL stage="test"

# Copy test files and execute tests
COPY test /root/test
RUN tebako press -R "$TEBAKO_RUBY_VERSION" -r /root/test -e tebako-test-run.rb -o "ruby-$TEBAKO_RUBY_VERSION-package" && \
rm "ruby-$TEBAKO_RUBY_VERSION-package"

# Create packaging environment for Ruby 3.3.6, 3.2.6
# Test and "warm up" since initialization is fully finished after the first packaging
RUN gem install tebako && \
tebako setup -R 3.3.6 && \
tebako setup -R 3.2.6 && \
tebako press -R 3.3.6 -r /root/test -e tebako-test-run.rb -o ruby-3.3.6-package && \
tebako press -R 3.2.6 -r /root/test -e tebako-test-run.rb -o ruby-3.2.6-package && \
rm ruby-*-package
# Final Production Image
FROM base-ruby AS builder
LABEL stage="builder"

ENV PS1="\[\]\[\e]0;\u@\h: \w\a\]${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ \[\]"
# Skip copying `test` into the final image to reduce size
#ENV PS1="\[\]\[\e]0;\u@\h: \w\a\]${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ \[\]"
CMD ["bash"]