在AWS Elastic Beanstalk上使用Docker对资产进行预编译 [英] Assets Precompile with Docker on AWS Elastic Beanstalk

查看:127
本文介绍了在AWS Elastic Beanstalk上使用Docker对资产进行预编译的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在64位Amazon Linux/2.12.6上运行的Docker上运行Rails(4.2.10)应用程序.该应用程序已成功运行,但是资产管道未运行.奇怪的是,我没有收到我看到的任何错误消息.

I'm running a rails (4.2.10) application on Docker running on 64bit Amazon Linux/2.12.6. The application is running successfully, however, the asset pipeline is not. Oddly, I'm not receiving any error messages that I can see.

此外,app/public/assets中有资产

Furthermore, there are assets in app/public/assets

例如,此.css文件存在:

For example this .css file exists:

<link rel="stylesheet" media="all" href="assets/application-e627105c73433d07311d93ea3e4f53942589150887a45432397a6b1e80017a2e.css">

Dockerfile:

Dockerfile:

FROM ruby:2.4.2

ENV APP_HOME /app
ENV RAILS_ENV production
ENV RACK_ENV production
ENV SECRET_KEY_BASE 39c3bae00bf53ba9e3...

RUN apt-get update -qq && apt-get install -y --no-install-recommends build-essential
RUN apt-get install -y mysql-client
RUN apt-get install -y libxml2-dev libxslt1-dev
RUN apt-get install -y libqtwebkit4 libqt4-dev xvfb
RUN apt-get install -y nodejs
RUN apt-get clean autoclean \
  && apt-get autoremove -y \
  && rm -rf \
    /var/lib/apt \
    /var/lib/dpkg \
    /var/lib/cache \
    /var/lib/log

RUN mkdir $APP_HOME
RUN mkdir $APP_HOME/tmp
WORKDIR $APP_HOME

ADD Gemfile* $APP_HOME/
RUN (bundle check || bundle install --without development test)

ADD . $APP_HOME

# NOTE: handles migrations (or db:setup if needed)
ENTRYPOINT ["sh", "script/docker/entrypoint.sh"]

RUN bundle exec rake assets:precompile --trace
VOLUME /app/public

EXPOSE 3000

CMD ["script/rails", "s", "-b", "0.0.0.0"]

如果您需要进一步的说明或希望查看其他内容,请告诉我.

Please let me know if you need further explanation or want to see anything else.

推荐答案

您需要在config/environments/production.rb中添加config.public_file_server.enabled = true,或者您可以使用

You need to add config.public_file_server.enabled = true in your config/environments/production.rb, or you can achieve that with an environment variable like that.

但是,您可能希望在Ruby应用程序服务器之前运行Web服务器,因此您需要检查我们的反向代理.

However, you might want to run a web server in front of your Ruby application server, so you need to check our Reverse Proxies.

这篇关于在AWS Elastic Beanstalk上使用Docker对资产进行预编译的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆