Skip to content

Commit 2d8846d

Browse files
authored
add md5 checksum of dockerfiles to image labels (#967)
1 parent 191fe32 commit 2d8846d

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

.github/workflows/docker-integration-tests.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,12 +61,19 @@ jobs:
6161
username: ${{ github.repository_owner }}
6262
password: ${{ secrets.GITHUB_TOKEN }}
6363

64+
- name: MD5 of Dockerfile
65+
id: md5_result
66+
run: |
67+
echo "md5=$(md5sum "${{ matrix.dockerfile }}" | awk '{ print $1 }')" >> $GITHUB_OUTPUT
68+
6469
- name: Extract metadata (tags, labels) for Docker
6570
id: meta
6671
uses: docker/metadata-action@v5
6772
with:
6873
images: |
6974
ghcr.io/${{ github.repository_owner }}/${{ matrix.image }}
75+
labels: |
76+
rocks.goss.dockerfile-md5=${{ steps.md5_result.outputs.md5 }}
7077
7178
- name: Build and push tag
7279
uses: docker/build-push-action@v5

development/build_images.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ LABEL_REVISION=$(git rev-parse HEAD)
1212
for docker_file in $INTEGRATION_TEST_DIR/Dockerfile_*; do
1313
[[ $docker_file == *.md5 ]] && continue
1414
os=$(cut -d '_' -f2 <<<"$docker_file")
15+
md5=$(md5sum "$docker_file" | awk '{ print $1 }')
1516
docker build \
1617
--label "org.opencontainers.image.created=$LABEL_DATE" \
1718
--label "org.opencontainers.image.description=Quick and Easy server testing/validation" \
@@ -21,5 +22,6 @@ for docker_file in $INTEGRATION_TEST_DIR/Dockerfile_*; do
2122
--label "org.opencontainers.image.title=goss" \
2223
--label "org.opencontainers.image.url=$LABEL_URL" \
2324
--label "org.opencontainers.image.version=manual" \
25+
--label "rocks.goss.dockerfile-md5"=$md5 \
2426
-t "aelsabbahy/goss_${os}:latest" - < "$docker_file"
2527
done

0 commit comments

Comments
 (0)