我试图运行docker-compose up,但在这一行运行入口点时:bundle exec rake assets:precompile RAILS_ENV=production
错误是:Node.js not installed. Please download and install Node.js https://nodejs.org/en/download/
我的Dockerfile安装了node,所以我不确定是什么问题。
我尝试了很多不同的Docker文件设置,总是得到同样的错误。有谁知道我怎么修吗?先谢了。
Docker文件:
# syntax=docker/dockerfile:1
FROM ruby:3.0.4
ENV NODE_OPTIONS="--openssl-legacy-provider"
RUN apt-get update -qq && \
apt-get install -y nodejs postgresql-client python curl apt-transport-https && \
curl -fsSL https://deb.nodesource.com/setup_14.x | bash - && \
apt-get install -y nodejs && \
curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add - && \
echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list && \
apt-get update && \
apt-get install -y yarn
WORKDIR /eclipse
COPY Gemfile /eclipse/Gemfile
COPY Gemfile.lock /eclipse/Gemfile.lock
RUN bundle install
RUN echo "Install webpacker ----"
RUN bundle exec rails webpacker:install \
rails webpacker:compile
# Entrypoint.sh will be run every time the container starts.
COPY /bin/entrypoint.sh /usr/bin/
RUN chmod +x /usr/bin/entrypoint.sh
ENTRYPOINT ["entrypoint.sh"]
EXPOSE 3000
# Configure the main process to run when running the image
CMD ["rails", "server", "-b", "0.0.0.0"]
entrypoint.sh
#!/bin/bash
set -e
echo "Compile assets ----"
bundle exec rake assets:precompile RAILS_ENV=production
echo "Create database ----"
bundle exec rake db:create
echo "Rake database ----"
bundle exec rake db:migrate
# Remove a potentially pre-existing server.pid for Rails.
rm -f /app/tmp/pids/server.pid
# Then exec the container's main process (what's set as CMD in the Dockerfile).
exec "$@"
1条答案
按热度按时间vi4fp9gy1#
当面对这样的事情时,我通常会从失败的一行向前评论一切。然后我启动Docker容器,并尝试执行我注解掉的第一个东西。这通常会指明方向。
结果往往是我安装了一个我没有预料到的古老版本。当然,您要安装的是节点14 -此时它已经相当长了。
在你的具体情况下,我建议放弃webpacker,如果这是一个新的应用程序。如果它是一个现有的应用程序,我建议迁移到https://github.com/shakacode/shakapacker-这至少是有点维护和更新。