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

Update Dockerfile to RockyLinux 8 + add workflow to build it #349

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
50 changes: 50 additions & 0 deletions .github/workflows/build-publish-container.yml
@@ -0,0 +1,50 @@
name: Build and publish container images
on:
pull_request:
workflow_dispatch:
push:
schedule:
# rebuild image every Sunday
- cron: '41 1 * * 0'

jobs:
build_publish:
name: Build/publish containers
runs-on: ubuntu-latest
permissions:
packages: write
contents: read
steps:
- name: Check out the repo
uses: actions/checkout@v3

- name: Set the image date tag
run: |
echo IMAGE_TAG=$(date +"%Y%m%d") >> $GITHUB_ENV

- name: Build Image
uses: redhat-actions/buildah-build@v2.12
id: build-image
with:
image: quattor-test-container
tags: latest ${{ github.sha }} ${{ env.IMAGE_TAG }}
dockerfiles: |
./Dockerfile

- name: Publish image on ghcr.io
id: push-to-ghcr
if: github.event_name == 'push' && github.ref_name == 'master'
uses: redhat-actions/push-to-registry@v2.7
with:
image: ${{ steps.build-image.outputs.image }}
tags: ${{ steps.build-image.outputs.tags }}
registry: ghcr.io/${{ github.repository_owner }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Print image name and tags
run: echo "Image ${{ steps.build-image.outputs.image }} build with tags ${{ steps.build-image.outputs.tags }}" >> $GITHUB_STEP_SUMMARY

- name: Print image url
if: github.event_name == 'push' && github.ref_name == 'master'
run: echo "Image pushed to ${{ steps.push-to-ghcr.outputs.registry-paths }}" >> $GITHUB_STEP_SUMMARY
57 changes: 27 additions & 30 deletions Dockerfile
@@ -1,42 +1,39 @@
# Use an official centos image as a parent image
FROM centos:7
# Use an official RockyLinux image as a parent image
FROM rockylinux:8

# Set the working directory to install dependencies to /quattor
WORKDIR /quattor

# install library core in /quattor, tests need it
ADD https://codeload.github.com/quattor/template-library-core/tar.gz/master /quattor/template-library-core-master.tar.gz
RUN tar xvfz template-library-core-master.tar.gz

# Install dependencies
RUN yum install maven epel-release -y
RUN rpm -U http://yum.quattor.org/devel/quattor-release-1-1.noarch.rpm

RUN yum install --nogpgcheck perl-Test-Quattor -y
# needed by some tests, not a dependency of perl-Test-Quattor
RUN yum install panc perl-JSON-Any -y

# these are not by default in centos7, but quattor tests assume they are
RUN touch /usr/sbin/selinuxenabled /sbin/restorecon
RUN chmod +x /usr/sbin/selinuxenabled /sbin/restorecon
ADD https://codeload.github.com/quattor/template-library-core/tar.gz/master template-library-core-master.tar.gz
RUN tar -xzf template-library-core-master.tar.gz

# point library core to where we downloaded it
ENV QUATTOR_TEST_TEMPLATE_LIBRARY_CORE /quattor/template-library-core-master

# set workdir to where we'll run the tests
# you need to provide the content of this directory when running this docker container:
# first build this container:
# docker build -t quattor_test .
# mount pwd in /quattor_test (not in /quattor or the mount will hide /quattor/template-library-core)
# docker run --mount type=bind,source="$PWD",target=/quattor_test quattor_test
# Prepare to install dependencies
RUN dnf -y install dnf-plugins-core && \
dnf config-manager --set-enabled appstream && \
dnf config-manager --set-enabled powertools && \
dnf -y install epel-release http://yum.quattor.org/devel/quattor-yum-repo-2-1.noarch.rpm

# The available version of perl-Test-Quattor is too old for mvnprove.pl to
# work, but this is a quick way of pulling in a lot of required dependencies.
# Surprisingly `which` is not installed by default and panc depends on it.
# libselinux-utils is required for /usr/sbin/selinuxenabled
RUN dnf install -y maven which rpm-build panc ncm-lib-blockdevices \
ncm-ncd git libselinux-utils sudo perl-Crypt-OpenSSL-X509 \
perl-Data-Compare perl-Date-Manip perl-File-Touch perl-JSON-Any \
perl-Net-DNS perl-Net-FreeIPA perl-Net-OpenNebula \
perl-Net-OpenStack-Client perl-NetAddr-IP perl-REST-Client \
perl-Set-Scalar perl-Text-Glob cpanminus gcc wget \
perl-Git-Repository perl-Data-Structure-Util \
perl-Test-Quattor aii-ks

# quattor tests should not be run as root
RUN useradd --user-group --create-home --no-log-init --home-dir /quattor_test quattortest
USER quattortest
WORKDIR /quattor_test

# when running the container, by default run the tests
# you can run any command in the container from the cli.
# e.g. to test configuration-modules-core/ncm-metaconfig
# (The only tests that this container has all dependencies for at the moment)
# cd /path/to/configuration-modules-core
# docker run --mount type=bind,source="$PWD",target=/quattor_test/configuration-modules-core \
# quattor_test bash -c 'source /usr/bin/mvn_test.sh && \
# cd /quattor_test/configuration-modules-core/ncm-metaconfig && mvn_test service-mailrc'
# Default action on running the container is to run all tests
CMD . /usr/bin/mvn_test.sh && mvn_test