Skip to content

Commit

Permalink
add md5 checksum of dockerfiles to image labels (#967)
Browse files Browse the repository at this point in the history
  • Loading branch information
dklimpel authored Aug 15, 2024
1 parent 191fe32 commit 2d8846d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
7 changes: 7 additions & 0 deletions .github/workflows/docker-integration-tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,19 @@ jobs:
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: MD5 of Dockerfile
id: md5_result
run: |
echo "md5=$(md5sum "${{ matrix.dockerfile }}" | awk '{ print $1 }')" >> $GITHUB_OUTPUT
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v5
with:
images: |
ghcr.io/${{ github.repository_owner }}/${{ matrix.image }}
labels: |
rocks.goss.dockerfile-md5=${{ steps.md5_result.outputs.md5 }}
- name: Build and push tag
uses: docker/build-push-action@v5
Expand Down
2 changes: 2 additions & 0 deletions development/build_images.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ LABEL_REVISION=$(git rev-parse HEAD)
for docker_file in $INTEGRATION_TEST_DIR/Dockerfile_*; do
[[ $docker_file == *.md5 ]] && continue
os=$(cut -d '_' -f2 <<<"$docker_file")
md5=$(md5sum "$docker_file" | awk '{ print $1 }')
docker build \
--label "org.opencontainers.image.created=$LABEL_DATE" \
--label "org.opencontainers.image.description=Quick and Easy server testing/validation" \
Expand All @@ -21,5 +22,6 @@ for docker_file in $INTEGRATION_TEST_DIR/Dockerfile_*; do
--label "org.opencontainers.image.title=goss" \
--label "org.opencontainers.image.url=$LABEL_URL" \
--label "org.opencontainers.image.version=manual" \
--label "rocks.goss.dockerfile-md5"=$md5 \
-t "aelsabbahy/goss_${os}:latest" - < "$docker_file"
done

0 comments on commit 2d8846d

Please sign in to comment.