lamby icon indicating copy to clipboard operation
lamby copied to clipboard

Had to fix bin/deploy script due to GLIBC 2.33 not found error.

Open randall-coding opened this issue 1 year ago • 1 comments

MY SETUP: OS: Linux Mint 21 GLIBC 2.35 Dockerfile Image: ruby:3.1.4-bullseye (which has GLIBC 2.31)

STEPS TO REPRODUCE Dockerize existing rails app make docker/build Add template.yaml .bin/deploy (taken from cookiecutter)

ERROR (Cloud Watch logs) "errorMessage": "/lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.33' not found (required by /app/vendor/bundle/ruby/3.1.0/gems/bootsnap-1.18.3/lib/bootsnap/bootsnap.so) - /app/vendor/bundle/ruby/3.1.0/gems/bootsnap-1.18.3/lib/bootsnap/bootsnap.so",

MY FIX I noticed that the deploy script is bundling all the gems again outside of the image on my host machine which uses a different GLIBC version. I don't know the significance of this or why it is needed (please let me know as I'm new to SAM). However I was able to deploy without error by removing the bundle install lines in bin/deploy like so:

# echo '== Bundle For Deployment ==' # bundle config --global silence_root_warning true # bundle config --local deployment true # bundle config --local without 'development test' # bundle config --local path './vendor/bundle' # bundle install --quiet --jobs 4

Afterwards I'm able to deploy my lambda without any noticeable issue yet.

What do the devs think of this fix? Am I on to something here or should that bundle install be called on my host machine rather than just inside the Dockerfile?

randall-coding avatar Mar 08 '24 07:03 randall-coding

Here is my Dockerfile.

FROM ruby:3.1.4-bullseye

RUN gem install 'aws_lambda_ric' ENTRYPOINT [ "/usr/local/bundle/bin/aws_lambda_ric" ]

RUN mkdir /app
&& groupadd -g 10001 app
&& useradd -u 10000 -g app app
&& chown -R app:app /app

RUN apt update
&& apt upgrade -y
&& apt install -y --no-install-recommends
tzdata
git
openssh-client
make
gcc
g++
default-libmysqlclient-dev
libxrender1
build-essential
libpq-dev
curl
socat
ca-certificates
gnupg
libc6

RUN echo "DEBUGGING..." RUN ldd --version

USER app WORKDIR "/app"

ENV BUNDLE_IGNORE_CONFIG=1 ENV BUNDLE_PATH=./vendor/bundle ENV BUNDLE_CACHE_PATH=./vendor/cache ENV RAILS_SERVE_STATIC_FILES=1 COPY --chown=app:app Gemfile ./ RUN bundle install COPY --chown=app:app . . CMD ["config/environment.Lamby.cmd"]

randall-coding avatar Mar 08 '24 07:03 randall-coding

bundle install is needed to run precompile or run db:migrate. If you do not need to do either of these things then there is no reason to do a bundle install in bin/deploy. Also in the cookie cutter he is running bundle install and coping over the bundle cache which makes the lambda quicker. Im not sure how he got that part to work in arm64 so im doing a bundle install in my Dockerfile

jeremiahlukus avatar Jun 03 '24 14:06 jeremiahlukus