I have a Dockerfile [as an example] that looks like this:
FROM atlassian/default-image:3
RUN apt-get install -y ffmpeg
The point of this dockerfile is to pull a specific image and use it as a basis to install another library.
What I want to do is use GitHub actions to:
Build the Dockerfile into an image [lets call it ‘atlassian-ffpeg-image’]
Run another build script based on the image I just built [so this new build script would have a FROM of ‘atlassian-ffpeg-image’]
Assuming Step 2 was successful, push my ‘atlassian-ffpeg-image’ to Docker Hub
The idea is to use CI/CD to test my newly built image before pushing it to Docker Hub.
Is there any current examples of this? It seems there is no way or guide for GitHub to pass an image to another step of the actions.yaml script in GitHub Actions
I have not used GitHub Actions yet so I checked the docs:
The examples here show steps like “Build and push” because those examples use the buildx action. docker buildx can build multi architecture images, however multi architecture images cannot be saved locally. You need a registry to push the images to right after the build. So there is no way to test unless you have a multi-stage build where one of the stages run some tests and the latest stage creates the final image. But then your final stage should somehow trigger the previous stages. This was my problem too when I wanted to build multi architecture images. If you don’t need that, I guess you should find an other action with which you can run docker commands manually and just use docker build, run the tests and push the image. Or you can do what I did and use buildx but add a temporary tag to the image. In the next step, download the image, test it, that add a new tag. I just ran buildx again using the previous image as a cache.
I used CircleCI, not GitHub actions, but it miight give you some idea if you find other github actions:
The steps in the .circleci folder and the helper scripts doing the real job is in the ci folder.