1

I am trying to implement docker container based CI runner for building embedded software on git actions platform which pulls docker image from docker hub and performs the action in it.

However, runner can't retain the pulled docker image in subsequent trigger events, I tried to look up how to use caching feature to cache pulled image and use it run the job but, it doesn't seem to work correctly.

There are multiple forums which discuss how to cache docker layer (build layer) and cache is using actions but, no guide on how to cache the pulled container without building it on github actions.

Question is : How to cache a pulled docker image rather than building one from cached docker layers ? Any help will be helpful. Thanks in advance.

name: push workflows

# on Event push trigger action specified in jobs
on: [push]

jobs:


Build-Job:

# base OS
runs-on: ubuntu-latest

# run in docker container
container: 
image: {myrepo}/{image}:{version}

steps:

  # Checkout repo
  - name: Checkout repo
    uses: actions/checkout@v2
   
  # mount project to /home/git and build
  - name: Build in Docker 
    run: |  
      echo Hello from docker
      sudo ln -s $(pwd) /home/git
      cd /home/git/project
      chmod u+x docker_build.sh
      ./docker_build.sh
  
  # Upload artifacts if build was successful
  - name: Upload Artifacts
    uses: actions/upload-artifact@v2.2.0
    with:
      name: output_files
      path: /home/git/project/output_files/**
      if-no-files-found: error
      retention-days: 90
rahulb
  • 185
  • 1
  • 9
  • You might try with `docker container export` and then save the tar file to a cache. Later on you can boot a new container based on the tar archive created. – Marko E Jul 26 '22 at 13:06
  • If you want to cache the container image downloaded by GitHub itself when you specify `container.image` for your job, [I don't believe this is currently supported](https://stackoverflow.com/a/68660121/2748899). If you want to cache a container image downloaded *within* some step of your job, there is a more fleshed-out variant of MarkoE's suggestion (using `save` and `load` instead of `export`) [in this answer](https://stackoverflow.com/a/71183339/2748899). – smheidrich Oct 22 '22 at 22:00

0 Answers0