AWS ElasticBeanstalk符号链接 [英] AWS ElasticBeanstalk Symlink
问题描述
我不想将config/database.yml文件放置在GITHUB中,而是将其放置在某处,并进行如下所示的符号链接
I don't want to place my config/database.yml file in GITHUB, rather to have it somewhere in the somewhere and do the symlink like below
config/databse.yml->/var/www/database.yml
config/databse.yml -> /var/www/database.yml
在.elasticbeanstalk/00packages.config中,我有以下内容
In the .elasticbeanstalk/00packages.config, I have following stuffs
commands:
# install WKHTML
03_command:
command: yum install xz urw-fonts libXext openssl-devel libXrender
04_command:
command: wget http://download.gna.org/wkhtmltopdf/0.12/0.12.3/wkhtmltox-0.12.3_linux-generic-amd64.tar.xz
05_command:
command: tar -xJf wkhtmltox-0.12.3_linux-generic-amd64.tar.xz
06_command:
command: cp wkhtmltox/bin/wkhtmltopdf /usr/local/bin/wkhtmltopdf
07_command:
command: cp wkhtmltox/bin/wkhtmltoimage /usr/local/bin/wkhtmltoimage
我可以在此处添加符号链接内容吗,并且可以正常工作
Can I add symlink stuff here and does it work
推荐答案
不幸的是,没有EB自定义配置允许您在部署应用程序之后执行操作.在运行 commands
时,您的应用程序仍位于/var/app/ondeck
中,因此,如果在/var/app/下创建符号链接当前
,当 ondeck
重命名为 current
时,它将被删除.
Unfortunately, none of the EB custom configurations allow you to perform operations after your application has been deployed. At the point at which commands
are run, your application is still in /var/app/ondeck
, so if you create a symlink under /var/app/current
, it will be deleted when ondeck
is renamed to current
.
我知道解决此限制的唯一方法是将文件放入 appdeploy/post
hooks目录.就您而言,它看起来像这样:
The only way around this limitation that I'm aware of is to put a file into the appdeploy/post
hooks directory. In your case, it would look something like this:
.ebextensions/01symlink.config
files:
"/opt/elasticbeanstalk/hooks/appdeploy/post/99_create_symlink.sh":
mode: "000755"
owner: root
group: root
content: |
#!/usr/bin/env bash
ln -sf /var/www/database.yml /var/app/current/config/database.yml
或者,您可以使用 commands
条目将文件从/var/www
复制到/var/app/ondeck
.
Alternately, you could use a commands
entry to copy the file from /var/www
to /var/app/ondeck
during the deploy.
这篇关于AWS ElasticBeanstalk符号链接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!