First try for ARM
This commit is contained in:
parent
e31492a9b4
commit
98acefe994
|
@ -1,9 +1,6 @@
|
||||||
name: push
|
name: push
|
||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
|
||||||
branches-ignore:
|
|
||||||
- release
|
|
||||||
pull_request:
|
pull_request:
|
||||||
branches-ignore:
|
branches-ignore:
|
||||||
- release
|
- release
|
||||||
|
@ -47,6 +44,9 @@ jobs:
|
||||||
docker_from:
|
docker_from:
|
||||||
- '' # use the default of the build script
|
- '' # use the default of the build script
|
||||||
- alpine:edge
|
- alpine:edge
|
||||||
|
platform:
|
||||||
|
- linux/amd64
|
||||||
|
- linux/arm64
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
name: Builds new NetBox Docker Images
|
name: Builds new NetBox Docker Images
|
||||||
|
@ -54,12 +54,22 @@ jobs:
|
||||||
- id: git-checkout
|
- id: git-checkout
|
||||||
name: Checkout
|
name: Checkout
|
||||||
uses: actions/checkout@v2
|
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
|
- id: docker-build
|
||||||
name: Build the image from '${{ matrix.docker_from }}' with '${{ matrix.build_cmd }}'
|
name: Build the image from '${{ matrix.docker_from }}' with '${{ matrix.build_cmd }}'
|
||||||
run: ${{ matrix.build_cmd }}
|
run: ${{ matrix.build_cmd }}
|
||||||
env:
|
env:
|
||||||
DOCKER_FROM: ${{ matrix.docker_from }}
|
DOCKER_FROM: ${{ matrix.docker_from }}
|
||||||
GH_ACTION: enable
|
GH_ACTION: enable
|
||||||
|
BUILDX_BUILDER_NAME: ${{ steps.buildx-setup.outputs.name }}
|
||||||
|
PLATFORMS: ${{ matrix.platform }}
|
||||||
- id: docker-test
|
- id: docker-test
|
||||||
name: Test the image
|
name: Test the image
|
||||||
run: IMAGE="${FINAL_DOCKER_TAG}" ./test.sh
|
run: IMAGE="${FINAL_DOCKER_TAG}" ./test.sh
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
name: release
|
name: release
|
||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
release:
|
||||||
branches:
|
types:
|
||||||
- release
|
- published
|
||||||
schedule:
|
schedule:
|
||||||
- cron: '45 5 * * *'
|
- cron: '45 5 * * *'
|
||||||
|
|
||||||
|
@ -16,6 +16,9 @@ jobs:
|
||||||
- PRERELEASE=true ./build-latest.sh
|
- PRERELEASE=true ./build-latest.sh
|
||||||
- ./build.sh feature
|
- ./build.sh feature
|
||||||
- ./build.sh develop
|
- ./build.sh develop
|
||||||
|
platform:
|
||||||
|
- linux/amd64
|
||||||
|
- linux/arm64
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
name: Builds new NetBox Docker Images
|
name: Builds new NetBox Docker Images
|
||||||
|
@ -23,11 +26,24 @@ jobs:
|
||||||
- id: git-checkout
|
- id: git-checkout
|
||||||
name: Checkout
|
name: Checkout
|
||||||
uses: actions/checkout@v2
|
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
|
- id: docker-build
|
||||||
name: Build the image with '${{ matrix.build_cmd }}'
|
name: Build the image with '${{ matrix.build_cmd }}'
|
||||||
run: ${{ matrix.build_cmd }}
|
run: ${{ matrix.build_cmd }}
|
||||||
env:
|
env:
|
||||||
GH_ACTION: enable
|
GH_ACTION: enable
|
||||||
|
BUILDX_BUILDER_NAME: ${{ steps.buildx-setup.outputs.name }}
|
||||||
|
PLATFORMS: ${{ matrix.platform }}
|
||||||
- id: docker-test
|
- id: docker-test
|
||||||
name: Test the image
|
name: Test the image
|
||||||
run: IMAGE="${FINAL_DOCKER_TAG}" ./test.sh
|
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 " DOCKER_TARGET A specific target to build."
|
||||||
echo " It's currently not possible to pass multiple targets."
|
echo " It's currently not possible to pass multiple targets."
|
||||||
echo " Default: main ldap"
|
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 " HTTP_PROXY The proxy to use for http requests."
|
||||||
echo " Example: http://proxy.domain.tld:3128"
|
echo " Example: http://proxy.domain.tld:3128"
|
||||||
echo " Default: undefined"
|
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 " 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 " 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 " 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
|
if [ "${1}x" == "x" ]; then
|
||||||
exit 1
|
exit 1
|
||||||
|
@ -260,9 +267,19 @@ for DOCKER_TARGET in "${DOCKER_TARGETS[@]}"; do
|
||||||
fi
|
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,
|
# Checking if the build is necessary,
|
||||||
# meaning build only if one of those values changed:
|
# meaning build only if one of those values changed:
|
||||||
|
@ -305,11 +322,20 @@ for DOCKER_TARGET in "${DOCKER_TARGETS[@]}"; do
|
||||||
SHOULD_BUILD="true"
|
SHOULD_BUILD="true"
|
||||||
BUILD_REASON="${BUILD_REASON} no-check"
|
BUILD_REASON="${BUILD_REASON} no-check"
|
||||||
fi
|
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`
|
# Composing all arguments for `docker build`
|
||||||
###
|
###
|
||||||
DOCKER_BUILD_ARGS=(
|
DOCKER_BUILD_ARGS=(
|
||||||
--pull
|
--pull
|
||||||
|
--output
|
||||||
--target "${DOCKER_TARGET}"
|
--target "${DOCKER_TARGET}"
|
||||||
-f "${DOCKERFILE}"
|
-f "${DOCKERFILE}"
|
||||||
-t "${TARGET_DOCKER_TAG}"
|
-t "${TARGET_DOCKER_TAG}"
|
||||||
|
@ -362,32 +388,42 @@ for DOCKER_TARGET in "${DOCKER_TARGETS[@]}"; do
|
||||||
DOCKER_BUILD_ARGS+=(--build-arg "no_proxy=${NO_PROXY}")
|
DOCKER_BUILD_ARGS+=(--build-arg "no_proxy=${NO_PROXY}")
|
||||||
fi
|
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
|
if [ "${2}" == "--push" ]; then
|
||||||
echo "🐳 Building the Docker image '${TARGET_DOCKER_TAG}'."
|
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}"
|
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 "✅ Finished building the Docker images '${TARGET_DOCKER_TAG}'"
|
||||||
echo "🔎 Inspecting labels on '${TARGET_DOCKER_TAG}'"
|
echo "🔎 Inspecting labels on '${TARGET_DOCKER_TAG}'"
|
||||||
$DRY docker inspect "${TARGET_DOCKER_TAG}" --format "{{json .Config.Labels}}"
|
$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
|
|
||||||
|
|
||||||
###
|
if [ "${BUILDX_BUILDER_CREATED}" == "yes" ]; then
|
||||||
# Pushing the docker images if either `--push` or `--push-only` are passed
|
echo "👷 Removing Buildx Builder '${BUILDX_BUILDER_NAME}'"
|
||||||
###
|
$DRY docker buildx rm "${BUILDX_BUILDER_NAME}"
|
||||||
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}"
|
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
Loading…
Reference in New Issue