Docker Compose 捆绑包安装失败

问题描述 投票:0回答:1

我正在从 Github CodeSpaces 的容器内调用

docker-compose run web bundle install --jobs=8
。该命令失败并出现以下错误:

Retrying fetcher due to error (2/4): Bundler::HTTPError Could not fetch specs from https://enterprise.contribsys.com/ due to underlying error 

我尝试通过命令调用获取的任何 gem 都会发生这种情况。当我在容器内运行捆绑安装时,它可以工作。

Dockerfile:

FROM ruby:3.1.4-slim

RUN set -eux; \
    apt-get update; \
    apt-get install -y --no-install-recommends \
    docker.io \
    gnupg \
    build-essential \
    git \
    pkg-config \
    libvips \
    curl \
    node-gyp \
    libpq-dev \
    shared-mime-info \
    ffmpeg \
    tzdata \
    net-tools \
    awscli \
    jq \
    python3-full \
    python3-pip \
    python3.11-venv \
    docker-compose \
    ; \
    rm -rf /var/lib/apt/lists/*

ENV SOPS_VERSION 3.7.3

RUN curl -LO https://github.com/getsops/sops/releases/download/v${SOPS_VERSION}/sops-v${SOPS_VERSION}.linux.amd64 && \
    mv sops-v${SOPS_VERSION}.linux.amd64 /usr/local/bin/sops && \
    chmod +x /usr/local/bin/sops

# Install node
ARG NODE_VERSION=16.15.0
ARG YARN_VERSION=1.22.19
ENV PATH=/usr/local/node/bin:$PATH
RUN curl -sL https://github.com/nodenv/node-build/archive/master.tar.gz | tar xz -C /tmp/ && \
    /tmp/node-build-master/bin/node-build "${NODE_VERSION}" /usr/local/node && \
    npm install -g yarn@$YARN_VERSION && \
    rm -rf /tmp/node-build-master

WORKDIR /redacted

# specify bundle location so we can use a volume to store installed gems
ENV BUNDLE_PATH=/bundle
ENV BUNDLE_BIN=/bundle/bin
ENV GEM_HOME=/bundle
ENV PATH="${BUNDLE_BIN}:${PATH}"

# ARG SIDEKIQ_KEY
RUN bundle config gems.contribsys.com $SIDEKIQ_KEY
RUN bundle config enterprise.contribsys.com $SIDEKIQ_KEY

RUN gem install bundler -v 2.4.6 --no-document && bundle config set frozen 'true'

COPY Gemfile .
COPY Gemfile.lock .
RUN MAKE="make --jobs=$(nproc)" bundle install

# ARG NPMRC
RUN test -n "NPMRC" || (echo "Must run 'export NPMRC=\$(cat ~/.npmrc|base64)' before building image to install private yarn packages" && exit 1)
RUN sh -c 'echo NPMRC| base64 -d > ~/.npmrc'

COPY package.json  .
COPY yarn.lock .
COPY .npmrc .

RUN yarn install --frozen-lockfile --non-interactive --no-progress

docker-compose.yml

version: '3.9'
services:
  web:
    command: bundle exec rdbg --open --host 0.0.0.0 --port 12345 --nonstop --command -- puma --port 80 --bind tcp://0.0.0.0 --threads 4 --workers 1
    build:
      context: .
      args:
        - "NPMRC=redacted"
    working_dir: /redacted
    volumes:
      - .:/redacted
      - bundle-cache:/bundle # so bundle installed gems can be cached
      - yarn-cache:/usr/local/share/.cache/yarn/v6 # so yarn's global cache persists
      - webpack-data:/redacted/public/packs # persist data even if container shuts down
      - node-modules:/redacted/node_modules # share node_modules
      # let container have the following all to itself
      - /redacted/public/packs-test # might be able to deprecate this requirement?
      - /redacted/public/javascripts/i18n # maybe should never have been checked in to repo?
      - /redacted/tmp # because rails is dirty with pid files sometimes, also doing this for tmp is probably a good call anyway
    ports:
      - "80:${redacted:-80}" # web server
      - "12345:12345"
    environment:
      BUNDLE_GEMS__CONTRIBSYS__COM: redacted
      BUNDLE_ENTERPRISE__CONTRIBSYS__COM: redacted
      DATABASE_HOST: db
      DATABASE_NAME: redacted
      DATABASE_USER: redacted
      LAUNCH_DARKLY_USER_ID: redacted
      redacted_HOSTS: hogwarts.redacted.local # pass through for development.rb hosts config
      PAGER: busybox less # otherwise pry gem uses some unavailable flags for the environment
      PIDFILE: /dev/null
      REDIS_HOST: redis
      REDIS_PORT: 6379
      REDIS_URL_SIDEKIQ: redis://redis:6379/1
      WEBPACKER_DEV_SERVER_HOST: webpack
      SMTP_ADDRESS: mail
    tty: true
    stdin_open: true
    networks:
      default:
        aliases:
          - app.redacted.test

volumes:
  database-data: # named volumes can be managed easier using docker-compose
  webpack-data: # named volumes can be managed easier using docker-compose
  bundle-cache: # to cache bundled gems
  node-modules: # to cache node modules
  yarn-cache: # to cache yarn's global cache
  caddy_data: # For caddy's persisted data

宝石文件

source 'https://rubygems.org'
ruby '~> 3.1'

source 'https://enterprise.contribsys.com/' do
  gem 'sidekiq-pro'

  # Include the enterprise version after pro
  gem 'sidekiq-ent'
end

gem 'active_hash', '~> 3.2'
gem 'activerecord-import', '~> 1.5'
gem 'acts-as-taggable-on', '~> 9.0' # Revisit @ Rails 6 and 7 upgrade
gem 'addressable', '~> 2.8'
gem 'algoliasearch-rails', '~> 2.2'
gem 'autoprefixer-rails', '~> 10.4'
gem 'aws-sdk-core', '~> 3.181'
gem 'aws-sdk-elastictranscoder', '~> 1.45'
gem 'aws-sdk-rds', '~> 1.192'
gem 'aws-sdk-s3', '~> 1.134'
gem 'bamboo-id', '~> 0.1.3', require: 'bamboo_id'
gem 'bcrypt', '~> 3.1'
gem 'bootsnap', '~> 1.16', require: false
gem 'browser', '~> 5.3'
gem 'carrierwave', '1.3.2' 
gem 'chunky_png', '~> 1.4'
gem 'composite_primary_keys', '~> 14.0'
gem 'counter_culture', '~> 3.5'
gem 'd3_rails', '~> 4.1'
gem 'daemons', '~> 1.4'
gem 'ddtrace', '~> 1.14'
gem 'dogstatsd-ruby'
gem 'embedly', '~> 1.9'
gem 'faraday', '~> 1.10'    # @TODO: add https://rubygems.org/gems/faraday-follow_redirects; update where FaradayMiddleware::FollowRedirects is used
gem 'faraday-cookie_jar', '~> 0.0.7'
gem 'fog-aws', '~> 3.19'
gem 'google-api-client', '~> 0.53.0', require: 'google/apis/calendar_v3'
gem 'henkei', '~> 2.6' # A beast. @TODO: consider simple_text_extract
gem 'htmlentities', '~> 4.3'
gem 'html_to_plain_text', '~> 1.0'
gem 'httparty', '~> 0.21.0'
gem 'i18n-js', '~> 3.9'
gem 'icalendar', '~> 2.9'
gem 'ice_cube', '~> 0.16.4'
gem 'image_processing', '~> 1.12'
gem 'json', '~> 2.6'
gem 'jsonapi-serializer'
gem 'jwt', '~> 2.7'
gem 'launchdarkly_api'
gem 'launchdarkly-server-sdk', '6.4.0'
gem 'logidze', '~> 0.12.0' # @TODO needs work to migrate past 1.0 - 0.12 does support Rails 6
gem 'lograge', '~> 0.13.0'
gem 'loofah', '~> 2.19'
gem 'mini_magick', '~> 4.12'
gem 'mini_portile2', '~> 2.8.1'
gem 'money', '~> 6.16'
gem 'net-sftp', '~> 4.0'
gem 'nokogiri', '~> 1.15'
gem 'omniauth', '~> 1.9' # blocked primarily by omniauth-stripe-connect which is abandoned since '19
gem 'omniauth-google-oauth2', '~> 0.8.2' # Set to '~> 1.0' if omniauth-stripe-connect ever allows us to go to omniauth 2.x
gem 'omniauth-salesforce', '~> 1.0'
gem 'omniauth-stripe-connect', '~> 2.10'
gem 'pagy', '~> 5.10'
gem 'paper_trail', '~> 14.0'
gem 'paranoia', '~> 2.6'
gem 'pg', '~> 1.4.5'    # Not Semver, check changelog before updating
gem 'premailer-rails', '~> 1.12'
gem 'puma', '~> 6.3.1'
gem 'pundit', '~> 2.3'
gem 'rack', '~> 2.2'
gem 'rack-cors', '~> 2.0'
gem 'rails', '~> 7.0.5' # Not Semver, check changelog before updating
gem 'rb-readline', '~> 0.5.5'
gem 'react_on_rails', '~> 11.3' # Revisit @ Rails 6 and 7 upgrade
gem 'redis', '~> 5.0'
gem 'redlock', '~> 1.3'
gem 'rest-client', '~> 2.1'
gem 'restforce', '~> 5.2'
gem 'ruby-openai', '~> 4.1.0'
gem 'ruby-saml', '~> 1.15'
gem 'rubyzip', '~> 2.3' # @TODO: Allowing v3 when it comes out should be safe
gem 'rustici_software_cloud_v2', '~> 2.0'
gem 'salesforce_bulk_api', '~> 1.0'
gem 'sanitize', '~> 6.0'
gem 'sassc-rails', '~> 2.1'
gem 'savon', '~> 2.14'
gem 'sendgrid-ruby', '~> 6.6'
gem 'smarter_csv', '~> 1.8'
gem 'sprockets', '~> 4.2'
gem 'sprockets-rails', '~> 3.4'
gem 'string-undump', '~> 0.0.2.1'
gem 'stripe', '~> 5.48'
gem 'strong_migrations', '~> 1.6'
gem 'terser', '~> 1.1'
gem 'turnout', '~> 2.5'
gem 'twilio-ruby', '~> 5.77'
gem 'tzinfo-data', '~> 1.2023'
gem 'uuidtools', '~> 2.2'
gem 'waypoints_rails', '~> 4.0'
gem 'webpacker', '~> 5.4'
gem 'websocket-extensions', '~> 0.1.5'
gem 'whenever', '~> 1.0'
gem 'wisper', '~> 2.0'
gem 'wisper-activejob', '~> 1.0'
gem 'xml-simple', '~> 1.1'
gem 'Ziggeo', '~> 2.30'

# Adding coverband here because it must be after rails
gem 'coverband', '~> 5.2'

group :development do
  gem 'colorize', require: 'colorized_string'
  gem 'letter_opener', '~> 1.8'
  gem 'listen', '~> 3.8'
  gem 'web-console', '~> 4.2'
end

group :development, :test do
  gem 'brakeman', '~> 6.0'
  gem 'bullet', '~> 7.0'
  gem 'bundle-audit'
  gem 'capybara', '~> 3.39'
  gem 'climate_control', '~> 1.2'
  gem 'database_cleaner', '~> 2.0'
  gem 'datadog_api_client', require: false
  gem 'debug', '~> 1.8'
  gem 'execjs', '~> 2.8', '>= 2.8.1'
  gem 'factory_bot_rails', '~> 6.2'
  gem 'faker', '~> 3.2'
  gem 'figaro', '~> 1.2'
  gem 'parallel_tests', '~> 4.2'
  gem 'rails-controller-testing', '~> 1.0'
  gem 'require_reloader'
  gem 'rspec_junit_formatter'
  gem 'rspec-rails', '~> 6.0'
  gem 'rspec-teamcity', '~> 1.0.0'
  gem 'rubocop', '~> 1.56', require: false
  gem 'rubocop-performance', '~> 1.19', require: false
  gem 'rubocop-rails', '~> 2.20', require: false
  gem 'seed_dump', '~> 3.3'
  gem 'simplecov', '~> 0.22.0'
  gem 'simplecov-html', '~> 0.12.3'
  gem 'simplecov-tailwindcss', '~> 2.1.1'
  gem 'simplecov-teamcity-summary', '~> 1.0'
  gem 'spring', '~> 4.1'    # Revisit @ Rails 6 and 7 upgrade. * Read more: https://github.com/rails/spring
  gem 'spring-commands-rspec', '~> 1.0'
  gem 'syntax_suggest', '~> 1.1.0'
  gem 'test-prof', '~> 1.0'
  gem 'timecop', '~> 0.9.8'
  gem 'wisper-rspec', '~> 1.1', require: false
end

group :test do
  gem 'pundit-matchers', '~> 3.1'
  gem 'shoulda-matchers', '~> 5.3'
  gem 'super_diff', '~> 0.10.0'
  gem 'webmock', '~> 3.19'
end

# gem 'mini_racer', platforms: :ruby

gem 'scenic', '~> 1.7'

gem 'tiktoken_ruby', '~> 0.0.5'
# Adding rb_sys for tiktoken_ruby. It shouldn't be needed,
# but it fails in local docker without this. Excluding the
# version to let it match the tiktoken required version.
gem 'rb_sys'

我可以在基础容器中运行bundle install,但是当使用docker-compose运行bundle install时,gems无法访问。

ruby-on-rails docker docker-compose bundler gemfile
1个回答
0
投票

在 DockerFile 中。

改变

RUN bundle config gems.contribsys.com $SIDEKIQ_KEY
RUN bundle config enterprise.contribsys.com $SIDEKIQ_KEY

RUN bundle config enterprise.contribsys.com abc:def 
- if use env: 'abc:def' -> $BUNDLE_ENTERPRISE__CONTRIBSYS__COM 
- I only run 'abc:def' i don't test add env. You can check)

或者如果你使用ENV

在 docker-compose.yml 中

改变

BUNDLE_GEMS__CONTRIBSYS__COM: redacted
BUNDLE_ENTERPRISE__CONTRIBSYS__COM: redacted

BUNDLE_ENTERPRISE__CONTRIBSYS__COM: 'abc:def'
© www.soinside.com 2019 - 2024. All rights reserved.