Skip to content

Commit

Permalink
fix: Use the SAM build images to build image based Ruby functions (#503)
Browse files Browse the repository at this point in the history
* Install dev tools before running bundle in image

* The command is remove, not uninstall

* Use build images instead of installing tools in runtime environment

* Remove duplicate comment
  • Loading branch information
lucashuy authored Jun 5, 2024
1 parent 653b808 commit 58e4304
Showing 1 changed file with 16 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,9 +1,23 @@
FROM public.ecr.aws/lambda/ruby:{{ cookiecutter.options[cookiecutter.runtime].version }}
# building phase
#
FROM public.ecr.aws/sam/build-ruby{{ cookiecutter.options[cookiecutter.runtime].version }} as build-image

ARG SCRATCH_DIR=/var/task/build

ENV GEM_HOME=${SCRATCH_DIR}

COPY app.rb Gemfile ./
RUN bundle install
RUN cp -r ${GEM_HOME}/* .
RUN rm -r ${GEM_HOME}

# runtime emulation phase
#
FROM public.ecr.aws/lambda/ruby:{{ cookiecutter.options[cookiecutter.runtime].version }}

ENV GEM_HOME=${LAMBDA_TASK_ROOT}
RUN bundle install

COPY --from=build-image /var/task/ ./

# Command can be overwritten by providing a different command in the template directly.
CMD ["app.lambda_handler"]

0 comments on commit 58e4304

Please sign in to comment.