20 lines
713 B
Bash
20 lines
713 B
Bash
#!/bin/sh
|
|
|
|
# build.sh checks if docker image with same sha256 exists remotely.
|
|
# if exists, do nothing, if not, build the image
|
|
|
|
commit_sha="${CI_COMMIT_SHA}"
|
|
registry_uri="${CI_PROJECT_URL}"
|
|
image_name="${CI_REGISTRY_IMAGE}"
|
|
arch="${ARCH}"
|
|
|
|
echo "* Building docker image ${image_name}:${commit_sha}-${arch}..."
|
|
|
|
if docker manifest inspect "${image_name}:${commit_sha}-${arch}" >/dev/null; then
|
|
echo "* Docker image ${image_name}:${commit_sha}-${arch} is already exists on remote, no rebuilt necessary."
|
|
exit 0
|
|
fi
|
|
|
|
docker build --pull --build-arg VCS_REF=${commit_sha} --build-arg VCS_URL=${registry_uri} --tag ${image_name}:${commit_sha}-${arch} .
|
|
docker push ${image_name}:${commit_sha}-${arch}
|