Skip to content

Commit

Permalink
fix(gorgone): use Centreon version to create 1 docker images per vers…
Browse files Browse the repository at this point in the history
…ion with the right repo
  • Loading branch information
sdepassio committed Nov 12, 2024
1 parent 5db88ff commit ec5db1c
Show file tree
Hide file tree
Showing 8 changed files with 93 additions and 115 deletions.
23 changes: 19 additions & 4 deletions .github/docker/Dockerfile.gorgone-testing-alma8
Original file line number Diff line number Diff line change
@@ -1,12 +1,27 @@
FROM almalinux:8
ARG REGISTRY_URL=docker.io
ARG VERSION

RUN bash -e <<EOF
FROM ${REGISTRY_URL}/almalinux:8

ARG VERSION
ARG IS_CLOUD

RUN --mount=type=secret,id=ARTIFACTORY_INTERNAL_REPO_USERNAME \
--mount=type=secret,id=ARTIFACTORY_INTERNAL_REPO_PASSWORD \
bash -e <<EOF

dnf install -y dnf-plugins-core zstd curl mariadb iproute procps lsof
dnf install -y https://rpms.remirepo.net/enterprise/remi-release-8.rpm
dnf config-manager --set-enabled 'powertools'
dnf -y config-manager --add-repo https://packages.centreon.com/rpm-standard/23.10/el8/centreon-23.10.repo
dnf -y clean all --enablerepo=*

if [[ "${IS_CLOUD}" == "1" ]]; then
dnf config-manager --add-repo https://$(cat /run/secrets/ARTIFACTORY_INTERNAL_REPO_USERNAME):$(cat /run/secrets/ARTIFACTORY_INTERNAL_REPO_PASSWORD)@packages.centreon.com/rpm-standard-internal/${VERSION}/el8/centreon-${VERSION}-internal.repo
sed -i "s#packages.centreon.com/rpm-standard-internal#$(cat /run/secrets/ARTIFACTORY_INTERNAL_REPO_USERNAME):$(cat /run/secrets/ARTIFACTORY_INTERNAL_REPO_PASSWORD)@packages.centreon.com/rpm-standard-internal#" /etc/yum.repos.d/centreon-${VERSION}-internal.repo
else
dnf config-manager --add-repo https://packages.centreon.com/rpm-standard/${VERSION}/el8/centreon-${VERSION}.repo
fi
dnf config-manager --set-enabled 'centreon*'

dnf install -y python3.11 python3.11-pip
pip3.11 install robotframework robotframework-examples robotframework-databaselibrary pymysql robotframework-requests robotframework-jsonlibrary

Expand Down
23 changes: 19 additions & 4 deletions .github/docker/Dockerfile.gorgone-testing-alma9
Original file line number Diff line number Diff line change
@@ -1,14 +1,29 @@
FROM almalinux:9
ARG REGISTRY_URL=docker.io
ARG VERSION

RUN bash -e <<EOF
FROM ${REGISTRY_URL}/almalinux:9

ARG VERSION
ARG IS_CLOUD

RUN --mount=type=secret,id=ARTIFACTORY_INTERNAL_REPO_USERNAME \
--mount=type=secret,id=ARTIFACTORY_INTERNAL_REPO_PASSWORD \
bash -e <<EOF

dnf install -y dnf-plugins-core zstd mariadb iproute epel-release procps lsof
dnf config-manager --set-enabled crb
dnf config-manager --add-repo https://packages.centreon.com/rpm-standard/23.10/el9/centreon-23.10.repo

if [[ "${IS_CLOUD}" == "1" ]]; then
dnf config-manager --add-repo https://$(cat /run/secrets/ARTIFACTORY_INTERNAL_REPO_USERNAME):$(cat /run/secrets/ARTIFACTORY_INTERNAL_REPO_PASSWORD)@packages.centreon.com/rpm-standard-internal/${VERSION}/el9/centreon-${VERSION}-internal.repo
sed -i "s#packages.centreon.com/rpm-standard-internal#$(cat /run/secrets/ARTIFACTORY_INTERNAL_REPO_USERNAME):$(cat /run/secrets/ARTIFACTORY_INTERNAL_REPO_PASSWORD)@packages.centreon.com/rpm-standard-internal#" /etc/yum.repos.d/centreon-${VERSION}-internal.repo
else
dnf config-manager --add-repo https://packages.centreon.com/rpm-standard/${VERSION}/el9/centreon-${VERSION}.repo
fi
dnf config-manager --set-enabled 'centreon*'

dnf install -y python3.11 python3.11-pip
pip3.11 install robotframework robotframework-examples robotframework-databaselibrary pymysql robotframework-requests robotframework-jsonlibrary


dnf clean all

EOF
25 changes: 20 additions & 5 deletions .github/docker/Dockerfile.gorgone-testing-bookworm
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
FROM debian:bookworm
ARG REGISTRY_URL=docker.io
ARG VERSION

FROM ${REGISTRY_URL}/debian:bookworm

ARG VERSION

ENV DEBIAN_FRONTEND=noninteractive

Expand All @@ -18,11 +23,21 @@ pip3 install --break-system-packages --no-cache-dir \
robotframework robotframework-examples robotframework-databaselibrary \
pymysql robotframework-requests robotframework-jsonlibrary

# can't use \$() method it would be executed before the main script, and lsb_release would not be installed.
lsb_release -sc | xargs -I % sh -c 'echo deb https://packages.centreon.com/apt-standard-24.09-stable/ % main' | tee /etc/apt/sources.list.d/centreon.list
lsb_release -sc | xargs -I % sh -c 'echo deb https://packages.centreon.com/apt-plugins-stable/ % main' | tee /etc/apt/sources.list.d/centreon-plugins.list
VERSION_CODENAME=\$(
. /etc/os-release
echo \$VERSION_CODENAME
)

echo "deb https://packages.centreon.com/apt-standard-${VERSION}-stable/ \$VERSION_CODENAME main" | tee -a /etc/apt/sources.list.d/centreon-stable.list
echo "deb https://packages.centreon.com/apt-standard-${VERSION}-testing/ \$VERSION_CODENAME main" | tee -a /etc/apt/sources.list.d/centreon-testing.list
echo "deb https://packages.centreon.com/apt-standard-${VERSION}-unstable/ \$VERSION_CODENAME main" | tee -a /etc/apt/sources.list.d/centreon-unstable.list
echo "deb https://packages.centreon.com/apt-plugins-stable/ \$VERSION_CODENAME main" | tee -a /etc/apt/sources.list.d/centreon-plugins-stable.list
echo "deb https://packages.centreon.com/apt-plugins-testing/ \$VERSION_CODENAME main" | tee -a /etc/apt/sources.list.d/centreon-plugins-testing.list
echo "deb https://packages.centreon.com/apt-plugins-unstable/ \$VERSION_CODENAME main" | tee -a /etc/apt/sources.list.d/centreon-plugins-unstable.list
wget -O- https://packages.centreon.com/api/security/keypair/APT-GPG-KEY/public | gpg --dearmor | tee /etc/apt/trusted.gpg.d/centreon.gpg > /dev/null 2>&1

apt-get update

wget -O- https://apt-key.centreon.com | gpg --dearmor | tee /etc/apt/trusted.gpg.d/centreon.gpg > /dev/null 2>&1
apt-get clean
rm -rf /var/lib/apt/lists/*

Expand Down
28 changes: 0 additions & 28 deletions .github/docker/Dockerfile.gorgone-testing-bullseye

This file was deleted.

41 changes: 0 additions & 41 deletions .github/docker/Dockerfile.gorgone-testing-jammy

This file was deleted.

24 changes: 19 additions & 5 deletions .github/workflows/docker-gorgone-testing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,14 @@ jobs:

dockerize:
needs: [get-version]
runs-on: ubuntu-22.04
runs-on: ubuntu-24.04

strategy:
matrix:
distrib: [alma8, alma9, bookworm, jammy]
distrib: [alma8, alma9, bookworm] # No ubuntu in 24.10, 24.11 or later for now
steps:
- name: Checkout sources
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0

- name: Login to registry
uses: docker/login-action@9780b0c442fbb1117ed29e0efdff1e18412f7567 # v3.3.0
Expand All @@ -40,12 +40,26 @@ jobs:
username: ${{ secrets.HARBOR_CENTREON_PUSH_USERNAME }}
password: ${{ secrets.HARBOR_CENTREON_PUSH_TOKEN }}

- name: Login to proxy registry
uses: docker/login-action@9780b0c442fbb1117ed29e0efdff1e18412f7567 # v3.3.0
with:
registry: ${{ vars.DOCKER_PROXY_REGISTRY_URL }}
username: ${{ secrets.HARBOR_CENTREON_PUSH_USERNAME }}
password: ${{ secrets.HARBOR_CENTREON_PUSH_TOKEN }}

- uses: docker/setup-buildx-action@988b5a0280414f521da01fcc63a27aeeb4b104db # v3.6.1

- uses: docker/build-push-action@5176d81f87c23d6fc96624dfdbcd9f3830bbe445 # v6.5.0
- uses: docker/build-push-action@4f58ea79222b3b9dc2c8bbdd6debcef730109a75 # v6.9.0
with:
file: .github/docker/Dockerfile.gorgone-testing-${{ matrix.distrib }}
context: .
build-args: |
"REGISTRY_URL=${{ vars.DOCKER_PROXY_REGISTRY_URL }}"
"VERSION=${{ needs.get-version.outputs.major_version }}"
"IS_CLOUD=${{ needs.get-version.outputs.release_cloud }}"
pull: true
push: true
tags: ${{ vars.DOCKER_INTERNAL_REGISTRY_URL }}/gorgone-testing-${{ matrix.distrib }}:${{ needs.get-version.outputs.gorgone_docker_version }}
tags: ${{ vars.DOCKER_INTERNAL_REGISTRY_URL }}/gorgone-testing-${{ matrix.distrib }}:${{ needs.get-version.outputs.major_version }}
secrets: |
"ARTIFACTORY_INTERNAL_REPO_USERNAME=${{ secrets.ARTIFACTORY_INTERNAL_REPO_USERNAME }}"
"ARTIFACTORY_INTERNAL_REPO_PASSWORD=${{ secrets.ARTIFACTORY_INTERNAL_REPO_PASSWORD }}"
7 changes: 0 additions & 7 deletions .github/workflows/get-version.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,6 @@ on:
release_cloud:
description: "context of release (cloud or not cloud)"
value: ${{ jobs.get-version.outputs.release_cloud }}
gorgone_docker_version:
description: "md5 of gorgone dockerfile"
value: ${{ jobs.get-version.outputs.gorgone_docker_version }}

jobs:
get-version:
Expand All @@ -54,7 +51,6 @@ jobs:
environment: ${{ steps.get_version.outputs.env }}
release_type: ${{ steps.get_version.outputs.release_type }}
release_cloud: ${{ steps.get_version.outputs.release_cloud}}
gorgone_docker_version: ${{ steps.get_version.outputs.gorgone_docker_version }}

steps:
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
Expand Down Expand Up @@ -117,9 +113,6 @@ jobs:
exit 1
fi
GORGONE_DOCKER_VERSION=$(cat .github/docker/Dockerfile.gorgone-testing-* | md5sum | cut -c1-8)
echo "gorgone_docker_version=$GORGONE_DOCKER_VERSION" >> $GITHUB_OUTPUT
IMG_VERSION=$( cat `ls .github/docker/Dockerfile.centreon-collect-* | grep -v test` vcpkg.json | md5sum | awk '{print substr($1, 0, 8)}')
TEST_IMG_VERSION=$(cat .github/docker/Dockerfile.centreon-collect-*-test .github/scripts/collect-prepare-test-robot.sh resources/*.sql | md5sum | cut -c1-8)
echo "img_version=$IMG_VERSION" >> $GITHUB_OUTPUT
Expand Down
37 changes: 16 additions & 21 deletions .github/workflows/gorgone.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ on:
- reopened
- ready_for_review
paths:
- ".github/workflows/gorgone.yml"
- "gorgone/**"
- "!gorgone/tests/**"
- "!gorgone/veracode.json"
Expand Down Expand Up @@ -61,7 +62,7 @@ jobs:
strategy:
fail-fast: false
matrix:
distrib: [el8, el9, bookworm, jammy]
distrib: [el8, el9, bookworm] # No ubuntu in 24.10, 24.11 or later for now
include:
- package_extension: rpm
image: packaging-nfpm-alma8
Expand All @@ -72,23 +73,20 @@ jobs:
- package_extension: deb
image: packaging-nfpm-bookworm
distrib: bookworm
- package_extension: deb
image: packaging-nfpm-jammy
distrib: jammy

runs-on: ubuntu-22.04
runs-on: ubuntu-24.04

container:
image: ${{ vars.DOCKER_INTERNAL_REGISTRY_URL }}/${{ matrix.image }}:${{ needs.get-version.outputs.major_version }}
credentials:
username: ${{ secrets.DOCKER_REGISTRY_ID }}
password: ${{ secrets.DOCKER_REGISTRY_PASSWD }}
username: ${{ secrets.HARBOR_CENTREON_PUSH_USERNAME }}
password: ${{ secrets.HARBOR_CENTREON_PUSH_TOKEN }}

name: package ${{ matrix.distrib }}

steps:
- name: Checkout sources
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0

- name: Set package version and paths according to distrib
run: |
Expand Down Expand Up @@ -136,27 +134,24 @@ jobs:
strategy:
fail-fast: false
matrix:
distrib: [el8, el9, bookworm, jammy]
distrib: [el8, el9, bookworm] # No ubuntu in 24.10, 24.11 or later for now
include:
- package_extension: rpm
image: gorgone-testing-alma8
distrib: el8
- package_extension: rpm
image: gorgone-testing-alma9
distrib: el9
- package_extension: deb
image: gorgone-testing-jammy
distrib: jammy
- package_extension: deb
image: gorgone-testing-bookworm
distrib: bookworm

runs-on: ubuntu-22.04
runs-on: ubuntu-24.04
container:
image: ${{ vars.DOCKER_INTERNAL_REGISTRY_URL }}/${{ matrix.image }}:${{ needs.get-version.outputs.gorgone_docker_version }}
image: ${{ vars.DOCKER_INTERNAL_REGISTRY_URL }}/${{ matrix.image }}:${{ needs.get-version.outputs.major_version }}
credentials:
username: ${{ secrets.DOCKER_REGISTRY_ID }}
password: ${{ secrets.DOCKER_REGISTRY_PASSWD }}
username: ${{ secrets.HARBOR_CENTREON_PUSH_USERNAME }}
password: ${{ secrets.HARBOR_CENTREON_PUSH_TOKEN }}

services:
mariadb:
Expand Down Expand Up @@ -250,7 +245,7 @@ jobs:

steps:
- name: Checkout sources
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0

- name: Deliver sources
uses: ./.github/actions/release-sources
Expand All @@ -273,7 +268,7 @@ jobs:

steps:
- name: Checkout sources
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0

- name: Delivery
uses: ./.github/actions/rpm-delivery
Expand All @@ -294,11 +289,11 @@ jobs:

strategy:
matrix:
distrib: [bookworm]
distrib: [bookworm] # No ubuntu in 24.10, 24.11 or later for now

steps:
- name: Checkout sources
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0

- name: Delivery
uses: ./.github/actions/deb-delivery
Expand Down Expand Up @@ -326,7 +321,7 @@ jobs:

steps:
- name: Checkout sources
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0

- name: Promote ${{ matrix.distrib }} to stable
uses: ./.github/actions/promote-to-stable
Expand Down

0 comments on commit ec5db1c

Please sign in to comment.