docker: include git hash in Docker image.
Put the Git hash of the current commit inside the Docker image built by Docker Hub. The hash is stored in the REVISION file in the root directory.
This commit is contained in:
13
hooks/build
Executable file
13
hooks/build
Executable file
@@ -0,0 +1,13 @@
|
||||
#!/bin/bash
|
||||
|
||||
# This file is used to add the Git commit hash to the Docker image when the
|
||||
# image is built by Docker Hub.
|
||||
#
|
||||
# https://docs.docker.com/docker-hub/builds/advanced/
|
||||
# https://stackoverflow.com/questions/59057978/passing-source-commit-to-dockerfile-commands-on-docker-hub
|
||||
#
|
||||
# SOURCE_COMMIT: the SHA1 hash of the commit being tested.
|
||||
# DOCKERFILE_PATH: the dockerfile currently being built.
|
||||
# IMAGE_NAME: the name and tag of the Docker repository being built. (This variable is a combination of DOCKER_REPO:DOCKER_TAG.)
|
||||
|
||||
docker build --build-arg SOURCE_COMMIT=$SOURCE_COMMIT -f $DOCKERFILE_PATH -t $IMAGE_NAME .
|
||||
Reference in New Issue
Block a user