new docker publish script

This commit is contained in:
Eugenio Romano
2018-01-30 15:40:51 +00:00
parent 9bd18c9770
commit a51d522807
2 changed files with 67 additions and 0 deletions

View File

@@ -295,3 +295,19 @@ Extract the i18n files from the repo and create a zip
```sh ```sh
./extract-langs.sh ./extract-langs.sh
``` ```
***docker-publish.sh***
publish doker images in the selected repository
| Option | Description |
| --- | --- |
| -u or --username | username |
| -p or --password | password |
| -t or --tags | tags |
```sh
./docker-publish.sh
```

51
scripts/docker-publish.sh Executable file
View File

@@ -0,0 +1,51 @@
#!/usr/bin/env bash
set -e
show_help() {
echo "Usage: docker_publish.sh"
echo ""
echo "-u or --username username docker repo"
echo "-p or --passwor password docker repo"
echo "-t or --tags tags comma separated"
}
username_set() {
USERNAME=$1
}
password_set() {
PASSWORD=$1
}
tags_set() {
TAGS=$1
}
while [[ $1 == -* ]]; do
case "$1" in
-h|--help|-\?) show_help; exit 0;;
-u|--username) username_set $2; shift 2;;
-p|--password) password_set $2; shift 2;;
-t|--tags) tags_set $2; shift 2;;
-*) echo "invalid option: $1" 1>&2; show_help; exit 1;;
esac
done
# Tag and push image for each additional tag
for current_tag in $(echo $TAGS | sed "s/,/ /g")
do
echo "====== PUBLISH DOCKER IMAGE TAG ${current_tag} ====="
docker build -t alfresco/demo-shell:${current_tag} .
docker tag alfresco/demo-shell:${current_tag} alfresco/demo-shell:${current_tag}
echo "====== LOGIN ====="
docker login -u "${USERNAME}" -p "${PASSWORD}"
docker push "alfresco/demo-shell"
echo "====== CLEAN LOCAL IMAGE TAG ${current_tag} ====="
docker rmi -f alfresco/demo-shell:${current_tag}
done