This repository was archived by the owner on Oct 21, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Teakowa
committed
Aug 24, 2019
0 parents
commit 2cd3c5b
Showing
2 changed files
with
75 additions
and
0 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 |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# Builder | ||
|
||
## Install | ||
|
||
``` | ||
sudo curl -L https://raw.githubusercontent.com/FSPNET/builder/master/scripts/publish.sh -o /usr/local/bin/docker-publish | ||
sudo chmod +x /usr/local/bin/docker-publish | ||
``` | ||
|
||
## Usage | ||
|
||
``` | ||
~ docker-publish | ||
usage: docker-publish repo[:tag] repo:tag [prefix count] | ||
ie: docker-publish build:travis FSPNET/php:7.3.4 | ||
docker-publish build FSPNET/php:7.3.4 2 | ||
``` |
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,58 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -eo pipefail | ||
shopt -s dotglob | ||
|
||
# make sure we can GTFO | ||
trap 'echo >&2 Ctrl+C captured, exiting; exit 1' SIGINT | ||
|
||
usage() { | ||
self="$(basename "$0")" | ||
cat <<-EOUSAGE | ||
usage: $self repo[:tag] repo:tag [prefix count] | ||
ie: $self build:travis FSPNET/php:7.3.4 | ||
$self build FSPNET/php:7.3.4 2 | ||
EOUSAGE | ||
} | ||
|
||
if [ $# -lt 2 ]; then | ||
usage >&2 | ||
exit 1 | ||
fi | ||
|
||
image_build="$1" && shift | ||
image_target="$1" && shift | ||
prefix_count=${1:-"0"} | ||
|
||
target_name=`echo "$image_target" | cut -d: -f1` | ||
target_version=`echo "$image_target" | cut -d: -f2` | ||
target_version_count=`echo "$target_version" | tr -dc '.' | wc -c | awk '{$1=$1;print}'` | ||
|
||
versions=() | ||
|
||
if [[ "$target_version" =~ -dev$ ]]; then | ||
is_dev="true" | ||
target_version=`echo $target_version | sed 's/-dev$//'` | ||
fi | ||
|
||
if [[ "$prefix_count" = "0" ]]; then | ||
if [ ! -z $is_dev ]; then | ||
versions+=("dev") | ||
else | ||
versions+=("latest") | ||
fi | ||
prefix_count="1" | ||
fi | ||
|
||
for (( i=$((${target_version_count}+1)); i>=${prefix_count}; i-- )); do | ||
version=`echo "$target_version" | cut -d. -f1-${i}` | ||
if [ ! -z $is_dev ]; then | ||
version="$version-dev" | ||
fi | ||
versions+=($version) | ||
done | ||
|
||
for version in "${versions[@]}"; do | ||
docker tag ${image_build} ${target_name}:${version} | ||
docker push ${target_name}:${version} | ||
done |