From dd2411613e32159343060d7fce6e2532b2734bca Mon Sep 17 00:00:00 2001 From: David Wilkie Date: Thu, 30 May 2024 19:40:17 +0700 Subject: [PATCH 1/5] Update services lambda --- .tool-versions | 2 +- components/services/.tool-versions | 1 - components/services/Dockerfile | 8 +-- components/services/Gemfile.lock | 26 ++++----- components/services/spec/support/aws.rb | 41 -------------- .../modules/somleng_switch/services.tf | 54 +++++++++---------- 6 files changed, 47 insertions(+), 85 deletions(-) delete mode 100644 components/services/.tool-versions delete mode 100644 components/services/spec/support/aws.rb diff --git a/.tool-versions b/.tool-versions index 2d76f1a75..dca91f501 100644 --- a/.tool-versions +++ b/.tool-versions @@ -1,3 +1,3 @@ terraform 1.5.6 -ruby 3.2.2 +ruby 3.3.1 golang 1.22.1 diff --git a/components/services/.tool-versions b/components/services/.tool-versions deleted file mode 100644 index f2a971aa7..000000000 --- a/components/services/.tool-versions +++ /dev/null @@ -1 +0,0 @@ -ruby 3.2.2 diff --git a/components/services/Dockerfile b/components/services/Dockerfile index 1a0bfa48a..8d319b935 100644 --- a/components/services/Dockerfile +++ b/components/services/Dockerfile @@ -1,6 +1,6 @@ ARG FUNCTION_DIR="/function" - -FROM ruby:3.2-alpine as build-image +ARG RUBY_VERSION=3.3 +FROM public.ecr.aws/docker/library/ruby:$RUBY_VERSION-alpine AS build-image RUN apk update && \ apk upgrade && \ @@ -30,7 +30,7 @@ COPY lib/ ${FUNCTION_DIR}/lib/ ############################# -FROM ruby:3.2-alpine +FROM public.ecr.aws/docker/library/ruby:$RUBY_VERSION-alpine ARG FUNCTION_DIR WORKDIR ${FUNCTION_DIR} @@ -44,5 +44,7 @@ RUN apk update && \ gem install bundler && \ gem install aws_lambda_ric +ENV RUBY_YJIT_ENABLE=true + ENTRYPOINT [ "/usr/local/bundle/bin/aws_lambda_ric" ] CMD [ "app.App::Handler.process" ] diff --git a/components/services/Gemfile.lock b/components/services/Gemfile.lock index 05f20d88a..8db0db5c2 100644 --- a/components/services/Gemfile.lock +++ b/components/services/Gemfile.lock @@ -2,37 +2,38 @@ GEM remote: https://rubygems.org/ specs: aws-eventstream (1.3.0) - aws-partitions (1.925.0) - aws-sdk-core (3.194.2) + aws-partitions (1.936.0) + aws-sdk-core (3.196.1) aws-eventstream (~> 1, >= 1.3.0) aws-partitions (~> 1, >= 1.651.0) aws-sigv4 (~> 1.8) jmespath (~> 1, >= 1.6.1) - aws-sdk-ec2 (1.456.0) + aws-sdk-ec2 (1.458.0) aws-sdk-core (~> 3, >= 3.193.0) aws-sigv4 (~> 1.1) - aws-sdk-ecs (1.146.0) + aws-sdk-ecs (1.147.0) aws-sdk-core (~> 3, >= 3.193.0) aws-sigv4 (~> 1.1) - aws-sdk-ssm (1.168.0) + aws-sdk-ssm (1.169.0) aws-sdk-core (~> 3, >= 3.193.0) aws-sigv4 (~> 1.1) aws-sigv4 (1.8.0) aws-eventstream (~> 1, >= 1.0.2) - bigdecimal (3.1.7) + bigdecimal (3.1.8) coderay (1.1.3) - concurrent-ruby (1.2.3) + concurrent-ruby (1.3.1) diff-lcs (1.5.1) docile (1.4.0) jmespath (1.6.2) - method_source (1.0.0) + method_source (1.1.0) ox (2.14.18) pg (1.5.6) pry (0.14.2) coderay (~> 1.1) method_source (~> 1.0) rake (13.2.1) - rexml (3.2.5) + rexml (3.2.8) + strscan (>= 3.0.9) rspec (3.13.0) rspec-core (~> 3.13.0) rspec-expectations (~> 3.13.0) @@ -42,10 +43,10 @@ GEM rspec-expectations (3.13.0) diff-lcs (>= 1.2.0, < 2.0) rspec-support (~> 3.13.0) - rspec-mocks (3.13.0) + rspec-mocks (3.13.1) diff-lcs (>= 1.2.0, < 2.0) rspec-support (~> 3.13.0) - rspec-support (3.13.0) + rspec-support (3.13.1) sentry-ruby (5.17.3) bigdecimal concurrent-ruby (~> 1.0, >= 1.0.2) @@ -60,6 +61,7 @@ GEM simplecov (~> 0.19) simplecov-html (0.12.3) simplecov_json_formatter (0.1.4) + strscan (3.1.0) PLATFORMS ruby @@ -79,4 +81,4 @@ DEPENDENCIES simplecov-cobertura BUNDLED WITH - 2.4.12 + 2.5.11 diff --git a/components/services/spec/support/aws.rb b/components/services/spec/support/aws.rb deleted file mode 100644 index 261763885..000000000 --- a/components/services/spec/support/aws.rb +++ /dev/null @@ -1,41 +0,0 @@ -Aws.config[:ssm] = { - stub_responses: { - get_parameters: lambda { |context| - { - parameters: context.params[:names].map do |name| - Aws::SSM::Types::Parameter.new( - name:, - value: name.delete_prefix("ssm-parameter-name-") - ) - end - } - } - } -} - -Aws.config[:ecs] = { - stub_responses: { - describe_container_instances: lambda { |_context| - { - container_instances: [ - ec2_instance_id: "ec2-instance-id" - ] - } - } - } -} - -Aws.config[:ec2] = { - stub_responses: { - describe_instances: lambda { |_context| - { - reservations: [ - instances: [ - private_ip_address: "10.0.0.1", - public_ip_address: "54.251.92.249" - ] - ] - } - } - } -} diff --git a/infrastructure/modules/somleng_switch/services.tf b/infrastructure/modules/somleng_switch/services.tf index 80f078c58..911a56438 100644 --- a/infrastructure/modules/somleng_switch/services.tf +++ b/infrastructure/modules/somleng_switch/services.tf @@ -12,7 +12,7 @@ resource "docker_image" "services" { } resource "docker_registry_image" "services" { - name = docker_image.services.name + name = docker_image.services.name keep_remotely = true } @@ -29,7 +29,7 @@ resource "aws_ssm_parameter" "services_application_master_key" { # IAM resource "aws_iam_role" "services" { - name = local.services_function_name + name = local.services_function_name assume_role_policy = < Date: Thu, 30 May 2024 19:43:30 +0700 Subject: [PATCH 2/5] WIP --- components/services/.tool-versions | 1 + 1 file changed, 1 insertion(+) create mode 100644 components/services/.tool-versions diff --git a/components/services/.tool-versions b/components/services/.tool-versions new file mode 100644 index 000000000..51f617d22 --- /dev/null +++ b/components/services/.tool-versions @@ -0,0 +1 @@ +ruby 3.3.1 From 0bcb8920e506014f14bac46fdc219aad78ed6ca3 Mon Sep 17 00:00:00 2001 From: David Wilkie Date: Thu, 30 May 2024 19:47:58 +0700 Subject: [PATCH 3/5] Upgrade s3mpeg --- components/s3_mpeg/.tool-versions | 2 +- components/s3_mpeg/Dockerfile | 29 +++++------------------------ components/s3_mpeg/Gemfile.lock | 14 ++++++++------ 3 files changed, 14 insertions(+), 31 deletions(-) diff --git a/components/s3_mpeg/.tool-versions b/components/s3_mpeg/.tool-versions index f2a971aa7..51f617d22 100644 --- a/components/s3_mpeg/.tool-versions +++ b/components/s3_mpeg/.tool-versions @@ -1 +1 @@ -ruby 3.2.2 +ruby 3.3.1 diff --git a/components/s3_mpeg/Dockerfile b/components/s3_mpeg/Dockerfile index 18d1d3e56..4a5912943 100644 --- a/components/s3_mpeg/Dockerfile +++ b/components/s3_mpeg/Dockerfile @@ -1,27 +1,6 @@ -# Adopted from https://docs.aws.amazon.com/lambda/latest/dg/images-create.html#images-create-from-alt - -# From: https://docs.aws.amazon.com/lambda/latest/dg/images-test.html#images-test-add -# To test an image without adding RIE to the image -# -# mkdir -p ~/.aws-lambda-rie && curl -Lo ~/.aws-lambda-rie/aws-lambda-rie \ -# https://github.com/aws/aws-lambda-runtime-interface-emulator/releases/latest/download/aws-lambda-rie \ -# && chmod +x ~/.aws-lambda-rie/aws-lambda-rie -# -# For ARM: -# -# https://github.com/aws/aws-lambda-runtime-interface-emulator/releases/latest/download/aws-lambda-rie-arm64 -# -# Run the command -# -# docker run --rm -v ~/.aws-lambda-rie:/aws-lambda -p 9000:8080 \ -# --entrypoint /aws-lambda/aws-lambda-rie record_to_mp3:latest \ -# /usr/local/bundle/bin/aws_lambda_ric app.App::Handler.process -# -# curl -XPOST "http://localhost:9000/2015-03-31/functions/function/invocations" -d '{}' - ARG FUNCTION_DIR="/app" - -FROM ruby:3.2-alpine as build-image +ARG RUBY_VERSION=3.3 +FROM public.ecr.aws/docker/library/ruby:$RUBY_VERSION-alpine AS build-image RUN apk update && \ apk upgrade && \ @@ -48,7 +27,7 @@ COPY app.rb ${FUNCTION_DIR} ############################# -FROM ruby:3.2-alpine +FROM public.ecr.aws/docker/library/ruby:$RUBY_VERSION-alpine ARG FUNCTION_DIR WORKDIR ${FUNCTION_DIR} @@ -62,5 +41,7 @@ RUN apk update && \ gem install bundler && \ gem install aws_lambda_ric +ENV RUBY_YJIT_ENABLE=true + ENTRYPOINT [ "/usr/local/bundle/bin/aws_lambda_ric" ] CMD [ "app.App::Handler.process" ] diff --git a/components/s3_mpeg/Gemfile.lock b/components/s3_mpeg/Gemfile.lock index 29860cd6c..01ad9163d 100644 --- a/components/s3_mpeg/Gemfile.lock +++ b/components/s3_mpeg/Gemfile.lock @@ -2,13 +2,13 @@ GEM remote: https://rubygems.org/ specs: aws-eventstream (1.3.0) - aws-partitions (1.929.0) + aws-partitions (1.936.0) aws-sdk-core (3.196.1) aws-eventstream (~> 1, >= 1.3.0) aws-partitions (~> 1, >= 1.651.0) aws-sigv4 (~> 1.8) jmespath (~> 1, >= 1.6.1) - aws-sdk-kms (1.81.0) + aws-sdk-kms (1.82.0) aws-sdk-core (~> 3, >= 3.193.0) aws-sigv4 (~> 1.1) aws-sdk-s3 (1.151.0) @@ -21,7 +21,8 @@ GEM docile (1.4.0) jmespath (1.6.2) ox (2.14.18) - rexml (3.2.5) + rexml (3.2.8) + strscan (>= 3.0.9) rspec (3.13.0) rspec-core (~> 3.13.0) rspec-expectations (~> 3.13.0) @@ -31,10 +32,10 @@ GEM rspec-expectations (3.13.0) diff-lcs (>= 1.2.0, < 2.0) rspec-support (~> 3.13.0) - rspec-mocks (3.13.0) + rspec-mocks (3.13.1) diff-lcs (>= 1.2.0, < 2.0) rspec-support (~> 3.13.0) - rspec-support (3.13.0) + rspec-support (3.13.1) simplecov (0.22.0) docile (~> 1.1) simplecov-html (~> 0.11) @@ -44,6 +45,7 @@ GEM simplecov (~> 0.19) simplecov-html (0.12.3) simplecov_json_formatter (0.1.4) + strscan (3.1.0) PLATFORMS ruby @@ -56,4 +58,4 @@ DEPENDENCIES simplecov-cobertura BUNDLED WITH - 2.4.12 + 2.5.11 From 92cc69f58cdc2ea357537727c5987878ecb0acf0 Mon Sep 17 00:00:00 2001 From: David Wilkie Date: Thu, 30 May 2024 19:49:46 +0700 Subject: [PATCH 4/5] Update app to 3.3.1 --- components/app/.tool-versions | 2 +- components/app/Dockerfile | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/components/app/.tool-versions b/components/app/.tool-versions index f2a971aa7..51f617d22 100644 --- a/components/app/.tool-versions +++ b/components/app/.tool-versions @@ -1 +1 @@ -ruby 3.2.2 +ruby 3.3.1 diff --git a/components/app/Dockerfile b/components/app/Dockerfile index 1f68baa94..dd0d9f4fd 100644 --- a/components/app/Dockerfile +++ b/components/app/Dockerfile @@ -1,4 +1,5 @@ -FROM ruby:3.2-alpine AS build-env +ARG RUBY_VERSION=3.3 +FROM public.ecr.aws/docker/library/ruby:$RUBY_VERSION-alpine AS build-image ARG APP_ROOT="/app" ENV BUNDLE_APP_CONFIG="/app/.bundle" @@ -23,7 +24,7 @@ RUN mkdir -p tmp/pids RUN rm -rf vendor/bundle/ruby/*/cache/ && find vendor/ -name "*.o" -delete && find vendor/ -name "*.c" -FROM ruby:3.2-alpine +FROM public.ecr.aws/docker/library/ruby:$RUBY_VERSION-alpine ARG APP_ROOT="/app" ENV BUNDLE_APP_CONFIG="/app/.bundle" @@ -35,6 +36,6 @@ RUN apk update && \ apk add --update --no-cache build-base pcre-dev && \ gem install bundler -COPY --from=build-env $APP_ROOT $APP_ROOT +COPY --from=build-image $APP_ROOT $APP_ROOT CMD ["bundle", "exec", "ahn", "start", "--no-console"] From 9850b3ca73f5115457ab886ef671a51970fd56b1 Mon Sep 17 00:00:00 2001 From: David Wilkie Date: Thu, 30 May 2024 19:56:12 +0700 Subject: [PATCH 5/5] Enable YJIT --- components/app/Dockerfile | 2 ++ components/app/Gemfile.lock | 31 ++++++++++++++++--------------- 2 files changed, 18 insertions(+), 15 deletions(-) diff --git a/components/app/Dockerfile b/components/app/Dockerfile index dd0d9f4fd..f84bef642 100644 --- a/components/app/Dockerfile +++ b/components/app/Dockerfile @@ -38,4 +38,6 @@ RUN apk update && \ COPY --from=build-image $APP_ROOT $APP_ROOT +ENV RUBY_YJIT_ENABLE=true + CMD ["bundle", "exec", "ahn", "start", "--no-console"] diff --git a/components/app/Gemfile.lock b/components/app/Gemfile.lock index 9d91bccff..03720f04c 100644 --- a/components/app/Gemfile.lock +++ b/components/app/Gemfile.lock @@ -74,7 +74,7 @@ GIT GEM remote: https://rubygems.org/ specs: - activesupport (7.1.3.2) + activesupport (7.1.3.3) base64 bigdecimal concurrent-ruby (~> 1.0, >= 1.0.2) @@ -89,7 +89,7 @@ GEM adhearsion-loquacious (1.9.3) ast (2.4.2) aws-eventstream (1.3.0) - aws-partitions (1.929.0) + aws-partitions (1.936.0) aws-sdk-core (3.196.1) aws-eventstream (~> 1, >= 1.3.0) aws-partitions (~> 1, >= 1.651.0) @@ -124,7 +124,7 @@ GEM coderay (1.1.3) coercible (1.0.0) descendants_tracker (~> 0.0.1) - concurrent-ruby (1.2.3) + concurrent-ruby (1.3.1) connection_pool (2.4.1) countdownlatch (1.0.0) crack (1.0.0) @@ -160,7 +160,7 @@ GEM domain_name (~> 0.5) http-form_data (2.3.0) http_parser.rb (0.8.0) - i18n (1.14.4) + i18n (1.14.5) concurrent-ruby (~> 1.0) ice_nine (0.11.2) jmespath (1.6.2) @@ -175,8 +175,8 @@ GEM logging (2.3.1) little-plugger (~> 1.1) multi_json (~> 1.14) - method_source (1.0.0) - minitest (5.22.3) + method_source (1.1.0) + minitest (5.23.1) mock_redis (0.44.0) multi_json (1.15.0) mustermann (3.0.0) @@ -186,7 +186,7 @@ GEM uri niceogiri (1.1.2) nokogiri (~> 1.5) - nio4r (2.7.1) + nio4r (2.7.3) nokogiri (1.16.5-arm-linux) racc (~> 1.4) nokogiri (1.16.5-arm64-darwin) @@ -204,7 +204,7 @@ GEM method_source (~> 1.0) public_suffix (5.0.5) racc (1.8.0) - rack (3.0.10) + rack (3.0.11) rack-protection (4.0.0) base64 (>= 0.1.0) rack (>= 3.0.0, < 4) @@ -216,12 +216,12 @@ GEM rack (>= 3) webrick (~> 1.8) rainbow (3.1.1) - rake (13.1.0) + rake (13.2.1) redis (5.2.0) redis-client (>= 0.22.0) - redis-client (0.22.1) + redis-client (0.22.2) connection_pool - regexp_parser (2.9.0) + regexp_parser (2.9.2) rexml (3.2.8) strscan (>= 3.0.9) rspec (3.13.0) @@ -233,11 +233,11 @@ GEM rspec-expectations (3.13.0) diff-lcs (>= 1.2.0, < 2.0) rspec-support (~> 3.13.0) - rspec-mocks (3.13.0) + rspec-mocks (3.13.1) diff-lcs (>= 1.2.0, < 2.0) rspec-support (~> 3.13.0) rspec-support (3.13.1) - rubocop (1.63.4) + rubocop (1.64.0) json (~> 2.3) language_server-protocol (>= 3.17.0) parallel (~> 1.10) @@ -260,7 +260,7 @@ GEM rubocop-performance (1.21.0) rubocop (>= 1.48.1, < 2.0) rubocop-ast (>= 1.31.1, < 2.0) - rubocop-rails (2.24.0) + rubocop-rails (2.25.0) activesupport (>= 4.2.0) rack (>= 1.1) rubocop (>= 1.33.0, < 2.0) @@ -344,6 +344,7 @@ GEM PLATFORMS arm64-darwin-22 + arm64-darwin-23 arm64-linux x86_64-linux x86_64-linux-musl @@ -381,4 +382,4 @@ DEPENDENCIES webmock BUNDLED WITH - 2.5.6 + 2.5.11