Last active
March 9, 2024 18:49
-
-
Save brentkirby/2731e01ca3e0e4e21d34745e0abff7bc to your computer and use it in GitHub Desktop.
Create lambda layer from docker image
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh -e | |
mkdir -p "$DIST_DIR/lib" | |
mkdir -p "$DIST_DIR/ruby/gems" | |
docker build -t $CONTAINER_NAME -f Dockerfile . | |
CONTAINER=$(docker run -d ruby-builder) | |
# See https://northsail.io/articles/aws-lambda-ruby-2-7-pg-gem-libldap-error | |
docker cp \ | |
$CONTAINER:/usr/lib64/libpq.so.5.14 \ | |
$DIST_DIR/lib/libpq.so.5 | |
docker cp \ | |
$CONTAINER:/usr/lib64/libldap_r-2.4.so.2.10.7 \ | |
$DIST_DIR/lib/libldap_r-2.4.so.2 | |
docker cp \ | |
$CONTAINER:/usr/lib64/liblber-2.4.so.2.10.7 \ | |
$DIST_DIR/lib/liblber-2.4.so.2 | |
docker cp \ | |
$CONTAINER:/usr/lib64/libsasl2.so.3.0.0 \ | |
$DIST_DIR/lib/libsasl2.so.3 | |
docker cp \ | |
$CONTAINER:/usr/lib64/libssl3.so \ | |
$DIST_DIR/lib/ | |
docker cp \ | |
$CONTAINER:/usr/lib64/libsmime3.so \ | |
$DIST_DIR/lib/ | |
docker cp \ | |
$CONTAINER:/usr/lib64/libnss3.so \ | |
$DIST_DIR/lib/ | |
docker cp \ | |
$CONTAINER:/usr/lib64/libnssutil3.so \ | |
$DIST_DIR/lib/ | |
docker cp \ | |
$CONTAINER:/var/task/vendor/bundle/ruby/3.2.0 \ | |
$DIST_DIR/ruby/gems/3.2.0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM public.ecr.aws/sam/build-ruby3.2:latest-x86_64 | |
RUN yum install -y amazon-linux-extras && amazon-linux-extras enable postgresql14 | |
RUN yum install -y postgresql postgresql-devel build-essential | |
ADD Gemfile /var/task/Gemfile | |
ADD Gemfile.lock /var/task/Gemfile.lock | |
RUN bundle config set --local deployment true | |
RUN bundle install |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment