【问题标题】:Docker, Rails and Sidekiq - bundler: command not found: sidekiq - Running sidekiq as a separate containerDocker、Rails 和 Sidekiq - 捆绑器:找不到命令:sidekiq - 将 sidekiq 作为单独的容器运行
【发布时间】:2021-07-26 01:45:03
【问题描述】:

尝试使用 sidekiq 设置我的环境,已经有一个 redis 容器启动并运行。

但是当我尝试启动它时,sidekiq 容器给了我这个错误。

bundler: command not found: sidekiq Install missing gem executables with 'bundle install'

我的 docker-compose 文件:

    sidekiq:
      container_name: app-sidekiq
      build: .
      command: bundle exec sidekiq
      depends_on:
        - redis
      volumes:
        - .:/app
      env_file:
        - .env
      networks:
        - app-network

我的 .env 文件有: REDIS_URL=redis://limpar-api-redis:6380

我应用的 Gemfile 目前有 sidekiq gem。

当我进入我的应用容器 bash 并从中启动 sidekiq 时,它启动得很好。

Dockerfile

FROM ruby:2.7.1

ENV LANG C.UTF-8
ENV NODE_VERSION 12
ENV NODE_ENV production
ENV INSTALL_PATH /home/app/app/current

RUN curl -sL https://deb.nodesource.com/setup_$NODE_VERSION.x | bash -
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 -qq
RUN apt-get install -y --no-install-recommends nodejs postgresql-client yarn build-essential vim

RUN mkdir -p $INSTALL_PATH
WORKDIR $INSTALL_PATH

COPY Gemfile Gemfile.lock ./
RUN gem install bundler
RUN bundle install

COPY . $INSTALL_PATH

RUN rm -rf tmp

RUN useradd -Ms /bin/bash api -u 1001
RUN chown -R api:api /home/app /usr/local/bundle
USER root


EXPOSE 3100
CMD rails server -p 3100 -b 0.0.0.0

我的 docker 文件中缺少任何步骤吗?

【问题讨论】:

    标签: ruby-on-rails docker sidekiq


    【解决方案1】:

    在我看来,您的Dockerfile 中缺少bundle install 步骤。我建议分享所述文件的内容以帮助调试。

    【讨论】:

    • 感谢您抽出宝贵时间@Piotr Usewicz,将我的 docker 文件添加到问题中。不过,我确实有一个捆绑安装步骤。
    【解决方案2】:

    运行 docker-compose build --no-cache sidekiqdocker-compose build --no-cache app 为我修复了它!显然只需要重建它。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2012-09-11
      • 2022-12-03
      • 2016-08-11
      • 2017-03-08
      • 1970-01-01
      • 2021-07-09
      • 2018-08-29
      相关资源
      最近更新 更多