clear up the build arg & tag logic
This commit is contained in:
parent
ac3b128bf6
commit
70983fda59
1 changed files with 14 additions and 9 deletions
23
buildx.sh
23
buildx.sh
|
@ -69,20 +69,25 @@ main() {
|
||||||
BUILD_ARGS=""
|
BUILD_ARGS=""
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
IMAGE="privatebin/$IMAGE"
|
IMAGE="privatebin/$IMAGE:"
|
||||||
|
IMAGE_TAGS="--tag $IMAGE:latest --tag $IMAGE:$TAG --tag ${IMAGE}:${TAG%%-*}"
|
||||||
|
|
||||||
if [ "$EDGE" = true ] ; then
|
if [ "$EDGE" = true ] ; then
|
||||||
|
# build from alpine:edge instead of the stable release
|
||||||
sed -e 's/^FROM alpine:.*$/FROM alpine:edge/' Dockerfile > Dockerfile.edge
|
sed -e 's/^FROM alpine:.*$/FROM alpine:edge/' Dockerfile > Dockerfile.edge
|
||||||
BUILD_ARGS="-f Dockerfile.edge --tag $IMAGE:edge $BUILD_ARGS"
|
BUILD_ARGS+=" -f Dockerfile.edge"
|
||||||
IMAGE="$IMAGE:edge"
|
|
||||||
elif [ "$EVENT" = push ] ; then
|
# replace the default tags, build just the edge one
|
||||||
BUILD_ARGS="--tag $IMAGE:latest --tag $IMAGE:$TAG --tag ${IMAGE}:${TAG%%-*} --tag ${IMAGE}:stable $BUILD_ARGS"
|
IMAGE_TAGS="--tag $IMAGE:edge"
|
||||||
IMAGE="$IMAGE:latest"
|
IMAGE+="edge"
|
||||||
else
|
else
|
||||||
BUILD_ARGS="--tag $IMAGE:latest --tag $IMAGE:$TAG --tag ${IMAGE}:${TAG%%-*} $BUILD_ARGS"
|
if [ "$EVENT" = push ] ; then
|
||||||
IMAGE="$IMAGE:latest"
|
# append the stable tag on explicit pushes to master or (git) tags
|
||||||
|
IMAGE_TAGS+=" --tag ${IMAGE}:stable"
|
||||||
|
fi
|
||||||
|
IMAGE+="latest"
|
||||||
fi
|
fi
|
||||||
build_image "$BUILD_ARGS"
|
build_image "$BUILD_ARGS $IMAGE_TAGS"
|
||||||
|
|
||||||
docker run -d --rm -p 127.0.0.1:8080:8080 --read-only --name smoketest "$IMAGE"
|
docker run -d --rm -p 127.0.0.1:8080:8080 --read-only --name smoketest "$IMAGE"
|
||||||
sleep 5 # give the services time to start up and the log to collect any errors that might occur
|
sleep 5 # give the services time to start up and the log to collect any errors that might occur
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue