问题
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.
Furthermore, there are assets in app/public/assets
For example this .css file exists:
<link rel="stylesheet" media="all" href="assets/application-e627105c73433d07311d93ea3e4f53942589150887a45432397a6b1e80017a2e.css">
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.
回答1:
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.
However, you might want to run a web server in front of your Ruby application server, so you need to check our Reverse Proxies.
来源:https://stackoverflow.com/questions/54333647/assets-precompile-with-docker-on-aws-elastic-beanstalk