This repository has been archived by the owner on Feb 26, 2022. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Enable TC builds with dockerhub uploads
The dockerhub credentials are stored in a tc secret repo:github.com/mozilla-releng/funsize-balrogworker:branch:master
- Loading branch information
Francis Kang
committed
Jul 13, 2016
1 parent
cc412d9
commit c5f951b
Showing
6 changed files
with
76 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
Dockerfile | ||
my_Dockerfile | ||
.idea/* | ||
scriptworker/* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
#!/bin/bash | ||
|
||
set -e | ||
|
||
echo "Setting up credentials" | ||
password_url="taskcluster/secrets/v1/secret/repo:github.com/mozilla-releng/funsize-balrogworker:branch:master" | ||
artifact_url="taskcluster/queue/v1/task/${TASK_ID}/runs/${RUN_ID}/artifacts/public/docker-image-shasum256.txt" | ||
artifact_expiry=$(date -d "+1 year" -u +%FT%TZ) | ||
dockerhub_email=fkang@mozilla.com | ||
dockerhub_username=fkang | ||
dockerhub_password=$(curl ${password_url} | python -c 'import json, sys; a = json.load(sys.stdin); print a["secret"]["dockerhub_password"]') | ||
|
||
|
||
if [ -z $dockerhub_password ]; then | ||
echo "Dockerhub password not set, can't continue!" | ||
exit 1 | ||
fi | ||
|
||
echo "Retrieving version info" | ||
commit=$(git rev-parse HEAD) | ||
version=$(cat version.txt) | ||
branch=$(git rev-parse --abbrev-ref HEAD) | ||
date=$(date --utc +%Y-%m-%d-%H-%M) | ||
|
||
echo "{ | ||
\"commit\": \"${commit}\", | ||
\"version\": \"${version}\", | ||
\"source\": \"https://github.com/mozilla-releng/funsize-balrogworker\", | ||
\"build\": \"https://tools.taskcluster.net/task-inspector/#${TASK_ID}\" | ||
}" > version.json | ||
|
||
|
||
branch_tag="${branch}" | ||
if [ "$branch" == "master" ]; then | ||
branch_tag="latest" | ||
fi | ||
date_tag="${branch}-${date}" | ||
|
||
echo "Building Docker image" | ||
docker build -t fkang/funsize-balrogworker:${branch_tag} . | ||
echo "Tagging Docker image with date tag" | ||
docker tag fkang/funsize-balrogworker:${branch_tag} "fkang/funsize-balrogworker:${date_tag}" | ||
echo "Logging into Dockerhub" | ||
docker login -e $dockerhub_email -u $dockerhub_username -p $dockerhub_password | ||
echo "Pushing Docker image" | ||
docker push fkang/funsize-balrogworker:${branch_tag} | ||
docker push fkang/funsize-balrogworker:${date_tag} | ||
|
||
sha256=$(docker images --no-trunc fkang/funsize-balrogworker | grep "${date_tag}" | awk '/^fkang/ {print $3}') | ||
echo "SHA256 is ${sha256}, creating artifact for it" | ||
put_url=$(curl --retry 5 --retry-delay 5 --data "{\"storageType\": \"s3\", \"contentType\": \"text/plain\", \"expires\": \"${artifact_expiry}\"}" ${artifact_url} | python -c 'import json; import sys; print json.load(sys.stdin)["putUrl"]') | ||
curl --retry 5 --retry-delay 5 -X PUT -H "Content-Type: text/plain" --data "${sha256}" "${put_url}" | ||
echo 'Artifact created, all done!' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
0.0.1 |
c5f951b
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TaskCluster-GitHub: https://tools.taskcluster.net/task-graph-inspector/#VjpDgCuAQG6ISsSTUkLk5Q