Skip to content

Docker build failing to use vendor cache #450

@stephenhyde

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!

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