Skip to content
This repository was archived by the owner on Jun 22, 2024. It is now read-only.

Commit 7754dc7

Browse files
Added the functionality to add browser versions to the Docker Hub tags. Also, updated the 'latest' tag.
1 parent 5709ba6 commit 7754dc7

File tree

5 files changed

+97
-31
lines changed

5 files changed

+97
-31
lines changed

.circleci/config.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ jobs:
163163
- run:
164164
name: "Tag browser images and update latest tag"
165165
command: |
166-
NAME=${NAMESPACE} VERSION=${BRANCH} BUILD_DATE=${BUILD_DATE} PUSH_IMAGE=true PLATFORMS=${PLATFORMS} make tag_and_push_multi_arch_browser_images
166+
NAME=${NAMESPACE} VERSION=${BRANCH} BUILD_DATE=${BUILD_DATE} PUSH_IMAGE=true make tag_and_push_multi_arch_browser_images
167167
NAME=${NAMESPACE} VERSION=${BRANCH} BUILD_DATE=${BUILD_DATE} make tag_multi_arch_latest
168168
- run:
169169
name: "Generate release notes"

Makefile

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -244,19 +244,19 @@ tag_latest:
244244
tag_and_push_multi_arch_browser_images: tag_and_push_multi_arch_chromium_images tag_and_push_multi_arch_firefox_images
245245

246246
tag_and_push_multi_arch_chromium_images:
247-
./tag_and_push_multi-arch_browser_images.sh $(VERSION) $(BUILD_DATE) $(NAMESPACE) $(PUSH_IMAGE) chromium $(PLATFORMS)
247+
./tag_and_push_multi-arch_browser_images.sh $(VERSION) $(BUILD_DATE) $(NAMESPACE) $(PUSH_IMAGE) chromium
248248

249249
tag_and_push_multi_arch_firefox_images:
250-
./tag_and_push_multi-arch_browser_images.sh $(VERSION) $(BUILD_DATE) $(NAMESPACE) $(PUSH_IMAGE) firefox $(PLATFORMS)
250+
./tag_and_push_multi-arch_browser_images.sh $(VERSION) $(BUILD_DATE) $(NAMESPACE) $(PUSH_IMAGE) firefox
251251

252252
tag_multi_arch_latest:
253-
docker tag $(NAME)/base:$(TAG_VERSION) $(NAME)/base:latest
254-
docker tag $(NAME)/hub:$(TAG_VERSION) $(NAME)/hub:latest
255-
docker tag $(NAME)/node-base:$(TAG_VERSION) $(NAME)/node-base:latest
256-
docker tag $(NAME)/node-chromium:$(TAG_VERSION) $(NAME)/node-chromium:latest
257-
docker tag $(NAME)/node-firefox:$(TAG_VERSION) $(NAME)/node-firefox:latest
258-
docker tag $(NAME)/standalone-chromium:$(TAG_VERSION) $(NAME)/standalone-chromium:latest
259-
docker tag $(NAME)/standalone-firefox:$(TAG_VERSION) $(NAME)/standalone-firefox:latest
253+
./tag-and-push-multi-arch-image.sh $(VERSION) $(BUILD_DATE) $(NAMESPACE) base latest
254+
./tag-and-push-multi-arch-image.sh $(VERSION) $(BUILD_DATE) $(NAMESPACE) hub latest
255+
./tag-and-push-multi-arch-image.sh $(VERSION) $(BUILD_DATE) $(NAMESPACE) node-base latest
256+
./tag-and-push-multi-arch-image.sh $(VERSION) $(BUILD_DATE) $(NAMESPACE) node-chromium latest
257+
./tag-and-push-multi-arch-image.sh $(VERSION) $(BUILD_DATE) $(NAMESPACE) node-firefox latest
258+
./tag-and-push-multi-arch-image.sh $(VERSION) $(BUILD_DATE) $(NAMESPACE) standalone-chromium latest
259+
./tag-and-push-multi-arch-image.sh $(VERSION) $(BUILD_DATE) $(NAMESPACE) standalone-firefox latest
260260

261261
release_latest:
262262
docker push $(NAME)/base:latest

get-image-sha256-digest.go

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
package main
2+
3+
import (
4+
"io/ioutil"
5+
"log"
6+
"net/http"
7+
"fmt"
8+
"encoding/json"
9+
"os"
10+
)
11+
12+
type Latest struct {
13+
Images []struct {
14+
Architecture string `json:"architecture"`
15+
Digest string `json:"digest"`
16+
}
17+
}
18+
19+
20+
func main() {
21+
argLen := len(os.Args)
22+
if argLen < 2 {
23+
showUsage()
24+
os.Exit(1)
25+
}
26+
27+
url := os.Args[1] // https://hub.docker.com/v2/repositories/selenium/standalone-chrome/tags/latest/
28+
resp, err := http.Get(url)
29+
if err != nil {
30+
log.Fatalln(err)
31+
}
32+
33+
body, err := ioutil.ReadAll(resp.Body)
34+
if err != nil {
35+
log.Fatalln(err)
36+
}
37+
38+
var jsonResp Latest
39+
sb := string(body)
40+
json.Unmarshal([]byte(sb), &jsonResp)
41+
42+
for _, image := range jsonResp.Images {
43+
fmt.Printf(image.Architecture + " " + image.Digest + "\n")
44+
}
45+
}
46+
47+
func showUsage() {
48+
fmt.Println(`Usage:
49+
get-image-sha256-digest TAG_URL
50+
51+
TAG_URL -> URL for a container image manifest (Required)
52+
53+
Example Usage:
54+
$ get-image-sha256-digest https://hub.docker.com/v2/repositories/selenium/standalone-chrome/tags/latest/
55+
`)
56+
}

tag-and-push-multi-arch-image.sh

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#!/bin/bash
2+
3+
VERSION=$1
4+
BUILD_DATE=$2
5+
NAMESPACE="${3:-seleniarm}"
6+
IMAGE=$4
7+
NEW_TAG=$5
8+
9+
if [ -z "$1" ] || [ -z "$2" ] || [ -z "$3" ] || [ -z "$4" ] || [ -z "$5" ]; then
10+
echo "Be sure to pass in all of the values"
11+
exit 1
12+
fi
13+
14+
15+
AMD64_DIGEST=`go run get-image-sha256-digest.go https://hub.docker.com/v2/repositories/$NAMESPACE/$IMAGE/tags/$VERSION-$BUILD_DATE/ | grep -w "amd64" | awk '{print $2}'`
16+
ARM_DIGEST=`go run get-image-sha256-digest.go https://hub.docker.com/v2/repositories/$NAMESPACE/$IMAGE/tags/$VERSION-$BUILD_DATE/ | grep -w "arm" | awk '{print $2}'`
17+
ARM64_DIGEST=`go run get-image-sha256-digest.go https://hub.docker.com/v2/repositories/$NAMESPACE/$IMAGE/tags/$VERSION-$BUILD_DATE/ | grep -w "arm64" | awk '{print $2}'`
18+
19+
docker manifest create $NAMESPACE/$IMAGE:$NEW_TAG \
20+
--amend $NAMESPACE/$IMAGE@$AMD64_DIGEST \
21+
--amend $NAMESPACE/$IMAGE@$ARM_DIGEST \
22+
--amend $NAMESPACE/$IMAGE@$ARM64_DIGEST
23+
24+
docker manifest push $NAMESPACE/$IMAGE:$NEW_TAG
25+

tag_and_push_multi-arch_browser_images.sh

Lines changed: 6 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ BUILD_DATE=$2
55
NAMESPACE=$3
66
PUSH_IMAGE="${4:-false}"
77
BROWSER=$5
8-
PLATFORMS=$6
98

109
TAG_VERSION=${VERSION}-${BUILD_DATE}
1110

@@ -53,20 +52,13 @@ chromium)
5352
${CHROME_SHORT_VERSION}
5453
)
5554

56-
cd NodeChromium
57-
NODE_CHROMIUM_TAGS=""
58-
STANDALONE_CHROMIUM_TAGS=""
5955
for chrome_tag in "${CHROME_TAGS[@]}"
6056
do
61-
#docker tag ${NAMESPACE}/node-chromium:${TAG_VERSION} ${NAMESPACE}/node-chromium:${chrome_tag}
62-
#docker tag ${NAMESPACE}/standalone-chromium:${TAG_VERSION} ${NAMESPACE}/standalone-chromium:${chrome_tag}
63-
NODE_CHROMIUM_TAGS+=" -t ${NAME}/node-chromium:${chrome_tag}"
64-
STANDALONE_CHROMIUM_TAGS+=" -t ${NAME}/standalone-chromium:${chrome_tag}"
57+
if [ "${PUSH_IMAGE}" = true ]; then
58+
sh tag-and-push-multi-arch-image.sh $VERSION $BUILD_DATE $NAME node-chromium ${chrome_tag}
59+
sh tag-and-push-multi-arch-image.sh $VERSION $BUILD_DATE $NAME standalone-chromium ${chrome_tag}
60+
fi
6561
done
66-
if [ "${PUSH_IMAGE}" = true ]; then
67-
cd ../NodeChromium && docker buildx build --platform ${PLATFORMS} --push ${NODE_CHROMIUM_TAGS} .
68-
cd ../StandaloneChromium && docker buildx build --platform ${PLATFORMS} --push ${STANDALONE_CHROMIUM_TAGS} .
69-
fi
7062

7163
;;
7264
firefox)
@@ -101,18 +93,11 @@ firefox)
10193
${FIREFOX_SHORT_VERSION}
10294
)
10395

104-
#cd NodeFirefox
105-
NODE_FIREFOX_TAGS=""
106-
STANDALONE_FIREFOX_TAGS=""
10796
for firefox_tag in "${FIREFOX_TAGS[@]}"
10897
do
109-
#docker tag ${NAMESPACE}/node-firefox:${TAG_VERSION} ${NAMESPACE}/node-firefox:${firefox_tag}
110-
#docker tag ${NAMESPACE}/standalone-firefox:${TAG_VERSION} ${NAMESPACE}/standalone-firefox:${firefox_tag}
111-
NODE_FIREFOX_TAGS+=" -t ${NAME}/node-firefox:${firefox_tag}"
112-
STANDALONE_FIREFOX_TAGS+=" -t ${NAME}/standalone-firefox:${firefox_tag}"
11398
if [ "${PUSH_IMAGE}" = true ]; then
114-
cd ../NodeFirefox && docker buildx build --platform ${PLATFORMS} --push ${NODE_FIREFOX_TAGS} .
115-
cd ../StandaloneFirefox && docker buildx build --platform ${PLATFORMS} --push ${STANDALONE_FIREFOX_TAGS} .
99+
sh tag-and-push-multi-arch-image.sh $VERSION $BUILD_DATE $NAME node-firefox ${firefox_tag}
100+
sh tag-and-push-multi-arch-image.sh $VERSION $BUILD_DATE $NAME standalone-firefox ${firefox_tag}
116101
fi
117102
done
118103

0 commit comments

Comments
 (0)