GithubHelp home page GithubHelp logo

Simple caching with ECR about aws-ecr-action HOT 7 CLOSED

kciter avatar kciter commented on August 16, 2024
Simple caching with ECR

from aws-ecr-action.

Comments (7)

kciter avatar kciter commented on August 16, 2024 1

I will. But very busy now. 😢

from aws-ecr-action.

Torvaney avatar Torvaney commented on August 16, 2024 1

Ah, that is wonderful. Thank you so much for sharing, @jondavidjohn !

from aws-ecr-action.

jondavidjohn avatar jondavidjohn commented on August 16, 2024 1

@Torvaney ended up throwing together a PR to better support this ^

from aws-ecr-action.

Torvaney avatar Torvaney commented on August 16, 2024

@jondavidjohn - I got a notification from you commenting on this thread, although it doesn't seem to be here anymore(?)

In answer to your question, I haven't yet succeeded with using extra_build_args - have you found a solution?

from aws-ecr-action.

jondavidjohn avatar jondavidjohn commented on August 16, 2024

I have, and happy to share. I tried just using the extra_build_args on it's own, and it never seemed to work.

I found out that --cache-from expects this image to already be pulled and available locally for it to work. This is why when I tested it locally it worked because I already had the image built locally!

Adding another step just before this action to pull the image made it work as expected. You do have to authenticate with ecr/docker first and then pull the image you want to reference with your cache.

Also, make sure you're tagging a latest in your build step so you can reference that for the cache.

jobs:
  build:
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v2
    - name: Pull Cache Image
      run: |
        aws ecr get-login-password | docker login --username AWS --password-stdin ${{ secrets.AWS_ACCOUNT_ID }}.    
 .dkr.ecr.us-east-2.amazonaws.com
        docker pull ${{ secrets.AWS_ACCOUNT_ID }}.dkr.ecr.us-east-2.amazonaws.com/rails:latest
      env:
        AWS_ACCOUNT_ID: ${{ secrets.AWS_ACCOUNT_ID }}
        AWS_ACCESS_KEY_ID: ${{ secrets.DEPLOY_USER_AWS_ACCESS_KEY_ID }}
        AWS_SECRET_ACCESS_KEY: ${{ secrets.DEPLOY_USER_SECRET_ACCESS_KEY }}
        AWS_DEFAULT_REGION: 'us-east-2'
    - uses: docker://ghcr.io/kciter/aws-ecr-action:034328f198022c55596bf0dfef5befbdba5043b6
      with:
        access_key_id: ${{ secrets.DEPLOY_USER_AWS_ACCESS_KEY_ID }}
        secret_access_key: ${{ secrets.DEPLOY_USER_SECRET_ACCESS_KEY }}
        account_id: ${{ secrets.AWS_ACCOUNT_ID }}
        repo: rails
        region: us-east-2
        tags: latest,${{ github.sha }}
        extra_build_args: --cache-from ${{ secrets.AWS_ACCOUNT_ID }}.dkr.ecr.us-east-2.amazonaws.com/rails:latest

from aws-ecr-action.

jondavidjohn avatar jondavidjohn commented on August 16, 2024

All this to say, it's a workaround, even if a bit ugly. Would love to see this cache functionality integrated in the action. I assume PRs would be welcome for this @kciter?

from aws-ecr-action.

kciter avatar kciter commented on August 16, 2024

Sorry, I'm too late merge.

from aws-ecr-action.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.