Skip to content

Commit

Permalink
using release tag name throughout
Browse files Browse the repository at this point in the history
  • Loading branch information
kichalla committed Oct 13, 2019
1 parent e96080a commit 1dcfd69
Show file tree
Hide file tree
Showing 7 changed files with 38 additions and 21 deletions.
1 change: 1 addition & 0 deletions build/__variables.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ declare -r __REPO_DIR=$( cd $( dirname "$0" ) && cd .. && pwd )
# VSTS environment variables
declare -r BUILD_NUMBER="$BUILD_BUILDNUMBER"
declare -r BUILD_CONFIGURATION="${BUILDCONFIGURATION:-Debug}"
declare -r RELEASE_TAG_NAME="${RELEASE_TAG_NAME:-$BUILD_NUMBER}"

declare -r BUILD_IMAGES_BUILD_CONTEXT_DIR="$__REPO_DIR/"
declare -r BUILD_IMAGES_DOCKERFILE="$__REPO_DIR/images/build/Dockerfile"
Expand Down
7 changes: 4 additions & 3 deletions build/buildBuildImages.sh
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,9 @@ function buildDockerImage() {
--build-arg AGENTBUILD=$BUILD_SIGNED \
$BASE_TAG_BUILD_ARGS \
--build-arg AI_KEY=$APPLICATION_INSIGHTS_INSTRUMENTATION_KEY \
$ctxArgs -f "$dockerFileToBuild" .
$ctxArgs \
-f "$dockerFileToBuild" \
.

echo
echo Building a base image for tests...
Expand All @@ -92,8 +94,7 @@ function buildDockerImage() {
# Retag build image with build number tags
if [ "$AGENT_BUILD" == "true" ]
then
releasetag="${RELEASE_TAG_NAME:-$BUILD_NUMBER}"
uniqueTag="$BUILD_DEFINITIONNAME.$releasetag"
uniqueTag="$BUILD_DEFINITIONNAME.$RELEASE_TAG_NAME"

echo
echo "Retagging image '$builtImageTag' with ACR related tags..."
Expand Down
8 changes: 6 additions & 2 deletions build/buildBuildpacksImages.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,21 @@ else
echo "Building buildpack runner image..."
fi

labels="--label com.microsoft.oryx.git-commit=$GIT_COMMIT"
labels="$labels --label com.microsoft.oryx.build-number=$BUILD_NUMBER"
labels="$labels --label com.microsoft.oryx.release-tag-name=$RELEASE_TAG_NAME"

# Build an image that runs `pack`
echo "-> Building pack runner image: $ACR_PACK_IMAGE_REPO"
echo
cd "$BUILD_IMAGES_BUILD_CONTEXT_DIR"
docker build -f "$PACK_IMAGE_DOCKERFILE" $noCacheFlag \
--build-arg BUILD_NUMBER="$BUILD_NUMBER" \
$labels \
-t $ACR_PACK_IMAGE_REPO:latest \
.

if [ "$AGENT_BUILD" == "true" ]; then
BUILD_SUFFIX="$BUILD_DEFINITIONNAME.$BUILD_NUMBER"
BUILD_SUFFIX="$BUILD_DEFINITIONNAME.$RELEASE_TAG_NAME"

docker tag "$ACR_PACK_IMAGE_REPO:latest" "$ACR_PACK_IMAGE_REPO:$BUILD_SUFFIX"
echo "$ACR_PACK_IMAGE_REPO:$BUILD_SUFFIX" >> $ACR_BUILD_IMAGES_ARTIFACTS_FILE
Expand Down
18 changes: 12 additions & 6 deletions build/buildRunTimeImages.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ declare -r REPO_DIR=$( cd $( dirname "$0" ) && cd .. && pwd )
source $REPO_DIR/build/__variables.sh
source $REPO_DIR/build/__functions.sh


runtimeImagesSourceDir="$RUNTIME_IMAGES_SRC_DIR"
runtimeSubDir="$1"
if [ ! -z "$runtimeSubDir" ]
Expand Down Expand Up @@ -50,7 +49,11 @@ fi
# We don't retrieve this image from a repository but rather build locally to make sure we get
# the latest version of its own base image.

docker build --pull -f "$RUNTIME_BASE_IMAGE_DOCKERFILE_PATH" -t "$RUNTIME_BASE_IMAGE_NAME" $REPO_DIR
docker build \
--pull \
-f "$RUNTIME_BASE_IMAGE_DOCKERFILE_PATH" \
-t "$RUNTIME_BASE_IMAGE_NAME" \
$REPO_DIR

# Write the list of images that were built to artifacts folder
mkdir -p "$ARTIFACTS_DIR/images"
Expand All @@ -67,17 +70,20 @@ for dockerFile in $dockerFiles; do
cd $REPO_DIR

echo
docker build -f $dockerFile -t $localImageTagName \
docker build \
-f $dockerFile \
-t $localImageTagName \
--build-arg AI_KEY=$APPLICATION_INSIGHTS_INSTRUMENTATION_KEY \
$args $labels .
$args \
$labels \
.

echo "$localImageTagName" >> $ACR_RUNTIME_IMAGES_ARTIFACTS_FILE

# Retag image with build number (for images built in oryxlinux buildAgent)
if [ "$AGENT_BUILD" == "true" ]
then
releasetag="${RELEASE_TAG_NAME:-$BUILD_NUMBER}"
uniqueTag="$BUILD_DEFINITIONNAME.$releasetag"
uniqueTag="$BUILD_DEFINITIONNAME.$RELEASE_TAG_NAME"
acrRuntimeImageTagNameRepo="$ACR_PUBLIC_PREFIX/$getTagName_result"

docker tag "$localImageTagName" "$acrRuntimeImageTagNameRepo:$uniqueTag"
Expand Down
7 changes: 5 additions & 2 deletions vsts/scripts/tagBuildImagesForRelease.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@

set -o pipefail

declare -r REPO_DIR=$( cd $( dirname "$0" ) && cd .. && cd .. && pwd )
source $REPO_DIR/build/__variables.sh

releasetag="${RELEASE_TAG_NAME:-$BUILD_BUILDNUMBER}"

function tagBuildImage() {
Expand Down Expand Up @@ -37,5 +40,5 @@ function tagBuildImage() {
echo -------------------------------------------------------------------------------
}

tagBuildImage "oryxdevmcr.azurecr.io/public/oryx/build:Oryx-CI.$releasetag" "latest" "$releasetag"
tagBuildImage "oryxdevmcr.azurecr.io/public/oryx/build-slim:Oryx-CI.$releasetag" "slim" "slim-$releasetag"
tagBuildImage "oryxdevmcr.azurecr.io/public/oryx/build:Oryx-CI.$RELEASE_TAG_NAME" "latest" "$RELEASE_TAG_NAME"
tagBuildImage "oryxdevmcr.azurecr.io/public/oryx/build-slim:Oryx-CI.$RELEASE_TAG_NAME" "slim" "slim-$RELEASE_TAG_NAME"
14 changes: 8 additions & 6 deletions vsts/scripts/tagBuildpacksImagesForRelease.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,21 @@

set -o pipefail

declare -r REPO_DIR=$( cd $( dirname "$0" ) && cd .. && cd .. && pwd )
source $REPO_DIR/build/__variables.sh

declare -r outFile="$BUILD_ARTIFACTSTAGINGDIRECTORY/drop/images/buildpack-images-mcr.txt"
declare -r sourceImageRepo="oryxdevmcr.azurecr.io/public/oryx"
declare -r prodImageRepo="oryxmcr.azurecr.io/public/oryx"

buildNumber=$BUILD_BUILDNUMBER
sourceBranchName=$BUILD_SOURCEBRANCHNAME

echo "Pulling pack image..."
packImage=$sourceImageRepo/pack:Oryx-CI.$buildNumber
packImage="$sourceImageRepo/pack:Oryx-CI.$RELEASE_TAG_NAME"
echo "Pulling pack image '$packImage'..."
docker pull "$packImage"
echo "Retagging pack image with 'buildNumber'..."
echo "$prodImageRepo/pack:$buildNumber">>"$outFile"
docker tag "$packImage" "$prodImageRepo/pack:$buildNumber"
echo "Retagging pack image with '$RELEASE_TAG_NAME'..."
echo "$prodImageRepo/pack:$RELEASE_TAG_NAME">>"$outFile"
docker tag "$packImage" "$prodImageRepo/pack:$RELEASE_TAG_NAME"

if [ "$sourceBranchName" == "master" ]; then
echo "Retagging pack image with 'stable'..."
Expand Down
4 changes: 2 additions & 2 deletions vsts/scripts/tagRunTimeImagesForRelease.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,15 @@ while read sourceImage; do
repo=${imageNameParts[0]}
tag=${imageNameParts[1]}
replaceText="Oryx-CI."
buildNumber=$(echo $tag | sed "s/$replaceText//g")
releaseTagName=$(echo $tag | sed "s/$replaceText//g")

IFS='-'
read -ra repoParts <<< "$repo"
acrRepoName=${repoParts[0]}
acrProdRepo=$(echo $acrRepoName | sed "s/oryxdevmcr/oryxmcr/g")
version=${repoParts[1]}
acrLatest="$acrProdRepo:$version"
acrSpecific="$acrProdRepo:$version-$buildNumber"
acrSpecific="$acrProdRepo:$version-$releaseTagName"

echo
echo "Tagging the source image with tag $acrSpecific..."
Expand Down

0 comments on commit 1dcfd69

Please sign in to comment.