且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

无法在AWS Lambda上加载文件mysql2

更新时间:2023-01-22 13:11:49

先决条件: * Docker

Prerequesties: * Docker

创建这样的docker文件

Create a docker file like this

    FROM lambci/lambda:build-ruby2.5
    RUN yum -y install mysql-devel
    RUN gem update bundler
    CMD "/bin/bash"

构建Docker

    docker build -t lambda-ruby2.5-mysqldep .

Docker使用以下命令在您的源代码文件夹中运行

Docker run in your source code folder with the below command

    docker run --rm -it -v $PWD:/var/task -w /var/task lambda-ruby2.5-mysqldep

这会让您陷入重击 在bash内

It will get you into the bash Inside the bash

  • 将mysql文件夹从/usr/lib64/mysql移至/usr/mysql
  • mkdir -p/var/task/lib
  • cp -a/usr/mysql/.so./var/task/lib/
  • 捆绑配置--local build.mysql --with-mysql-config =/usr/local/mysql/bin/mysql_config
  • 捆绑安装(带部署和不带部署)
  • move the mysql folder from /usr/lib64/mysql to /usr/mysql
  • mkdir -p /var/task/lib
  • cp -a /usr/mysql/.so. /var/task/lib/
  • bundle config --local build.mysql --with-mysql-config=/usr/local/mysql/bin/mysql_config
  • bundle install with and without deployment

然后退出重击.然后创建一个lambda部署程序包,并将其上传到AWS.它对我有用

Then exit the bash. And create a lambda deployment package and upload it to AWS. It worked for me