From cfbac66a0119468ae2a5e292caf01d5bcc2534bf Mon Sep 17 00:00:00 2001 From: Jakub-PMX Date: Tue, 26 Aug 2025 10:52:52 +0200 Subject: [PATCH 1/6] Adds grpc docker image pre-build --- grpc/ruby-3.2/Dockerfile | 21 +++++++++++++++++++++ grpc/ruby-3.2/Gemfile | 3 +++ grpc/ruby-3.2/Gemfile.lock | 22 ++++++++++++++++++++++ 3 files changed, 46 insertions(+) create mode 100644 grpc/ruby-3.2/Dockerfile create mode 100644 grpc/ruby-3.2/Gemfile create mode 100644 grpc/ruby-3.2/Gemfile.lock diff --git a/grpc/ruby-3.2/Dockerfile b/grpc/ruby-3.2/Dockerfile new file mode 100644 index 0000000..bcc83f9 --- /dev/null +++ b/grpc/ruby-3.2/Dockerfile @@ -0,0 +1,21 @@ +FROM f3ddevelopers/aws-lambda-ruby-patched:3.2 + +RUN yum swap -y openssl-snapsafe-libs openssl-libs + +RUN yum update -y && \ + yum install -y make gcc gcc-c++ && \ + yum clean all + +COPY Gemfile . +COPY Gemfile.lock . + +RUN bundle config set deployment true && \ + bundle config set without 'test development' && \ + bundle config build.ffi -- --with-cflags="-Wno-implicit-function-declaration" && \ + bundle config set retry 5 && \ + bundle config set jobs $(getconf _NPROCESSORS_ONLN) && \ + if [[ "$ARCHITECTURE" == "arm64" ]]; then \ + bundle config set force_ruby_platform true && \ + bundle config build.ffi --enable-libffi-alloc; \ + fi && \ + BUNDLE_FORCE_RUBY_PLATFORM=true bundle diff --git a/grpc/ruby-3.2/Gemfile b/grpc/ruby-3.2/Gemfile new file mode 100644 index 0000000..a957f6c --- /dev/null +++ b/grpc/ruby-3.2/Gemfile @@ -0,0 +1,3 @@ +source 'https://rubygems.org' + +gem 'grpc' diff --git a/grpc/ruby-3.2/Gemfile.lock b/grpc/ruby-3.2/Gemfile.lock new file mode 100644 index 0000000..e175f54 --- /dev/null +++ b/grpc/ruby-3.2/Gemfile.lock @@ -0,0 +1,22 @@ +GEM + remote: https://rubygems.org/ + specs: + bigdecimal (3.2.2) + google-protobuf (4.32.0) + bigdecimal + rake (>= 13) + googleapis-common-protos-types (1.20.0) + google-protobuf (>= 3.18, < 5.a) + grpc (1.74.1) + google-protobuf (>= 3.25, < 5.0) + googleapis-common-protos-types (~> 1.0) + rake (13.3.0) + +PLATFORMS + ruby + +DEPENDENCIES + grpc + +BUNDLED WITH + 2.7.1 From 082b0dd24c4caefd5ef287715e63d9325b368d9c Mon Sep 17 00:00:00 2001 From: Jakub-PMX Date: Tue, 26 Aug 2025 10:53:06 +0200 Subject: [PATCH 2/6] Adds GHA for grpc pre-build --- .github/workflows/grpc.yml | 52 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 .github/workflows/grpc.yml diff --git a/.github/workflows/grpc.yml b/.github/workflows/grpc.yml new file mode 100644 index 0000000..cd92825 --- /dev/null +++ b/.github/workflows/grpc.yml @@ -0,0 +1,52 @@ +name: "aws-lambda-ruby-grpc:3.2" + +on: + pull_request: + paths: + - "grpc/ruby-3.2/Dockerfile" + +jobs: + build-and-push: + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Set up QEMU (for emulation) + uses: docker/setup-qemu-action@v3 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + with: + driver: docker-container + driver-opts: image=moby/buildkit:master + + - name: Log in to Docker Hub Container Registry + uses: docker/login-action@v3 + with: + username: ${{ secrets.DOCKER_HUB_USERNAME }} + password: ${{ secrets.DOCKER_HUB_PASSWORD }} + + - name: Build and push Docker image + uses: docker/build-push-action@v6 + with: + context: . + file: ./grpc/ruby-3.2/Dockerfile + push: true + platforms: linux/amd64,linux/arm64 + tags: ${{ secrets.DOCKER_HUB_USERNAME }}/aws-lambda-ruby-grpc:3.2 + # - name: Scan + # id: scan + # uses: anchore/scan-action@v6 + # continue-on-error: true + # with: + # image: ${{ secrets.DOCKER_HUB_USERNAME }}/aws-lambda-ruby-grpc:3.2 + # fail-build: true + # output-format: sarif + # severity-cutoff: low + # add-cpes-if-none: true + # - name: Update PR with vulnerability scan results + # uses: forward3d/comment-failure-details@v1.0.0 + # with: + # report: ${{ steps.scan.outputs.sarif }} + # image-name: aws-lambda-ruby-grpc:3.2 From 264b87ebdbae52fad5585bc39fea9d2a7534f622 Mon Sep 17 00:00:00 2001 From: Jakub-PMX Date: Tue, 26 Aug 2025 10:59:52 +0200 Subject: [PATCH 3/6] fix context --- .github/workflows/grpc.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/grpc.yml b/.github/workflows/grpc.yml index cd92825..249af86 100644 --- a/.github/workflows/grpc.yml +++ b/.github/workflows/grpc.yml @@ -30,7 +30,7 @@ jobs: - name: Build and push Docker image uses: docker/build-push-action@v6 with: - context: . + context: ./grpc/ruby-3.2/ file: ./grpc/ruby-3.2/Dockerfile push: true platforms: linux/amd64,linux/arm64 From 51e929b8c16a41726f9f4233d21c0edbcf7e9930 Mon Sep 17 00:00:00 2001 From: Jakub-PMX Date: Tue, 26 Aug 2025 15:15:43 +0200 Subject: [PATCH 4/6] simplify --- grpc/ruby-3.2/Dockerfile | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/grpc/ruby-3.2/Dockerfile b/grpc/ruby-3.2/Dockerfile index bcc83f9..5f109d7 100644 --- a/grpc/ruby-3.2/Dockerfile +++ b/grpc/ruby-3.2/Dockerfile @@ -11,11 +11,11 @@ COPY Gemfile.lock . RUN bundle config set deployment true && \ bundle config set without 'test development' && \ - bundle config build.ffi -- --with-cflags="-Wno-implicit-function-declaration" && \ + # bundle config build.ffi -- --with-cflags="-Wno-implicit-function-declaration" && \ bundle config set retry 5 && \ - bundle config set jobs $(getconf _NPROCESSORS_ONLN) && \ - if [[ "$ARCHITECTURE" == "arm64" ]]; then \ - bundle config set force_ruby_platform true && \ - bundle config build.ffi --enable-libffi-alloc; \ - fi && \ + # bundle config set jobs $(getconf _NPROCESSORS_ONLN) && \ + # if [[ "$ARCHITECTURE" == "arm64" ]]; then \ + # bundle config set force_ruby_platform true && \ + # bundle config build.ffi --enable-libffi-alloc; \ + # fi && \ BUNDLE_FORCE_RUBY_PLATFORM=true bundle From 5d3cacabdd6e0d5909046da2e7bfbd54230cc6f7 Mon Sep 17 00:00:00 2001 From: Jakub-PMX Date: Tue, 26 Aug 2025 16:43:57 +0200 Subject: [PATCH 5/6] Adds ruby-devel libs --- grpc/ruby-3.2/Dockerfile | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/grpc/ruby-3.2/Dockerfile b/grpc/ruby-3.2/Dockerfile index 5f109d7..6963302 100644 --- a/grpc/ruby-3.2/Dockerfile +++ b/grpc/ruby-3.2/Dockerfile @@ -3,19 +3,21 @@ FROM f3ddevelopers/aws-lambda-ruby-patched:3.2 RUN yum swap -y openssl-snapsafe-libs openssl-libs RUN yum update -y && \ - yum install -y make gcc gcc-c++ && \ + yum install -y make gcc gcc-c++ ruby-devel && \ yum clean all COPY Gemfile . COPY Gemfile.lock . -RUN bundle config set deployment true && \ - bundle config set without 'test development' && \ - # bundle config build.ffi -- --with-cflags="-Wno-implicit-function-declaration" && \ - bundle config set retry 5 && \ - # bundle config set jobs $(getconf _NPROCESSORS_ONLN) && \ - # if [[ "$ARCHITECTURE" == "arm64" ]]; then \ - # bundle config set force_ruby_platform true && \ - # bundle config build.ffi --enable-libffi-alloc; \ - # fi && \ - BUNDLE_FORCE_RUBY_PLATFORM=true bundle +# RUN bundle config set deployment true && \ +# bundle config set without 'test development' && \ +# bundle config build.ffi -- --with-cflags="-Wno-implicit-function-declaration" && \ +# bundle config set retry 5 && \ +# bundle config set jobs $(getconf _NPROCESSORS_ONLN) && \ +# if [[ "$ARCHITECTURE" == "arm64" ]]; then \ +# bundle config set force_ruby_platform true && \ +# bundle config build.ffi --enable-libffi-alloc; \ +# fi && \ +# BUNDLE_FORCE_RUBY_PLATFORM=true bundle + +RUN BUNDLE_FORCE_RUBY_PLATFORM=true bundle From 94fbefd6addb8dd85494f5baf14d7c9bdd6d07f1 Mon Sep 17 00:00:00 2001 From: Jakub-PMX Date: Thu, 28 Aug 2025 12:40:39 +0200 Subject: [PATCH 6/6] Forces creation of vendor on bundle install --- grpc/ruby-3.2/Dockerfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/grpc/ruby-3.2/Dockerfile b/grpc/ruby-3.2/Dockerfile index 6963302..5a88ff1 100644 --- a/grpc/ruby-3.2/Dockerfile +++ b/grpc/ruby-3.2/Dockerfile @@ -9,8 +9,8 @@ RUN yum update -y && \ COPY Gemfile . COPY Gemfile.lock . -# RUN bundle config set deployment true && \ -# bundle config set without 'test development' && \ +RUN bundle config set deployment true && \ + bundle config set without 'test development' # bundle config build.ffi -- --with-cflags="-Wno-implicit-function-declaration" && \ # bundle config set retry 5 && \ # bundle config set jobs $(getconf _NPROCESSORS_ONLN) && \