netbox-docker/hooks/common
Christian Mäder d0ebb34432 Refactor to multistage builds
This commit introduces a huge change in the build process.

What changed:

- Dockerfile.ldap was integrated into Dockerfile as a seperate
  [build stage][multistage-build].
- All the build scripts were refactored according to this.
- The `docker-compose.yml` file was adjusted likewise.
- The main build script, `/build.sh`, now always builds all
  targets (formerly called variants).
- The minimal requirements for Docker and docker-compose
  have increased.
- The build on hub.docker.com must be adjusted.

This change should also fix #156 permanently.

[multistage-build]: https://docs.docker.com/develop/develop-images/multistage-build/
2019-10-15 00:34:15 +02:00

55 lines
1.2 KiB
Bash
Executable File

#!/bin/bash
ensure_jq() {
if [ ! -x "$(command -v jq)" ]; then
if [ ! -x "$(command -v apt-get)" ]; then
echo "🛠🛠🛠 Installing 'jq' via 'apt-get'"
apt-get update && apt-get install -y jq
else
echo "⚠️⚠️⚠️ apt-get not found, unable to automatically install 'jq'."
fi
fi
}
# Passes args to the scripts
run_build() {
echo "🐳🐳🐳 Building '${BUILD}' images"
case $BUILD in
release)
# build the latest release
# shellcheck disable=SC2068
./build-latest.sh $@
;;
prerelease)
# build the latest pre-release
# shellcheck disable=SC2068
PRERELEASE=true ./build-latest.sh $@
;;
branches)
# build all branches
# shellcheck disable=SC2068
./build-branches.sh $@
;;
*)
echo "🚨 Unrecognized build '$BUILD'."
if [ -z "$DEBUG" ]; then
exit 1
else
echo "⚠️ Would exit here with code '1', but DEBUG is enabled."
fi
;;
esac
}
echo "🤖🤖🤖 Preparing build"
export DOCKER_ORG="index.docker.io/netboxcommunity"
export DOCKER_REPO=netbox
export DOCKERHUB_REPO=netboxcommunity/netbox
# shellcheck disable=SC2153
export BUILD="$DOCKER_TAG"
unset DOCKER_TAG
ensure_jq