Skip to content

Commit

Permalink
hooks
Browse files Browse the repository at this point in the history
  • Loading branch information
Tob1as committed Apr 6, 2021
1 parent f86ca15 commit 0b67341
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# https://github.com/github/gitignore/blob/master/Global/JetBrains.gitignore
.idea/
*.iml
18 changes: 18 additions & 0 deletions hooks/build
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/bin/bash

# Autobuild the Image on Docker Hub with advanced options and buildx for multiarch images
# read more: https://github.com/Tob1asDocker/dockerhubhooksexample

# '--push' shorthand for '--output=type=registry'

set -ex

echo "### RUN build START: using buildx ###"
echo "Image Name: ${IMAGE_NAME} (Repo: ${DOCKER_REPO}, Tag: ${DOCKER_TAG})"
echo "Dockerfile Path/Name: ${DOCKERFILE_PATH}"
BUILDPLATFORM="${BUILDPLATFORM:-"linux/amd64,linux/arm64,linux/arm/v7,linux/arm/v6"}"
echo "Architectures=${BUILDPLATFORM}"

docker buildx build --build-arg BUILD_DATE="$(date -u +'%Y-%m-%dT%H:%M:%SZ')" --build-arg VCS_REF="$(git rev-parse --short HEAD)" --tag "${IMAGE_NAME}" --platform "${BUILDPLATFORM}" --file "${DOCKERFILE_PATH}" --push .

echo "### RUN build END"
26 changes: 26 additions & 0 deletions hooks/pre_build
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/bin/bash

# Autobuild the Image on Docker Hub with advanced options and buildx for multiarch images
# read more: https://github.com/Tob1asDocker/dockerhubhooksexample

set -ex

echo "### RUN pre_build START: QEMU and buildx ###"

# docker settings
#export DOCKER_CLI_EXPERIMENTAL=enabled
#export DOCKER_BUILDKIT=1

# need binfmt-support and qemu-user-static
#apt-get update && apt-get install -y qemu-user-static binfmt-support
#docker run --rm --privileged multiarch/qemu-user-static --reset -p yes
docker run --rm --privileged multiarch/qemu-user-static:register --reset

# docker buildx settings
#docker buildx create --name multiarchbuilder
#docker buildx use multiarchbuilder
docker buildx create --use --name multiarchbuilder
#docker buildx inspect --bootstrap
docker buildx ls

echo "### RUN pre_build END ###"
7 changes: 7 additions & 0 deletions hooks/push
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/bash

# If use 'docker buildx build' then disable the push of 'docker build', because the push has already been done and fails here.

set -ex

echo "### RUN push: This has already been done by buildx. ###"

0 comments on commit 0b67341

Please sign in to comment.