33variables :
44 CONTAINER_TEST_IMAGE : $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA
55 CONTAINER_RELEASE_IMAGE : $CI_REGISTRY_IMAGE:latest
6+ CONTAINER_TAGGED_IMAGE : $CI_REGISTRY_IMAGE:$CI_COMMIT_TAG
67 DOCKERHUB_IMAGE : geontech/redhawk-webserver
8+ REDHAWK_VERSION : 2.0.8
79
810stages :
911 - build
@@ -46,10 +48,10 @@ test:
4648 script :
4749 # Install docker-compose
4850 - apk add --no-cache py2-pip && pip install docker-compose
49-
5051 # Pull the test image and start the stack without rebuilding it.
5152 - cd tests
5253 - docker pull ${CONTAINER_TEST_IMAGE}
54+ - export REDHAWK_VERSION=$REDHAWK_VERSION
5355 - export CONTAINER_TEST_IMAGE=$CONTAINER_TEST_IMAGE
5456 - docker-compose -p ${CI_COMMIT_SHA} up -d --no-build
5557 - docker-compose -p ${CI_COMMIT_SHA} images
@@ -77,26 +79,18 @@ release:
7779 - docker push $CONTAINER_RELEASE_IMAGE
7880 - docker rmi $CONTAINER_TEST_IMAGE $CONTAINER_RELEASE_IMAGE
7981
80- # Push the released image to DockerHub on tags
82+ # Deploy internally, tagged.
8183deploy-image :
8284 stage : deploy
8385 only :
8486 - tags
8587 << : *container_registry
86- variables :
87- dockerhub_image_tag : geontech/redhawk-webserver:$CI_COMMIT_TAG
88- dockerhub_image_latest : geontech/redhawk-webserver:latest
8988 script :
90- # Use JQ to patch in our dockerhub credentials for the public push
91- - apk add --no-cache jq
92- - " jq --arg token \" $DOCKERHUB_TOKEN\" '.auths[\" https://index.docker.io/v1\" ] = { auth: $token }' ~/.docker/config.json > ~/.docker/config.json"
9389 # Pull the release image, re-tag it to the dockerhub name and push it.
9490 - docker pull $CONTAINER_RELEASE_IMAGE
95- - docker tag $CONTAINER_RELEASE_IMAGE ${dockerhub_image_tag}
96- - docker tag $CONTAINER_RELEASE_IMAGE ${dockerhub_image_latest}
97- - docker push ${dockerhub_image_tag}
98- - docker push ${dockerhub_image_latest}
99- - docker rmi ${CONTAINER_RELEASE_IMAGE} ${dockerhub_image_tag} ${dockerhub_image_latest}
91+ - docker tag $CONTAINER_RELEASE_IMAGE $CONTAINER_TAGGED_IMAGE
92+ - docker push $CONTAINER_TAGGED_IMAGE
93+ - docker rmi $CONTAINER_RELEASE_IMAGE $CONTAINER_TAGGED_IMAGE
10094
10195# Push to GitHub
10296deploy-github :
@@ -105,9 +99,9 @@ deploy-github:
10599 - tags
106100 image : alpine
107101 script :
108- - apk add --no-cache openssh-client git
102+ - apk add --no-cache openssh-client git bash
109103 - eval $(ssh-agent -s)
110- - echo "$GITHUB_TOKEN" | ssh-add -
104+ - bash -c ' ssh-add <(echo "$GITHUB_TOKEN")'
111105 - mkdir -p ~/.ssh
112106 - echo -e "Host *\n\tStrictHostKeyChecking no\n\n" > ~/.ssh/config
113107 # Configure git and push w/ tag(s)
@@ -116,29 +110,28 @@ deploy-github:
116110 - git remote set-url origin ${GITHUB_REPO}
117111 - git push origin ${GITHUB_BRANCH} --follow-tags
118112
119- # Template for cleaning the image registry
120- .clean-image : &clean-image
121- stage : cleanup
122- << : *container_registry
123- script :
124- - apk add --no-cache git bash curl
125- - git clone ${DOCKER_UTILS} docker-util
126- - docker-util/delete-image.sh $clean_target_image
127-
128113# Clean dev/test images not on master branch
129114clean-dev :
115+ stage : cleanup
116+ << : *container_registry
130117 when : always
131- variables :
132- clean_target_image : $CONTAINER_TEST_IMAGE
133118 except :
134119 - master
135120 - tags
136- << : *clean-image
121+ script :
122+ - apk add --no-cache git bash curl
123+ - git clone ${DOCKER_UTILS} docker-util
124+ - docker-util/delete-image.sh $CONTAINER_TEST_IMAGE
137125
138126# Cleanup the locally stored image after tagging and pushing to public
127+ # This has to be manual since deploying to Dockerhub is manual too.
139128clean-internal :
140- variables :
141- clean_target_image : $CONTAINER_RELEASE_IMAGE
129+ stage : cleanup
130+ << : *container_registry
131+ when : manual
142132 only :
143133 - tags
144- << : *clean-image
134+ script :
135+ - apk add --no-cache git bash curl
136+ - git clone ${DOCKER_UTILS} docker-util
137+ - docker-util/delete-image.sh $CONTAINER_RELEASE_IMAGE
0 commit comments