Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(gorgone): use Centreon version to create 1 docker images per version with the right repo #1850

Closed
wants to merge 12 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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}" == "true" ]]; 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}" == "true" ]]; 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.11-unstable/ % 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
9 changes: 7 additions & 2 deletions .github/docker/Dockerfile.gorgone-testing-bullseye
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
FROM debian:bullseye
ARG REGISTRY_URL=docker.io
ARG VERSION

FROM ${REGISTRY_URL}/debian:bullseye

ARG VERSION

ENV DEBIAN_FRONTEND noninteractive
# fix locale
Expand All @@ -18,7 +23,7 @@ localedef -i en_US -c -f UTF-8 -A /usr/share/locale/locale.alias en_US.UTF-8
pip3 install robotframework robotframework-examples robotframework-databaselibrary \
pymysql robotframework-requests robotframework-jsonlibrary

lsb_release -sc | xargs -I % sh -c 'echo deb https://packages.centreon.com/apt-standard-24.11-unstable/ % main' | tee /etc/apt/sources.list.d/centreon.list
lsb_release -sc | xargs -I % sh -c 'echo deb https://packages.centreon.com/apt-standard-${VERSION}-unstable/ % 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

wget -O- https://apt-key.centreon.com | gpg --dearmor | tee /etc/apt/trusted.gpg.d/centreon.gpg > /dev/null 2>&1
Expand Down
9 changes: 7 additions & 2 deletions .github/docker/Dockerfile.gorgone-testing-jammy
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
FROM ubuntu:jammy
ARG REGISTRY_URL=docker.io
ARG VERSION

FROM ${REGISTRY_URL}/ubuntu:jammy

ARG VERSION

ENV DEBIAN_FRONTEND=noninteractive

Expand All @@ -11,7 +16,7 @@ RUN apt-get update && \
ENV LANG=en_US.UTF-8

# Add Centreon repositories and their public key
RUN echo "deb https://packages.centreon.com/ubuntu-standard-24.11-unstable/ jammy main" | tee -a /etc/apt/sources.list.d/centreon-testing.list && \
RUN echo "deb https://packages.centreon.com/ubuntu-standard-${VERSION}-unstable/ jammy main" | tee -a /etc/apt/sources.list.d/centreon-testing.list && \
echo "deb https://packages.centreon.com/ubuntu-plugins-testing/ jammy main" | tee -a /etc/apt/sources.list.d/centreon-plugins-testing.list && \
wget -O- https://apt-key.centreon.com | gpg --dearmor | tee /etc/apt/trusted.gpg.d/centreon.gpg > /dev/null 2>&1 && \
apt-get update
Expand Down
16 changes: 15 additions & 1 deletion .github/workflows/docker-gorgone-testing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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@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-environment.outputs.major_version }}"
"IS_CLOUD=${{ needs.get-environment.outputs.is_cloud }}"
pull: true
push: true
tags: ${{ vars.DOCKER_INTERNAL_REGISTRY_URL }}/gorgone-testing-${{ matrix.distrib }}:${{ needs.get-environment.outputs.gorgone_docker_version }}
tags: ${{ vars.DOCKER_INTERNAL_REGISTRY_URL }}/gorgone-testing-${{ matrix.distrib }}:${{ needs.get-environment.outputs.major_version }}
secrets: |
"ARTIFACTORY_INTERNAL_REPO_USERNAME=${{ secrets.ARTIFACTORY_INTERNAL_REPO_USERNAME }}"
"ARTIFACTORY_INTERNAL_REPO_PASSWORD=${{ secrets.ARTIFACTORY_INTERNAL_REPO_PASSWORD }}"
8 changes: 0 additions & 8 deletions .github/workflows/get-environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,6 @@ on:
test_img_version:
description: "test docker image version (checksum of database sql, script and dockerfiles)"
value: ${{ jobs.get-environment.outputs.test_img_version }}
gorgone_docker_version:
description: "md5 of gorgone dockerfile"
value: ${{ jobs.get-environment.outputs.gorgone_docker_version }}

jobs:
get-environment:
Expand All @@ -58,7 +55,6 @@ jobs:
is_targeting_feature_branch: ${{ steps.get_stability.outputs.is_targeting_feature_branch }}
img_version: ${{ steps.get_docker_images_version.outputs.img_version }}
test_img_version: ${{ steps.get_docker_images_version.outputs.test_img_version }}
gorgone_docker_version: ${{ steps.get_docker_images_version.outputs.gorgone_docker_version }}

steps:
- name: Checkout sources (current branch)
Expand Down Expand Up @@ -239,9 +235,6 @@ jobs:
TEST_IMG_VERSION=$(cat .github/docker/Dockerfile.centreon-collect-*-test .github/scripts/collect-prepare-test-robot.sh resources/*.sql | md5sum | cut -c1-8)
echo "test_img_version=$TEST_IMG_VERSION" >> $GITHUB_OUTPUT

GORGONE_DOCKER_VERSION=$(cat .github/docker/Dockerfile.gorgone-testing-* | md5sum | cut -c1-8)
echo "gorgone_docker_version=$GORGONE_DOCKER_VERSION" >> $GITHUB_OUTPUT

- name: Display info in job summary
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
env:
Expand All @@ -260,7 +253,6 @@ jobs:
['is_targeting_feature_branch', '${{ steps.get_stability.outputs.is_targeting_feature_branch }}'],
['img_version', '${{ steps.get_docker_images_version.outputs.img_version }}'],
['test_img_version', '${{ steps.get_docker_images_version.outputs.test_img_version }}'],
['gorgone_docker_version', '${{ steps.get_docker_images_version.outputs.gorgone_docker_version }}'],
];

outputTable.push(['target_stability', '${{ steps.get_stability.outputs.target_stability || '<em>not defined because current run is not triggered by pull request event</em>' }}']);
Expand Down
10 changes: 2 additions & 8 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 @@ -73,9 +74,6 @@ jobs:
- package_extension: deb
image: packaging-nfpm-bookworm
distrib: bookworm
- package_extension: deb
image: packaging-nfpm-jammy
distrib: jammy

runs-on: ubuntu-24.04

Expand Down Expand Up @@ -132,7 +130,6 @@ jobs:
stability: ${{ needs.get-environment.outputs.stability }}

test-gorgone:
if: false
needs: [get-environment, package]

strategy:
Expand All @@ -146,16 +143,13 @@ jobs:
- 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-24.04
container:
image: ${{ vars.DOCKER_INTERNAL_REGISTRY_URL }}/${{ matrix.image }}:${{ needs.get-environment.outputs.gorgone_docker_version }}
image: ${{ vars.DOCKER_INTERNAL_REGISTRY_URL }}/${{ matrix.image }}:${{ needs.get-environment.outputs.major_version }}
credentials:
username: ${{ secrets.HARBOR_CENTREON_PULL_USERNAME }}
password: ${{ secrets.HARBOR_CENTREON_PULL_TOKEN }}
Expand Down
Loading