First try for ARM
This commit is contained in:
parent
e31492a9b4
commit
98acefe994
|
@ -1,9 +1,6 @@
|
|||
name: push
|
||||
|
||||
on:
|
||||
push:
|
||||
branches-ignore:
|
||||
- release
|
||||
pull_request:
|
||||
branches-ignore:
|
||||
- release
|
||||
|
@ -47,6 +44,9 @@ jobs:
|
|||
docker_from:
|
||||
- '' # use the default of the build script
|
||||
- alpine:edge
|
||||
platform:
|
||||
- linux/amd64
|
||||
- linux/arm64
|
||||
fail-fast: false
|
||||
runs-on: ubuntu-latest
|
||||
name: Builds new NetBox Docker Images
|
||||
|
@ -54,12 +54,22 @@ jobs:
|
|||
- id: git-checkout
|
||||
name: Checkout
|
||||
uses: actions/checkout@v2
|
||||
- id: qemu-setup
|
||||
name: Set up QEMU
|
||||
uses: docker/setup-qemu-action@v1
|
||||
- id: buildx-setup
|
||||
name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v1
|
||||
with:
|
||||
install: true
|
||||
- id: docker-build
|
||||
name: Build the image from '${{ matrix.docker_from }}' with '${{ matrix.build_cmd }}'
|
||||
run: ${{ matrix.build_cmd }}
|
||||
env:
|
||||
DOCKER_FROM: ${{ matrix.docker_from }}
|
||||
GH_ACTION: enable
|
||||
BUILDX_BUILDER_NAME: ${{ steps.buildx-setup.outputs.name }}
|
||||
PLATFORMS: ${{ matrix.platform }}
|
||||
- id: docker-test
|
||||
name: Test the image
|
||||
run: IMAGE="${FINAL_DOCKER_TAG}" ./test.sh
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
name: release
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- release
|
||||
release:
|
||||
types:
|
||||
- published
|
||||
schedule:
|
||||
- cron: '45 5 * * *'
|
||||
|
||||
|
@ -16,6 +16,9 @@ jobs:
|
|||
- PRERELEASE=true ./build-latest.sh
|
||||
- ./build.sh feature
|
||||
- ./build.sh develop
|
||||
platform:
|
||||
- linux/amd64
|
||||
- linux/arm64
|
||||
fail-fast: false
|
||||
runs-on: ubuntu-latest
|
||||
name: Builds new NetBox Docker Images
|
||||
|
@ -23,11 +26,24 @@ jobs:
|
|||
- id: git-checkout
|
||||
name: Checkout
|
||||
uses: actions/checkout@v2
|
||||
- id: qemu-setup
|
||||
name: Set up QEMU
|
||||
uses: docker/setup-qemu-action@v1
|
||||
- id: buildx-setup
|
||||
name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v1
|
||||
with:
|
||||
install: true
|
||||
- id: buildx-platforms
|
||||
name: Available platforms
|
||||
run: echo ${{ steps.buildx-setup.outputs.platforms }}
|
||||
- id: docker-build
|
||||
name: Build the image with '${{ matrix.build_cmd }}'
|
||||
run: ${{ matrix.build_cmd }}
|
||||
env:
|
||||
GH_ACTION: enable
|
||||
BUILDX_BUILDER_NAME: ${{ steps.buildx-setup.outputs.name }}
|
||||
PLATFORMS: ${{ matrix.platform }}
|
||||
- id: docker-test
|
||||
name: Test the image
|
||||
run: IMAGE="${FINAL_DOCKER_TAG}" ./test.sh
|
||||
|
|
78
build.sh
78
build.sh
|
@ -53,6 +53,9 @@ if [ "${1}x" == "x" ] || [ "${1}" == "--help" ] || [ "${1}" == "-h" ]; then
|
|||
echo " DOCKER_TARGET A specific target to build."
|
||||
echo " It's currently not possible to pass multiple targets."
|
||||
echo " Default: main ldap"
|
||||
echo " BUILDX_PLATFORMS If defined, the image will be build for the given platform(s)."
|
||||
echo " Example: linux/amd64,linux/arm64"
|
||||
echo " Default: linux/amd64"
|
||||
echo " HTTP_PROXY The proxy to use for http requests."
|
||||
echo " Example: http://proxy.domain.tld:3128"
|
||||
echo " Default: undefined"
|
||||
|
@ -87,6 +90,10 @@ if [ "${1}x" == "x" ] || [ "${1}" == "--help" ] || [ "${1}" == "-h" ]; then
|
|||
echo " SRC_ORG=cimnine DOCKER_ORG=cimnine ${0} feature-x"
|
||||
echo " This will fetch the 'feature-x' branch from https://github.com/cimnine/netbox.git,"
|
||||
echo " build a Docker Image and tag it 'cimnine/netbox:feature-x'."
|
||||
echo " PLATFORMS=linux/amd64,linux/arm64 ${0} master"
|
||||
echo " This will fetch the latest 'master' branch, build a Docker Image and tag it"
|
||||
echo " 'netboxcommunity/netbox:latest'."
|
||||
echo " It will produce an ARM64 and an AMD64 version of the image."
|
||||
|
||||
if [ "${1}x" == "x" ]; then
|
||||
exit 1
|
||||
|
@ -260,9 +267,19 @@ for DOCKER_TARGET in "${DOCKER_TARGETS[@]}"; do
|
|||
fi
|
||||
|
||||
###
|
||||
# Proceeding to buils stage, except if `--push-only` is passed
|
||||
# If `--push-only` is passed, just push and then quit
|
||||
###
|
||||
if [ "${2}" != "--push-only" ]; then
|
||||
if [ "${2}" == "--push-only" ]; then
|
||||
source ./build-functions/docker-functions.sh
|
||||
push_image_to_registry "${TARGET_DOCKER_TAG}"
|
||||
|
||||
if [ -n "${TARGET_DOCKER_SHORT_TAG}" ]; then
|
||||
push_image_to_registry "${TARGET_DOCKER_SHORT_TAG}"
|
||||
push_image_to_registry "${TARGET_DOCKER_LATEST_TAG}"
|
||||
fi
|
||||
exit 1
|
||||
fi
|
||||
|
||||
###
|
||||
# Checking if the build is necessary,
|
||||
# meaning build only if one of those values changed:
|
||||
|
@ -305,11 +322,20 @@ for DOCKER_TARGET in "${DOCKER_TARGETS[@]}"; do
|
|||
SHOULD_BUILD="true"
|
||||
BUILD_REASON="${BUILD_REASON} no-check"
|
||||
fi
|
||||
|
||||
###
|
||||
# Building the docker image
|
||||
###
|
||||
if [ "${SHOULD_BUILD}" != "true" ]; then
|
||||
echo "Build skipped because sources didn't change"
|
||||
echo "::set-output name=skipped::true"
|
||||
else
|
||||
###
|
||||
# Composing all arguments for `docker build`
|
||||
###
|
||||
DOCKER_BUILD_ARGS=(
|
||||
--pull
|
||||
--output
|
||||
--target "${DOCKER_TARGET}"
|
||||
-f "${DOCKERFILE}"
|
||||
-t "${TARGET_DOCKER_TAG}"
|
||||
|
@ -362,32 +388,42 @@ for DOCKER_TARGET in "${DOCKER_TARGETS[@]}"; do
|
|||
DOCKER_BUILD_ARGS+=(--build-arg "no_proxy=${NO_PROXY}")
|
||||
fi
|
||||
|
||||
# --platform
|
||||
DOCKER_BUILD_ARGS+=(--platform "${PLATFORMS-linux/amd64}")
|
||||
|
||||
# --cache-from / --cache-to
|
||||
DOCKER_BUILD_ARGS+=("--cache-from=type=registry,ref=${TARGET_DOCKER_TAG}-cache,mode=max")
|
||||
DOCKER_BUILD_ARGS+=("--cache-to=type=registry,ref=${TARGET_DOCKER_TAG}-cache,mode=max")
|
||||
|
||||
###
|
||||
# Building the docker image
|
||||
# Pushing the docker images if `--push` is passed
|
||||
###
|
||||
if [ "${SHOULD_BUILD}" == "true" ]; then
|
||||
echo "🐳 Building the Docker image '${TARGET_DOCKER_TAG}'."
|
||||
if [ "${2}" == "--push" ]; then
|
||||
DOCKER_BUILD_ARGS+=(--push)
|
||||
fi
|
||||
|
||||
if [ -z "${BUILDX_BUILDER_NAME}" ]; then
|
||||
echo "👷 Creating new Buildx Builder"
|
||||
BUILDX_BUILDER_NAME=$($DRY docker buildx create)
|
||||
BUILDX_BUILDER_CREATED="yes"
|
||||
fi
|
||||
|
||||
echo "🐳 Building the Docker image '${TARGET_DOCKER_TAG}' on '${BUILDX_BUILDER_NAME}'."
|
||||
echo " Build reason set to: ${BUILD_REASON}"
|
||||
$DRY docker build "${DOCKER_BUILD_ARGS[@]}" .
|
||||
|
||||
$DRY docker buildx \
|
||||
--builder "${BUILDX_BUILDER_NAME}" \
|
||||
build \
|
||||
"${DOCKER_BUILD_ARGS[@]}" \
|
||||
.
|
||||
|
||||
echo "✅ Finished building the Docker images '${TARGET_DOCKER_TAG}'"
|
||||
echo "🔎 Inspecting labels on '${TARGET_DOCKER_TAG}'"
|
||||
$DRY docker inspect "${TARGET_DOCKER_TAG}" --format "{{json .Config.Labels}}"
|
||||
else
|
||||
echo "Build skipped because sources didn't change"
|
||||
echo "::set-output name=skipped::true"
|
||||
fi
|
||||
fi
|
||||
|
||||
###
|
||||
# Pushing the docker images if either `--push` or `--push-only` are passed
|
||||
###
|
||||
if [ "${2}" == "--push" ] || [ "${2}" == "--push-only" ]; then
|
||||
source ./build-functions/docker-functions.sh
|
||||
push_image_to_registry "${TARGET_DOCKER_TAG}"
|
||||
|
||||
if [ -n "${TARGET_DOCKER_SHORT_TAG}" ]; then
|
||||
push_image_to_registry "${TARGET_DOCKER_SHORT_TAG}"
|
||||
push_image_to_registry "${TARGET_DOCKER_LATEST_TAG}"
|
||||
if [ "${BUILDX_BUILDER_CREATED}" == "yes" ]; then
|
||||
echo "👷 Removing Buildx Builder '${BUILDX_BUILDER_NAME}'"
|
||||
$DRY docker buildx rm "${BUILDX_BUILDER_NAME}"
|
||||
fi
|
||||
fi
|
||||
done
|
||||
|
|
Loading…
Reference in New Issue