Skip to content

Docker build failing to use vendor cache #450

Description

@stephenhyde

Hi! So this is probably me issue but tried a few things to speed up my docker build in github actions as bundle is taking a majority of the time. 6 mins ! I am sure this will be helpful to others as I scoured the internet looking. I figured docker just didn't have the cache so the last thing I landed on was trying to copy it to /vender/bundle but still doesn't seem to use it.

Docker File

FROM ruby:2.6.6
RUN apt-get update -qq && apt-get install -y nodejs postgresql-client
WORKDIR /1v1Me-API

COPY Gemfile /1v1Me-API
COPY Gemfile.lock /1v1Me-API
COPY vendor/bundle /vendor/bundle/
RUN bundle install

COPY . /1v1Me-API

RUN bundle exec rake assets:precompile

# Add a script to be executed every time the container starts.
COPY entrypoint.sh /usr/bin/
RUN chmod +x /usr/bin/entrypoint.sh
ENTRYPOINT ["entrypoint.sh"]

GitHub Action (Snippet)

    - uses: actions/checkout@v3
    - uses: ruby/setup-ruby@v1
      with:
        ruby-version: '2.6.6' # Not needed with a .ruby-version file
        bundler-cache: true # runs 'bundle install' and caches installed gems automatically

    - name: Build, tag, and push image to Amazon ECR
      env:
        ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
        ECR_REPOSITORY: api-dev
        IMAGE_TAG: ${{ steps.split.outputs.fragment }}
      run: |
        echo "$ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG"
        echo "${{ github.head_ref || github.ref_name }}"
        docker build -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG .
        docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG

I figure this prob not an issue with this library but any help be greatly appreciated!

Activity

  1. stephenhyde commented on Jan 24, 2023

    @stephenhyde
    Author

    Looking at your build in github i do notice

    /opt/hostedtoolcache/Ruby/2.6.6/x64/bin/bundle config --local path /home/runner/work/1v1Me-API/1v1Me-API/vendor/bundle

    before bundle install so maybe I am just copying nothing over?

  2. locked and limited conversation to collaborators on Jan 24, 2023
  3. converted this issue into a discussion #451 on Jan 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions