mirror of
https://github.com/Icinga/docker-icingaweb2.git
synced 2025-10-24 05:21:00 +02:00
commit
de1bbe4bff
2
.github/workflows/build.yml
vendored
2
.github/workflows/build.yml
vendored
@ -15,6 +15,8 @@ jobs:
|
|||||||
- name: Checkout HEAD
|
- name: Checkout HEAD
|
||||||
uses: actions/checkout@v1
|
uses: actions/checkout@v1
|
||||||
|
|
||||||
|
- run: docker buildx create --use
|
||||||
|
|
||||||
- name: Icinga Web 2
|
- name: Icinga Web 2
|
||||||
run: git clone https://github.com/Icinga/icingaweb2.git
|
run: git clone https://github.com/Icinga/icingaweb2.git
|
||||||
|
|
||||||
|
|||||||
21
Dockerfile
21
Dockerfile
@ -8,6 +8,23 @@ WORKDIR /entrypoint
|
|||||||
RUN ["go", "build", "."]
|
RUN ["go", "build", "."]
|
||||||
|
|
||||||
|
|
||||||
|
FROM composer:lts as usr-share
|
||||||
|
SHELL ["/bin/bash", "-exo", "pipefail", "-c"]
|
||||||
|
|
||||||
|
RUN ["mkdir", "/usr-share"]
|
||||||
|
WORKDIR /usr-share
|
||||||
|
|
||||||
|
ARG BUILD_MODE
|
||||||
|
COPY get-mods.sh /
|
||||||
|
RUN /get-mods.sh $BUILD_MODE
|
||||||
|
|
||||||
|
COPY composer.bash /
|
||||||
|
RUN ["/composer.bash"]
|
||||||
|
|
||||||
|
COPY --from=icingaweb2-git . /icingaweb2-src/.git
|
||||||
|
RUN git -C /icingaweb2-src archive --prefix=icingaweb2/ HEAD |tar -x
|
||||||
|
|
||||||
|
|
||||||
FROM debian:bullseye-slim
|
FROM debian:bullseye-slim
|
||||||
|
|
||||||
RUN ["bash", "-exo", "pipefail", "-c", "export DEBIAN_FRONTEND=noninteractive; apt-get update; apt-get install --no-install-{recommends,suggests} -y apache2 ca-certificates libapache2-mod-php7.4 libldap-common locales-all php-{imagick,redis} php7.4-{bcmath,bz2,common,curl,dba,enchant,gd,gmp,imap,interbase,intl,json,ldap,mbstring,mysql,odbc,opcache,pgsql,pspell,readline,snmp,soap,sqlite3,sybase,tidy,xml,xmlrpc,xsl,zip}; apt-get clean; rm -vrf /var/lib/apt/lists/*"]
|
RUN ["bash", "-exo", "pipefail", "-c", "export DEBIAN_FRONTEND=noninteractive; apt-get update; apt-get install --no-install-{recommends,suggests} -y apache2 ca-certificates libapache2-mod-php7.4 libldap-common locales-all php-{imagick,redis} php7.4-{bcmath,bz2,common,curl,dba,enchant,gd,gmp,imap,interbase,intl,json,ldap,mbstring,mysql,odbc,opcache,pgsql,pspell,readline,snmp,soap,sqlite3,sybase,tidy,xml,xmlrpc,xsl,zip}; apt-get clean; rm -vrf /var/lib/apt/lists/*"]
|
||||||
@ -33,9 +50,7 @@ RUN ["install", "-o", "www-data", "-g", "www-data", "-d", "/data"]
|
|||||||
|
|
||||||
ENTRYPOINT ["/entrypoint"]
|
ENTRYPOINT ["/entrypoint"]
|
||||||
|
|
||||||
COPY icingaweb2 /usr/share/icingaweb2
|
COPY --from=usr-share /usr-share/. /usr/share/
|
||||||
COPY icinga-php /usr/share/icinga-php
|
|
||||||
COPY icinga-L10n /usr/share/icinga-L10n
|
|
||||||
COPY php.ini /etc/php/7.4/cli/conf.d/99-docker.ini
|
COPY php.ini /etc/php/7.4/cli/conf.d/99-docker.ini
|
||||||
|
|
||||||
RUN ["ln", "-vs", "/usr/share/icingaweb2/bin/icingacli", "/usr/local/bin/"]
|
RUN ["ln", "-vs", "/usr/share/icingaweb2/bin/icingacli", "/usr/local/bin/"]
|
||||||
|
|||||||
@ -1,3 +0,0 @@
|
|||||||
# Icinga Web 2 Docker image | (c) 2020 Icinga GmbH | GPLv2+
|
|
||||||
|
|
||||||
deb [arch=amd64] https://download.docker.com/linux/debian bullseye stable
|
|
||||||
@ -1,39 +0,0 @@
|
|||||||
# Icinga Web 2 Docker image | (c) 2020 Icinga GmbH | GPLv2+
|
|
||||||
|
|
||||||
FROM buildpack-deps:scm as clone
|
|
||||||
SHELL ["/bin/bash", "-exo", "pipefail", "-c"]
|
|
||||||
|
|
||||||
RUN mkdir actions ;\
|
|
||||||
cd actions ;\
|
|
||||||
git clone --bare https://github.com/actions/checkout.git ;\
|
|
||||||
git -C checkout.git archive --prefix=checkout/ v2 |tar -x ;\
|
|
||||||
rm -rf *.git
|
|
||||||
|
|
||||||
|
|
||||||
FROM debian:bullseye-slim
|
|
||||||
SHELL ["/bin/bash", "-exo", "pipefail", "-c"]
|
|
||||||
ENV DEBIAN_FRONTEND noninteractive
|
|
||||||
|
|
||||||
RUN apt-get update ;\
|
|
||||||
apt-get install --no-install-{recommends,suggests} -y \
|
|
||||||
apt-transport-https gnupg2 dirmngr ca-certificates ;\
|
|
||||||
apt-get clean ;\
|
|
||||||
rm -vrf /var/lib/apt/lists/* ;\
|
|
||||||
apt-key adv --fetch-keys https://download.docker.com/linux/debian/gpg ;\
|
|
||||||
apt-get purge -y gnupg2 dirmngr ;\
|
|
||||||
apt-get autoremove --purge -y
|
|
||||||
|
|
||||||
ADD action-base.list /etc/apt/sources.list.d/docker.list
|
|
||||||
|
|
||||||
RUN apt-get update ;\
|
|
||||||
apt-get install --no-install-{recommends,suggests} -y \
|
|
||||||
composer docker-ce-cli git nodejs patch php7.4-zip ;\
|
|
||||||
apt-get clean ;\
|
|
||||||
rm -vrf /var/lib/apt/lists/*
|
|
||||||
|
|
||||||
COPY --from=clone /actions /actions
|
|
||||||
|
|
||||||
COPY action.bash composer.bash Dockerfile get-mods.sh php.ini /
|
|
||||||
COPY entrypoint /entrypoint
|
|
||||||
|
|
||||||
CMD ["/action.bash"]
|
|
||||||
59
action.bash
59
action.bash
@ -1,59 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
# Icinga Web 2 Docker image | (c) 2020 Icinga GmbH | GPLv2+
|
|
||||||
set -exo pipefail
|
|
||||||
|
|
||||||
TARGET=icinga/icingaweb2
|
|
||||||
|
|
||||||
mkimg () {
|
|
||||||
test -n "$TAG"
|
|
||||||
test -n "$MODE"
|
|
||||||
|
|
||||||
node /actions/checkout/dist/index.js |grep -vFe ::add-matcher::
|
|
||||||
|
|
||||||
git archive --prefix=icingaweb2/ HEAD |tar -x
|
|
||||||
|
|
||||||
/get-mods.sh "$MODE"
|
|
||||||
/composer.bash
|
|
||||||
|
|
||||||
cp -r /entrypoint /php.ini .
|
|
||||||
docker build -f /Dockerfile -t "${TARGET}:$TAG" .
|
|
||||||
|
|
||||||
STATE_isPost=1 node /actions/checkout/dist/index.js
|
|
||||||
}
|
|
||||||
|
|
||||||
push () {
|
|
||||||
test -n "$TAG"
|
|
||||||
|
|
||||||
if [ "$(tr -d '\n' <<<"$DOCKER_HUB_PASSWORD" |wc -c)" -gt 0 ]; then
|
|
||||||
docker login -u icingaadmin --password-stdin <<<"$DOCKER_HUB_PASSWORD"
|
|
||||||
docker push "${TARGET}:$TAG"
|
|
||||||
docker logout
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
case "$GITHUB_EVENT_NAME" in
|
|
||||||
workflow_dispatch|schedule|release)
|
|
||||||
case "$GITHUB_REF" in
|
|
||||||
refs/tags/v*)
|
|
||||||
MODE=release
|
|
||||||
TAG=${GITHUB_REF#refs/tags/v}
|
|
||||||
;;
|
|
||||||
refs/heads/*)
|
|
||||||
MODE=snapshot
|
|
||||||
TAG=${GITHUB_REF#refs/heads/}
|
|
||||||
# Remove everything up to the first slash to remove prefixes like "feature/"
|
|
||||||
TAG=${TAG#*/}
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
echo "Unknown ref: $GITHUB_REF" >&2
|
|
||||||
false
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
mkimg
|
|
||||||
push
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
echo "Unknown event: $GITHUB_EVENT_NAME" >&2
|
|
||||||
false
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
39
action.yml
39
action.yml
@ -1,6 +1,41 @@
|
|||||||
# Icinga Web 2 Docker image | (c) 2020 Icinga GmbH | GPLv2+
|
# Icinga Web 2 Docker image | (c) 2020 Icinga GmbH | GPLv2+
|
||||||
|
|
||||||
name: Icinga Web 2 Docker image
|
name: Icinga Web 2 Docker image
|
||||||
|
inputs:
|
||||||
|
dockerhub-token:
|
||||||
|
default: ''
|
||||||
runs:
|
runs:
|
||||||
using: docker
|
using: composite
|
||||||
image: action.Dockerfile
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
|
||||||
|
- shell: bash
|
||||||
|
run: docker buildx create --use
|
||||||
|
|
||||||
|
- if: inputs.dockerhub-token != ''
|
||||||
|
env:
|
||||||
|
PW: ${{ inputs.dockerhub-token }}
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
docker login -u icingaadmin --password-stdin <<<"$PW"
|
||||||
|
|
||||||
|
- if: github.event_name == 'release'
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
TAG="$(tr -d v <<<'${{ github.ref_name }}')"
|
||||||
|
'${{ github.action_path }}/build.bash' .
|
||||||
|
docker tag icinga/icingaweb2 "icinga/icingaweb2:$TAG"
|
||||||
|
docker push "icinga/icingaweb2:$TAG"
|
||||||
|
|
||||||
|
- if: github.event_name == 'workflow_dispatch' || github.event_name == 'schedule'
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
TAG="$(tr / - <<<'${{ github.ref_name }}')"
|
||||||
|
'${{ github.action_path }}/build.bash' . snapshot
|
||||||
|
docker tag icinga/icingaweb2 "icinga/icingaweb2:$TAG"
|
||||||
|
docker push "icinga/icingaweb2:$TAG"
|
||||||
|
|
||||||
|
- if: github.event_name != 'release' && github.event_name != 'workflow_dispatch' && github.event_name != 'schedule'
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
'${{ github.action_path }}/build.bash' . snapshot
|
||||||
|
|||||||
29
build.bash
29
build.bash
@ -13,25 +13,14 @@ EOF
|
|||||||
false
|
false
|
||||||
fi
|
fi
|
||||||
|
|
||||||
IW2SRC="$(realpath "$IW2SRC")"
|
if ! docker version; then
|
||||||
BLDCTX="$(realpath "$(dirname "$0")")"
|
echo 'Docker not found' >&2
|
||||||
|
false
|
||||||
|
fi
|
||||||
|
|
||||||
docker build -f "${BLDCTX}/action.Dockerfile" -t icinga/icingaweb2-builder "$BLDCTX"
|
if ! docker buildx version; then
|
||||||
|
echo '"docker buildx" not found (see https://docs.docker.com/buildx/working-with-buildx/ )' >&2
|
||||||
|
false
|
||||||
|
fi
|
||||||
|
|
||||||
docker run --rm -i \
|
docker buildx build --load -t icinga/icingaweb2 --build-context "icingaweb2-git=$(realpath "$IW2SRC")/.git" --build-arg "BUILD_MODE=$BUILD_MODE" "$(realpath "$(dirname "$0")")"
|
||||||
-v "${IW2SRC}:/iw2src:ro" \
|
|
||||||
-v "${BLDCTX}:/bldctx:ro" \
|
|
||||||
-v /var/run/docker.sock:/var/run/docker.sock \
|
|
||||||
-e BUILD_MODE \
|
|
||||||
icinga/icingaweb2-builder bash <<EOF
|
|
||||||
set -exo pipefail
|
|
||||||
|
|
||||||
git -C /iw2src archive --prefix=iw2cp/icingaweb2/ HEAD |tar -xC /
|
|
||||||
cd /iw2cp
|
|
||||||
|
|
||||||
/bldctx/get-mods.sh "$BUILD_MODE"
|
|
||||||
/bldctx/composer.bash
|
|
||||||
|
|
||||||
cp -r /entrypoint /bldctx/php.ini .
|
|
||||||
docker build -f /bldctx/Dockerfile -t icinga/icingaweb2 .
|
|
||||||
EOF
|
|
||||||
|
|||||||
11
get-mods.sh
11
get-mods.sh
@ -12,11 +12,16 @@ EOF
|
|||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get_first_line() {
|
||||||
|
head -n 1
|
||||||
|
cat >/dev/null
|
||||||
|
}
|
||||||
|
|
||||||
get_tag () {
|
get_tag () {
|
||||||
if git -C dockerweb2-temp tag |grep -qvFe -; then # ex. RCs
|
if git -C dockerweb2-temp tag |grep -vFe - >/dev/null; then # ex. RCs
|
||||||
git -C dockerweb2-temp tag --sort=-version:refname |grep -vFe - |head -n 1
|
git -C dockerweb2-temp tag --sort=-version:refname |grep -vFe - |get_first_line
|
||||||
else
|
else
|
||||||
git -C dockerweb2-temp tag --sort=-version:refname |grep -Fe - |head -n 1
|
git -C dockerweb2-temp tag --sort=-version:refname |grep -Fe - |get_first_line
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user