Skip to content

Commit

Permalink
refine uc3-ssm inclusion
Browse files Browse the repository at this point in the history
  • Loading branch information
terrywbrady committed Apr 11, 2024
1 parent 569ecb2 commit 1b85efd
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 10 deletions.
12 changes: 2 additions & 10 deletions mysql-ruby-lambda/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,23 +14,15 @@ RUN yum -y update && yum -y upgrade
# UC3 ruby code pulls a common gem from github for use in Lambda code.
RUN yum -y install mysql-devel gcc make git

RUN gem update bundler && \
git clone https://github.com/cdluc3/uc3-ssm.git && \
cd uc3-ssm && \
# pull a particular branch in order to build it
git checkout main && \
gem build uc3-ssm.gemspec && \
gem install uc3-ssm*.gem && \
cd ..
RUN gem update bundler

# Start with a Gemfile containing only MySQL
COPY * ./

RUN bundle config --local build.mysql2 --with-mysql2-config=/usr/lib64/mysql/mysql_config && \
bundle config --local silence_root_warning true && \
bundle config set path 'vendor/bundle' && \
bundle install && \
gem install uc3-ssm/uc3-ssm*.gem --install-dir vendor/bundle/ruby/3.2.0
bundle install

# This structure assumes the following:
# lambda_function.rb contains a module name LambdaFunctions which contains a class Handler
Expand Down
6 changes: 6 additions & 0 deletions mysql-ruby-lambda/lambda_function.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# frozen_string_literal: true

# Docs say that the LambdaLayer gems are found mounted as /opt/ruby/gems but an inspection
# of the $LOAD_PATH shows that only /opt/ruby/lib is available. So we add what we want here
# and indicate exactly which folders contain the *.rb files
my_gem_path = Dir['/var/task/vendor/bundle/ruby/**/bundler/gems/**/lib/']
$LOAD_PATH.unshift(*my_gem_path)

require 'json'
require 'uc3-ssm'
require 'mysql2'
Expand Down
6 changes: 6 additions & 0 deletions src-admintool/test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@
# docker build -t x .
# docker run --rm -it --entrypoint 'bundle' -e SSM_ROOT_PATH=... x exec ruby test.rb

# Docs say that the LambdaLayer gems are found mounted as /opt/ruby/gems but an inspection
# of the $LOAD_PATH shows that only /opt/ruby/lib is available. So we add what we want here
# and indicate exactly which folders contain the *.rb files
my_gem_path = Dir['/var/task/vendor/bundle/ruby/3.2.0/bundler/gems/**/lib/']
$LOAD_PATH.unshift(*my_gem_path)

require 'json'
require 'yaml'
require 'uc3-ssm'
Expand Down
2 changes: 2 additions & 0 deletions src-colladmin/config/ssm.registry.yml
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,8 @@ ui:
description: Byte count file size limit for direct upload through the Merritt UI
upload-limit-message:
description: Human readable byte count file size limit for direct upload through the Merritt UI
port:
description: Microservice port
integ-tests:
skip: true
for-stage: &inttest
Expand Down
6 changes: 6 additions & 0 deletions src-common/lambda_base.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# frozen_string_literal: true

# Docs say that the LambdaLayer gems are found mounted as /opt/ruby/gems but an inspection
# of the $LOAD_PATH shows that only /opt/ruby/lib is available. So we add what we want here
# and indicate exactly which folders contain the *.rb files
my_gem_path = Dir['/var/task/vendor/bundle/ruby/**/bundler/gems/**/lib/']
$LOAD_PATH.unshift(*my_gem_path)

require 'time'
require 'json'
require 'yaml'
Expand Down

0 comments on commit 1b85efd

Please sign in to comment.