部署时 EFS 符号链接失败
EFS symlink fails while deploying
所以我使用 AWS Elastic Beanstalk 来为我的 PHP 应用程序提供服务。我想挂载 EFS 以永久存储通过我的应用程序上传的图像。
我创建了 .ebextensions 文件夹并使用以下代码创建了一个名为 mount.config 的文件
packages:
yum:
nfs-utils: []
jq: []
files:
"/tmp/mount-efs.sh" :
mode: "000755"
content: |
#!/usr/bin/env bash
mkdir -p /mnt/efs
EFS_NAME=$(/opt/elasticbeanstalk/bin/get-config environment | jq -r '.EFS_NAME')
mount -t nfs4 -o nfsvers=4.1,rsize=1048576,wsize=1048576,hard,timeo=600,retrans=2 $EFS_NAME:/ /mnt/efs || true
mkdir -p /mnt/efs/questions
chown webapp:webapp /mnt/efs/questions
commands:
01_mount:
command: "/tmp/mount-efs.sh"
container_commands:
01-symlink-uploads:
command: ln -s /mnt/efs/questions /var/app/ondeck/images/
一切正常,直到最后一行未能创建符号链接。
到目前为止我尝试过的:
- 运行命令直接在机器上同时改变ondeck -> current。这很好用。
- 正在删除 EC2 实例并添加一个新实例。仍然失败
在我看到的日志中
ln: failed to create symbolic link '/var/app/current/images/questions': No such file or directory
任何建议可能是什么原因?
好的,我通过将 ondeck 替换为 staging
来修复它
并在 container_commands 下添加此行:
01-change-permission:
command: chmod -R 777 /var/app/staging/images
所以我使用 AWS Elastic Beanstalk 来为我的 PHP 应用程序提供服务。我想挂载 EFS 以永久存储通过我的应用程序上传的图像。 我创建了 .ebextensions 文件夹并使用以下代码创建了一个名为 mount.config 的文件
packages:
yum:
nfs-utils: []
jq: []
files:
"/tmp/mount-efs.sh" :
mode: "000755"
content: |
#!/usr/bin/env bash
mkdir -p /mnt/efs
EFS_NAME=$(/opt/elasticbeanstalk/bin/get-config environment | jq -r '.EFS_NAME')
mount -t nfs4 -o nfsvers=4.1,rsize=1048576,wsize=1048576,hard,timeo=600,retrans=2 $EFS_NAME:/ /mnt/efs || true
mkdir -p /mnt/efs/questions
chown webapp:webapp /mnt/efs/questions
commands:
01_mount:
command: "/tmp/mount-efs.sh"
container_commands:
01-symlink-uploads:
command: ln -s /mnt/efs/questions /var/app/ondeck/images/
一切正常,直到最后一行未能创建符号链接。
到目前为止我尝试过的:
- 运行命令直接在机器上同时改变ondeck -> current。这很好用。
- 正在删除 EC2 实例并添加一个新实例。仍然失败
在我看到的日志中
ln: failed to create symbolic link '/var/app/current/images/questions': No such file or directory
任何建议可能是什么原因?
好的,我通过将 ondeck 替换为 staging
来修复它并在 container_commands 下添加此行:
01-change-permission:
command: chmod -R 777 /var/app/staging/images