stevenringo / lambda-ruby-pg-nokogiri

How to ensure binary dependencies are available for gems such as pg (postgres) and nokogiri are configured correctly in Ruby on AWS Lambda
28 stars 7 forks source link

Error during Docker build #4

Open ejstembler opened 4 years ago

ejstembler commented 4 years ago

Getting this error during Docker build:

Error: Package: pgdg-redhat-repo-42.0-5.noarch (/pgdg-redhat10-10-2.noarch)
           Requires: /etc/redhat-release

Here's the full output:

docker build -t lambda-ruby2.5-postgresql10 .
Sending build context to Docker daemon  10.75kB
Step 1/6 : FROM lambci/lambda:build-ruby2.5
build-ruby2.5: Pulling from lambci/lambda
c10bc2510050: Pull complete 
fa535c6d8b41: Pull complete 
b17a5543c497: Pull complete 
ff5b96d65dff: Pull complete 
Digest: sha256:eb71bf94bc332928bdfd66868107cce7cbdf9ba9c361ce2d9e042352244d5a80
Status: Downloaded newer image for lambci/lambda:build-ruby2.5
 ---> 807020d3e4f6
Step 2/6 : RUN yum install -y     https://download.postgresql.org/pub/repos/yum/10/redhat/rhel-6-x86_64/pgdg-redhat10-10-2.noarch.rpm
 ---> Running in b8f25f6964f0
Loaded plugins: ovl, priorities
Examining /var/tmp/yum-root-mDWiCr/pgdg-redhat10-10-2.noarch.rpm: pgdg-redhat-repo-42.0-5.noarch
Marking /var/tmp/yum-root-mDWiCr/pgdg-redhat10-10-2.noarch.rpm to be installed
Resolving Dependencies
--> Running transaction check
---> Package pgdg-redhat-repo.noarch 0:42.0-5 will be installed
--> Processing Dependency: /etc/redhat-release for package: pgdg-redhat-repo-42.0-5.noarch
--> Processing Dependency: /etc/redhat-release for package: pgdg-redhat-repo-42.0-5.noarch
--> Finished Dependency Resolution
 You could try using --skip-broken to work around the problem
Error: Package: pgdg-redhat-repo-42.0-5.noarch (/pgdg-redhat10-10-2.noarch)
           Requires: /etc/redhat-release
 You could try running: rpm -Va --nofiles --nodigest
The command '/bin/sh -c yum install -y     https://download.postgresql.org/pub/repos/yum/10/redhat/rhel-6-x86_64/pgdg-redhat10-10-2.noarch.rpm' returned a non-zero code: 1
mlsaito commented 4 years ago

Getting the same error.

nir0 commented 4 years ago

same here

nir0 commented 4 years ago

guys, i was able to install pg gem following this guide: https://stackoverflow.com/questions/54330779/how-to-correctly-load-a-gem-extension-in-aws-lambda

with some changement it works for me like this:

# Dockerfile
FROM lambci/lambda:build-ruby2.5

RUN yum install -y postgresql-devel postgresql
RUN gem update bundler

ADD Gemfile /var/task/Gemfile
ADD Gemfile.lock /var/task/Gemfile.lock

RUN bundle install --path /var/task/vendor/bundle --clean

maybe i also ran RUN yum update -y if that changed anything, i donno

# build.sh
set -e

rm -rf lib && rm -rf vendor && mkdir lib && mkdir vendor

docker build -t lambda-ruby2.5-postgresql10x -f Dockerfile .

CONTAINER=$(docker run -d lambda-ruby2.5-postgresql10x false)

docker cp \
    $CONTAINER:/var/task/vendor/ \
    ./

docker cp \
    $CONTAINER:/usr/lib64/libpq.so.5.5 \
    lib/libpq.so.5

# docker cp \
#     $CONTAINER:/usr/lib64/mysql/. \
#     lib/

docker rm $CONTAINER

hope this helps