Skip to content
Snippets Groups Projects
Commit bbdeef8a authored by Luca Bassi's avatar Luca Bassi
Browse files

Multiple EL versions

parent 19c5a333
No related branches found
No related tags found
1 merge request!26Migration to EL9
Pipeline #225950 passed
......@@ -13,6 +13,6 @@ COPY library-scripts/*.sh /tmp/library-scripts/
RUN \
sh /tmp/library-scripts/provide-dev-deps.sh && \
sh /tmp/library-scripts/provide-user.sh ${USERNAME} ${USER_UID} ${USER_GID} && \
yum clean all && rm -rf /var/cache/yum
dnf clean all && rm -rf /var/cache/dnf
USER $USERNAME
......@@ -4,20 +4,20 @@ A devcontainer is ready to use for the developers. A set of packages without ngi
## How to build and install nginx with or without httpg patch
To build and install the latest stable version of [nginx](http://nginx.org/en/download.html) (1.24.0) you have to copy the `nginx.repo` file (it is contained in the `docker` directory) into the `/etc/yum.repos.d/` directory and install nginx with `yum`:
To build and install the latest stable version of [nginx](http://nginx.org/en/download.html) you have to copy the `nginx.repo` file (it is contained in the `docker` directory) into the `/etc/yum.repos.d/` directory and install nginx with `yum`:
```shell
$ sudo cp docker/nginx.repo /etc/yum.repos.d/
$ sudo yum install -y nginx
```
Otherwise, if you want to build and install the latest stable version of [nginx](http://nginx.org/en/download.html) (1.24.0) with the httpg patch, a bash library is ready to use. You can source it and follow the commands below:
Otherwise, if you want to build and install the latest stable version of [nginx](http://nginx.org/en/download.html) with the httpg patch, a bash library is ready to use. You can source it and follow the commands below:
```shell
$ source .devcontainer/assets/build-library.sh
$ downloadNginx
$ buildHttpgNginxRPM
$ sudo rpm -ivh ~/rpmbuild/RPMS/x86_64/nginx-httpg-1.24.0-1.el7.ngx.x86_64.rpm
$ sudo rpm -ivh ~/rpmbuild/RPMS/x86_64/nginx-*.httpg.x86_64.rpm
```
## How to build and install the `ngx_http_voms_module`
......@@ -28,7 +28,7 @@ If you want to build and install the `ngx_http_voms_module`, nginx have to be in
$ source .devcontainer/assets/build-library.sh
$ downloadNginx
$ buildVomsModuleRPM
$ sudo rpm -ivh ~/rpmbuild/RPMS/x86_64/nginx-module-http-voms-1.24.0-1.el7.x86_64.rpm
$ sudo rpm -ivh ~/rpmbuild/RPMS/x86_64/nginx-module-http-voms-*.x86_64.rpm
```
## How to manage this project
......@@ -36,7 +36,7 @@ If you want to understand how this project works, start from the CI. Three stage
### 1. build-rpms
Starting from a clear centos7, we install all the useful packages to compile nginx and to build a rpm package. The bash steps that achieves these results are defined in the `.devcontainer/assets/build-library.sh` file, so you can read that bash script to learn which nginx version we use, how to download it, how to set up the environment and how to build the rpm.
Starting from a clear AlmaLinux 9, we install all the useful packages to compile nginx and to build a rpm package. The bash steps that achieves these results are defined in the `.devcontainer/assets/build-library.sh` file, so you can read that bash script to learn which nginx version we use, how to download it, how to set up the environment and how to build the rpm.
It is important to underline that to build the nginx rpm we use the spec file in the `rpm` repo, that is the official nginx 1.24.0 spec file increased by the HTTPG patch. To build the `ngx_http_voms_module` we have defined an appropriate spec file indeed. The files that are used to build the rpm module are written, called and collocated following the common practices of the nginx modules: a source file is defined in the `src` folder, the `config` and the `config.make` files are in the root project directory.
......@@ -46,12 +46,8 @@ At the end of this stage, all the useful rpms are saved as job artifacts.
In this stage we set up a docker image with nginx, the httpg patch and the `ngx_http_voms_module`. To do this, we use a set of scripts written by Andrea Ceccanti in the [`helper-scripts`](https://baltig.infn.it/mw-devel/helper-scripts.git) project.
The dockerfile and all the files needed for its compilation are in the `docker` directory. The image starts from centos7, defines a user and installs a set of useful packages. After that we import the nginx repo file, in this way we can download a lot of packages provided by nginx, including its last stable version. In the end we install the rpm packages that we build in the previous stage and the njs module.
The dockerfile and all the files needed for its compilation are in the `docker` directory. The image starts from AlmaLinux 9, defines a user and installs a set of useful packages. After that we import the nginx repo file, in this way we can download a lot of packages provided by nginx, including its last stable version. In the end we install the rpm packages that we build in the previous stage and the njs module.
### 3. push-to-dockerhub
In this last stage we push on dockerhub the image that we have builded in the previous stage. Note that this stage is run only when we push something in the master branch.
......@@ -13,24 +13,16 @@ downloadNginx() {
# set nginx version
if [ -z ${ngxVersion} ]; then
ngxVersion=1.26.1-2
ngxVersion=1.26.2-1
fi
echo "Downloading nginx version ${ngxVersion}"
src_package_name="nginx-${ngxVersion}.el9.ngx.src.rpm"
src_package_url="https://nginx.org/packages/centos/9/SRPMS/${src_package_name}"
elVersion=$(rpmbuild --eval %{rhel})
echo "Downloading nginx version ${ngxVersion} (EL${elVersion})"
src_package_name="nginx-${ngxVersion}.el${elVersion}.ngx.src.rpm"
src_package_url="https://nginx.org/packages/centos/${elVersion}/SRPMS/${src_package_name}"
# setup rpmbuild dir
cat <<EOF > ~/.rpmmacros
%_topdir %{getenv:HOME}/rpmbuild
EOF
cd
rpmdev-setuptree
# download nginx sources
cd ~/rpmbuild/SOURCES/
wget ${src_package_url}
rpm2cpio ${src_package_name} | cpio -idm
rpm -i ${src_package_name}
}
buildHttpgNginxRPM() {
......@@ -40,20 +32,12 @@ buildHttpgNginxRPM() {
CI_PROJECT_DIR="${PWD}"
fi
# set the nginx spec file with the httpg patch
cd ~/rpmbuild/SOURCES/
cp ${CI_PROJECT_DIR}/nginx-httpg_no_delegation.patch ~/rpmbuild/SOURCES/
cp ${CI_PROJECT_DIR}/rpm/nginx.spec ~/rpmbuild/SPECS
sh ${CI_PROJECT_DIR}/rpm/addPatchToNginxSpec.sh
# build rpm
rpmlint ~/rpmbuild/SPECS/nginx.spec
rpmbuild -ba ~/rpmbuild/SPECS/nginx.spec
# include httpg in the rpm name
mv ~/rpmbuild/RPMS/x86_64/nginx-$ngxVersion-1.el7.ngx.x86_64.rpm ~/rpmbuild/RPMS/x86_64/nginx-httpg-$ngxVersion-1.el7.ngx.x86_64.rpm
mv ~/rpmbuild/RPMS/x86_64/nginx-debuginfo-$ngxVersion-1.el7.ngx.x86_64.rpm ~/rpmbuild/RPMS/x86_64/nginx-httpg-debuginfo-$ngxVersion-1.el7.ngx.x86_64.rpm
mv ~/rpmbuild/SRPMS/nginx-$ngxVersion-1.el7.ngx.src.rpm ~/rpmbuild/SRPMS/nginx-httpg-$ngxVersion-1.el7.ngx.src.rpm
cd ${CI_PROJECT_DIR}
}
......
......@@ -4,20 +4,39 @@ stages:
- docker-build
- docker-push
build-rpms:
build-rpms-el8:
stage: build
image: centos:7
image: almalinux:8
script:
- env | sort
- yum -y install epel-release
- yum install -y wget openssl-devel zlib-devel pcre2-devel make rpmdevtools rpmlint boost-devel voms-devel gcc-c++
- source .devcontainer/assets/build-library.sh
- dnf -y install epel-release
- dnf install -y wget openssl-devel zlib-devel pcre2-devel make rpmdevtools rpmlint boost-devel voms-devel gcc-c++
- source .devcontainer/assets/build-library.sh
- CI_PROJECT_DIR=$PWD
- downloadNginx
- buildHttpgNginxRPM
- buildVomsModuleRPM
- cd ${CI_PROJECT_DIR}/docker && mkdir artifacts
- cp ~/rpmbuild/SRPMS/* artifacts/
- cp ~/rpmbuild/SRPMS/* artifacts/
- cp ~/rpmbuild/RPMS/x86_64/* artifacts/
artifacts:
paths:
- docker/artifacts/
build-rpms-el9:
stage: build
image: almalinux:9
script:
- env | sort
- dnf -y install epel-release
- dnf install -y wget openssl-devel zlib-devel pcre2-devel make rpmdevtools rpmlint boost-devel voms-devel gcc-c++
- source .devcontainer/assets/build-library.sh
- CI_PROJECT_DIR=$PWD
- downloadNginx
- buildHttpgNginxRPM
- buildVomsModuleRPM
- cd ${CI_PROJECT_DIR}/docker && mkdir artifacts
- cp ~/rpmbuild/SRPMS/* artifacts/
- cp ~/rpmbuild/RPMS/x86_64/* artifacts/
artifacts:
paths:
......@@ -30,7 +49,8 @@ docker-build-rpms:
- name: docker:dind
command: ["--tls=false"]
dependencies:
- build-rpms
- build-rpms-el8
- build-rpms-el9
script:
- apk add git bash
- git clone https://baltig.infn.it/mw-devel/helper-scripts.git helper-scripts
......@@ -61,4 +81,4 @@ push-to-dockerhub:
- cd docker && pull-docker-image.sh && unset DOCKER_REGISTRY_HOST
- docker login -u ${DOCKERHUB_USER} -p ${DOCKERHUB_PASSWORD} && push-docker-image.sh
only:
- master
\ No newline at end of file
- master
......@@ -93,8 +93,6 @@ _Example_: `7B`
## Installation
### prerequisites
The module is written in C++, using features from C++14 that are supported by gcc v. 4.8.5 (the version available in CentOS 7) enabling the option `-std=c++1y` (see [`config.make`](config.make)).
The software dependecies are listed in the [provide-deps](docker/library-scripts/provide-deps.sh) script in the `docker` directory.
The nginx source files are also needed. To download them in ```/tmp/nginx-x.y.z``` you can execute:
......
# Copyright 2018-2023 Istituto Nazionale di Fisica Nucleare
# SPDX-License-Identifier: EUPL-1.2
FROM centos:7
ARG EL_VERSION=9
FROM almalinux:${EL_VERSION}
# https://docs.docker.com/reference/dockerfile/#understand-how-arg-and-from-interact
ARG EL_VERSION
# Allow customization of nginx user ID and name
ARG USERNAME=nginx
......@@ -10,29 +15,29 @@ ARG USER_GID=${USER_UID}
# install dependencies
COPY library-scripts/*.sh /tmp/library-scripts/
RUN yum update -y && \
RUN dnf update -y && \
sh /tmp/library-scripts/provide-deps.sh && \
sh /tmp/library-scripts/provide-user.sh ${USERNAME} ${USER_UID} ${USER_GID} && \
mkdir /pkgs && \
yum clean all && rm -rf /var/cache/yum
dnf clean all && rm -rf /var/cache/dnf
COPY artifacts/*.rpm /pkgs/
# install nginx httpg + voms and njs dynamic modules (latest version)
COPY nginx.repo /etc/yum.repos.d/nginx.repo
RUN rpm -ivh /pkgs/nginx-httpg-1.24.0-1.el7.ngx.x86_64.rpm && \
rpm -ivh /pkgs/nginx-module-http-voms-1.24.0-1.el7.x86_64.rpm && \
yum install -y nginx-module-njs \
RUN rpm -ivh /pkgs/nginx-*.el${EL_VERSION}.httpg.x86_64.rpm && \
rpm -ivh /pkgs/nginx-module-http-voms-*.el${EL_VERSION}.x86_64.rpm && \
dnf install -y nginx-module-njs \
# forward request and error logs to docker log collector
&& ln -sf /dev/stdout /var/log/nginx/access.log \
&& ln -sf /dev/stderr /var/log/nginx/error.log
# install nginx + voms and njs dynamic modules
# RUN yum -y install nginx nginx-module-njs && \
# rpm -ivh /pkgs/nginx-module-http-voms-1.24.0-1.el7.x86_64.rpm
# RUN dnf -y install nginx nginx-module-njs && \
# rpm -ivh /pkgs/nginx-module-http-voms-1.24.0-1.el${EL_VERSION}.x86_64.rpm
EXPOSE 80
STOPSIGNAL SIGQUIT
CMD ["nginx", "-g", "daemon off;"]
\ No newline at end of file
CMD ["nginx", "-g", "daemon off;"]
......@@ -5,13 +5,16 @@
set -ex
yum -y install epel-release
yum-config-manager --add-repo https://openresty.org/package/centos/openresty.repo
dnf -y install epel-release wget
yum -y install \
# https://openresty.org/en/linux-packages.html#centos
wget https://openresty.org/package/centos/openresty2.repo
mv openresty2.repo /etc/yum.repos.d/openresty.repo
dnf config-manager --set-enabled crb
dnf -y install \
hostname \
which \
wget \
tar \
sudo \
file \
......@@ -31,4 +34,5 @@ yum -y install \
perl-Test-Nginx \
perl-Digest-SHA \
cpan \
voms-clients-java
\ No newline at end of file
voms-clients-java \
procps-ng
[nginx-stable]
name=nginx stable repo
baseurl=http://nginx.org/packages/centos/\$releasever/\$basearch/
baseurl=http://nginx.org/packages/centos/$releasever/$basearch/
gpgcheck=1
enabled=1
gpgkey=https://nginx.org/keys/nginx_signing.key
......@@ -8,7 +8,7 @@ module_hotfixes=true
[nginx-mainline]
name=nginx mainline repo
baseurl=http://nginx.org/packages/mainline/centos/\$releasever/\$basearch/
baseurl=http://nginx.org/packages/mainline/centos/$releasever/$basearch/
gpgcheck=1
enabled=0
gpgkey=https://nginx.org/keys/nginx_signing.key
......
#!/usr/bin/env bash
set -ex
# Add the httpg patch
# Set the nginx spec file with the httpg patch
PATCH_NAME="nginx-httpg_no_delegation.patch"
SPEC_FILE="${HOME}/rpmbuild/SPECS/nginx.spec"
# Copy the patch in the rpmbuild directory
cp ${CI_PROJECT_DIR}/${PATCH_NAME} ~/rpmbuild/SOURCES/
cd ~/rpmbuild/SOURCES/
# Find the highest existing Patch number in the spec file
LAST_PATCH_NUM=$(grep -oP "^Patch\K[0-9]+" $SPEC_FILE | sort -n | tail -1)
if [ -z "$LAST_PATCH_NUM" ]; then
# There are no existing patches: find the highest Source number in the spec file
LAST_SOURCE_NUM=$(grep -oP "^Source\K[0-9]+" $SPEC_FILE | sort -n | tail -1)
# Add the patch to the spec file after the last Source
sed -i "/^Source${LAST_SOURCE_NUM}/a Patch0: ${PATCH_NAME}" "${SPEC_FILE}"
else
# Add the new patch to the spec file after the last Patch
sed -i "/^Patch${LAST_PATCH_NUM}/a Patch$((LAST_PATCH_NUM + 1)): ${PATCH_NAME}" "${SPEC_FILE}"
fi
# Add httpg to release
sed -i '/%define base_release/ s/ngx/httpg/' "${SPEC_FILE}"
%define nginx_user nginx
%define nginx_group nginx
%define base_version 1.24.0
%define base_version 1.26.2
%define bdir %{_builddir}/%{name}-%{base_version}
Name: nginx-module-http-voms
Version: 1.24.0
Version: %{base_version}
Release: 1%{?dist}
Summary: nginx http voms dynamic modules
......@@ -84,8 +84,11 @@ fi
%changelog
* Fri Oct 18 2024 Francesco Giacomini
- nginx http voms module updated to 1.26.2-1.0.0
* Wed Apr 12 2023 Laura Cappelli
- nginx http voms module updated to 1.24.0-1.0.0
* Fri Nov 18 2022 Laura Cappelli
- nginx http voms module updated to 1.22.1-1.0.0
\ No newline at end of file
- nginx http voms module updated to 1.22.1-1.0.0
This diff is collapsed.
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment