AWS lambda上的纱线?
是否有人设法获得 yarn 安装并在AWS lambda上工作?
(我正在尝试创建一个可以构建小反应项目的函数)
目前,我已经在Docker映像中安装了纱线并工作(基于public.ecr.aws/lambda/provided:al2),但是在Lambda中运行它时纱线试图访问只读文件系统时,我会遇到权限错误。
Dockerfile摘要:
FROM public.ecr.aws/lambda/provided:al2
...
# Update yum
RUN yum -y update
# Install NodeJS
RUN curl -fsSL https://rpm.nodesource.com/setup_16.x \
| bash - && yum -y install nodejs
# Install Yarn
RUN curl -fsSL https://dl.yarnpkg.com/rpm/yarn.repo \
| tee /etc/yum.repos.d/yarn.repo && \
rpm --import https://dl.yarnpkg.com/rpm/pubkey.gpg && \
yum -y install yarn
# Copy Binaries
RUN cp -r \
/usr/share/yarn/bin/* \
/usr/bin/corepack /usr/bin/node /usr/bin/npm /usr/bin/npx \
/opt/bin/
# Copy Libraries
RUN cp -r \
/usr/share/yarn/lib/* \
/usr/lib/node_modules \
/opt/lib/
# Configure NPM & Yarn
RUN npm config set prefix /tmp/npm/
RUN yarn config set prefix /tmp/yarn/
...
错误:
>yarn install
warning Cannot find a suitable global folder. Tried these: "/usr/local, /home/sbx_user1051/.yarn"
ovl: Error while doing RPMdb copy-up:
[Errno 30] Read-only file system: '/var/lib/rpm/.dbenv.lock'
Could not set cachedir: [Errno 30] Read-only file system: '/var/tmp/yum-sbx_user1051-eC5Oqk'
Error making cache directory: /var/cache/yum/x86_64/2/amzn2-core error was: [Errno 30] Read-only file system: '/var/cache/yum'
error Command failed with exit code 1.
***编辑***
带有全局标志
>yarn --global-folder /tmp/yarn/ install
warning Skipping preferred cache folder "/home/sbx_user1051/.cache/yarn" because it is not writable.
warning Selected the next writable cache folder in the list, will be "/tmp/.yarn-cache-993".
warning Cannot find a suitable global folder. Tried these: "/usr/local, /home/sbx_user1051/.yarn"
ovl: Error while doing RPMdb copy-up:
[Errno 30] Read-only file system: '/var/lib/rpm/.dbenv.lock'
Could not set cachedir: [Errno 30] Read-only file system: '/var/tmp/yum-sbx_user1051-3FcZxd'
Error making cache directory: /var/cache/yum/x86_64/2/amzn2-core error was: [Errno 30] Read-only file system: '/var/cache/yum'
error Command failed with exit code 1.
Did anyone manage to get yarn installed and working on AWS Lambda?
(I'm trying to create a function that can build small React projects)
Currently I have yarn installed and working in a Docker image (based on public.ecr.aws/lambda/provided:al2), but while running it in the Lambda environment I'm getting permission errors when yarn tries to access the read-only file system.
Dockerfile snippet:
FROM public.ecr.aws/lambda/provided:al2
...
# Update yum
RUN yum -y update
# Install NodeJS
RUN curl -fsSL https://rpm.nodesource.com/setup_16.x \
| bash - && yum -y install nodejs
# Install Yarn
RUN curl -fsSL https://dl.yarnpkg.com/rpm/yarn.repo \
| tee /etc/yum.repos.d/yarn.repo && \
rpm --import https://dl.yarnpkg.com/rpm/pubkey.gpg && \
yum -y install yarn
# Copy Binaries
RUN cp -r \
/usr/share/yarn/bin/* \
/usr/bin/corepack /usr/bin/node /usr/bin/npm /usr/bin/npx \
/opt/bin/
# Copy Libraries
RUN cp -r \
/usr/share/yarn/lib/* \
/usr/lib/node_modules \
/opt/lib/
# Configure NPM & Yarn
RUN npm config set prefix /tmp/npm/
RUN yarn config set prefix /tmp/yarn/
...
Errors:
>yarn install
warning Cannot find a suitable global folder. Tried these: "/usr/local, /home/sbx_user1051/.yarn"
ovl: Error while doing RPMdb copy-up:
[Errno 30] Read-only file system: '/var/lib/rpm/.dbenv.lock'
Could not set cachedir: [Errno 30] Read-only file system: '/var/tmp/yum-sbx_user1051-eC5Oqk'
Error making cache directory: /var/cache/yum/x86_64/2/amzn2-core error was: [Errno 30] Read-only file system: '/var/cache/yum'
error Command failed with exit code 1.
*** edit ***
With global flag
>yarn --global-folder /tmp/yarn/ install
warning Skipping preferred cache folder "/home/sbx_user1051/.cache/yarn" because it is not writable.
warning Selected the next writable cache folder in the list, will be "/tmp/.yarn-cache-993".
warning Cannot find a suitable global folder. Tried these: "/usr/local, /home/sbx_user1051/.yarn"
ovl: Error while doing RPMdb copy-up:
[Errno 30] Read-only file system: '/var/lib/rpm/.dbenv.lock'
Could not set cachedir: [Errno 30] Read-only file system: '/var/tmp/yum-sbx_user1051-3FcZxd'
Error making cache directory: /var/cache/yum/x86_64/2/amzn2-core error was: [Errno 30] Read-only file system: '/var/cache/yum'
error Command failed with exit code 1.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论