为了正常访问 public 目录下的静态文件,修改配置 /config/environments/production.rb
中:
config.public_file_server.enabled = true
而且要注意检查文件中下方是否有地方再次赋值此变量
部署正式环境需要配置 assets.compile 为 false
config.assets.compile = true
并且提前运行 precompile
rails assets:precompile
运行 rails assets:precompile 前要安装 node 和 yarn:
nodejs [ http://www.laozuo.org/10792.html ]
RUN apt-get update -y
RUN apt-get install -y build-essential curl
RUN curl -sL https://deb.nodesource.com/setup_8.x | bash -
RUN apt-get install nodejs
yarn [ https://yarnpkg.com/lang/en/docs/install/#linux-tab ]
RUN curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add -
RUN echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list
RUN apt-get update && apt-get install yarn
网友评论