Merge pull request #10 from Icinga/feature/build-local

Add build.bash
This commit is contained in:
Noah Hilverling 2020-07-07 14:58:12 +02:00 committed by GitHub
commit 537d520f91
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 52 additions and 12 deletions

View File

@ -1,5 +1,5 @@
FROM icinga/icingaweb2-builder
COPY action.bash Dockerfile get-mods.sh icingaweb2.patch /
COPY action.bash composer.bash Dockerfile get-mods.sh icingaweb2.patch /
CMD ["/action.bash"]

View File

@ -9,18 +9,9 @@ mkimg () {
node /actions/checkout/dist/index.js |grep -vFe ::add-matcher::
git archive --prefix=icingaweb2/ HEAD |tar -x
/get-mods.sh "$1"
for d in icingaweb2 icingaweb2/modules/*; do
pushd "$d"
if [ -e composer.json ]; then
composer install --no-dev --ignore-platform-reqs
fi
popd
done
/composer.bash
patch -d icingaweb2 -p0 < /icingaweb2.patch
docker build -f /Dockerfile -t "${TARGET}:$TAG" .

37
build.bash Executable file
View File

@ -0,0 +1,37 @@
#!/bin/bash
set -exo pipefail
IW2SRC="$1"
export MODS_BRANCH="$2"
if [ -z "$IW2SRC" ]; then
cat <<EOF >&2
Usage: ${0} /icingaweb2/source/dir
EOF
false
fi
IW2SRC="$(realpath "$IW2SRC")"
BLDCTX="$(realpath "$(dirname "$0")")"
docker build -f "${BLDCTX}/action-base.Dockerfile" -t icinga/icingaweb2-builder "$BLDCTX"
docker build -f "${BLDCTX}/deps.Dockerfile" -t icinga/icingaweb2-deps "$BLDCTX"
docker run --rm -i \
-v "${IW2SRC}:/iw2src:ro" \
-v "${BLDCTX}:/bldctx:ro" \
-v /var/run/docker.sock:/var/run/docker.sock \
-e MODS_BRANCH \
icinga/icingaweb2-builder bash <<EOF
set -exo pipefail
git -C /iw2src archive --prefix=iw2cp/icingaweb2/ HEAD |tar -xC /
cd /iw2cp
/bldctx/get-mods.sh "$MODS_BRANCH"
/bldctx/composer.bash
patch -d icingaweb2 -p0 < /bldctx/icingaweb2.patch
docker build -f /bldctx/Dockerfile -t icinga/icingaweb2 .
EOF

12
composer.bash Executable file
View File

@ -0,0 +1,12 @@
#!/bin/bash
set -exo pipefail
for d in icingaweb2 icingaweb2/modules/*; do
pushd "$d"
if [ -e composer.json ]; then
composer install --no-dev --ignore-platform-reqs
fi
popd
done