evilmartians / ruby-on-whales

Ruby on Whales example and templates
MIT License
295 stars 26 forks source link

How to use cache in github action when using dip #20

Closed j-manu closed 2 years ago

j-manu commented 2 years ago

Reference

When using dip.yml it is convenient to use it in github actions as well. Example from a repo of mine

    - name: Build Images
        run: dip build
        shell: bash

      - name: Pull Images
        run: dip compose pull redis minio caddy  
        shell: bash

      - name: Provision
        run: touch .dockerdev/.bashrc && dip provision
        shell: bash

      - name: Integration Tests
        run: dip test system
        shell: bash

By default this doesn't cache the images created in dip build step. How can we do that?

palkan commented 2 years ago

Hey!

Pushed an example GitHub Action which I use in one of the apps: https://github.com/evilmartians/ruby-on-whales/blob/main/example/.github/workflows/test.yml

The key is to use buildx (which supports GitHub Actions cache out-of-the-box).

Note that since we store bundled gems in a volume, it's not cached. That could be fixed by using different volume drivers, though I haven't tried this approach yet.

j-manu commented 2 years ago

Thanks you!

So the build args and tags have to be kept in sync between github actions and compose file.