add a smoketest of the amd64 image, before pushing all archs
This commit is contained in:
parent
f15474e7c8
commit
0fa6605d91
1 changed files with 32 additions and 16 deletions
48
buildx.sh
48
buildx.sh
|
@ -10,17 +10,22 @@ EDGE=false
|
||||||
[ "$3" = edge ] && EDGE=true
|
[ "$3" = edge ] && EDGE=true
|
||||||
|
|
||||||
build_image() {
|
build_image() {
|
||||||
local PUSH
|
|
||||||
PUSH=$1
|
|
||||||
shift 1
|
|
||||||
|
|
||||||
docker buildx build \
|
docker buildx build \
|
||||||
--platform linux/amd64,linux/386,linux/arm/v6,linux/arm/v7,linux/arm64,linux/ppc64le \
|
--platform linux/amd64,linux/386,linux/arm/v6,linux/arm/v7,linux/arm64,linux/ppc64le \
|
||||||
--output type=image,push="$PUSH" \
|
--progress plain \
|
||||||
|
--output type=image \
|
||||||
--pull \
|
--pull \
|
||||||
--no-cache \
|
--no-cache \
|
||||||
|
"$@" \
|
||||||
|
.
|
||||||
|
}
|
||||||
|
|
||||||
|
push_image() {
|
||||||
|
docker buildx build \
|
||||||
|
--platform linux/amd64,linux/386,linux/arm/v6,linux/arm/v7,linux/arm64,linux/ppc64le \
|
||||||
--progress plain \
|
--progress plain \
|
||||||
$@ \
|
--push \
|
||||||
|
"$@" \
|
||||||
.
|
.
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -38,7 +43,7 @@ is_image_push_required() {
|
||||||
}
|
}
|
||||||
|
|
||||||
main() {
|
main() {
|
||||||
local PUSH TAG BUILD_ARGS
|
local TAG BUILD_ARGS
|
||||||
|
|
||||||
if [ "$EVENT" = schedule ] ; then
|
if [ "$EVENT" = schedule ] ; then
|
||||||
TAG=nightly
|
TAG=nightly
|
||||||
|
@ -46,13 +51,6 @@ main() {
|
||||||
TAG=${GITHUB_REF##*/}
|
TAG=${GITHUB_REF##*/}
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if is_image_push_required ; then
|
|
||||||
PUSH=true
|
|
||||||
docker_login
|
|
||||||
else
|
|
||||||
PUSH=false
|
|
||||||
fi
|
|
||||||
|
|
||||||
case "$IMAGE" in
|
case "$IMAGE" in
|
||||||
fs)
|
fs)
|
||||||
BUILD_ARGS="--build-arg ALPINE_PACKAGES= --build-arg COMPOSER_PACKAGES="
|
BUILD_ARGS="--build-arg ALPINE_PACKAGES= --build-arg COMPOSER_PACKAGES="
|
||||||
|
@ -71,9 +69,27 @@ main() {
|
||||||
|
|
||||||
if [ "$EDGE" = true ] ; then
|
if [ "$EDGE" = true ] ; then
|
||||||
sed -e 's/^FROM alpine:.*$/FROM alpine:edge/' Dockerfile > Dockerfile.edge
|
sed -e 's/^FROM alpine:.*$/FROM alpine:edge/' Dockerfile > Dockerfile.edge
|
||||||
build_image $PUSH -f Dockerfile.edge --tag "$IMAGE:edge" "$BUILD_ARGS"
|
BUILD_ARGS="-f Dockerfile.edge --tag $IMAGE:edge $BUILD_ARGS"
|
||||||
|
IMAGE="$IMAGE:edge"
|
||||||
else
|
else
|
||||||
build_image $PUSH --tag "$IMAGE:latest" --tag "$IMAGE:$TAG" --tag "${IMAGE}:${TAG%%-*}" "$BUILD_ARGS"
|
BUILD_ARGS="--tag $IMAGE:latest --tag $IMAGE:$TAG --tag ${IMAGE}:${TAG%%-*} $BUILD_ARGS"
|
||||||
|
IMAGE="$IMAGE:latest"
|
||||||
|
fi
|
||||||
|
build_image "$BUILD_ARGS"
|
||||||
|
|
||||||
|
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
|
||||||
|
test "$(docker inspect --format="{{.State.Running}}" smoketest)" = true
|
||||||
|
curl --silent --show-error -o /dev/null http://127.0.0.1:8080/
|
||||||
|
if docker logs smoketest 2>&1 | grep -E "warn|emerg|fatal|panic"
|
||||||
|
then
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
docker stop smoketest
|
||||||
|
|
||||||
|
if is_image_push_required ; then
|
||||||
|
docker_login
|
||||||
|
push_image "$BUILD_ARGS"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
rm -f Dockerfile.edge "$HOME/.docker/config.json"
|
rm -f Dockerfile.edge "$HOME/.docker/config.json"
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue