diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 2e57d965b00d656ad36885962b2e8961ed35ca4a..ad4d3cedabfc0e4e3b4ca334410621ba32f8cadd 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,19 +1,49 @@ stages: - - build + - build-ngx + - build-voms + - docker-build -upload-container: - stage: build +build-ngx-httpg-rpm: + stage: build-ngx + image: centos:7 + script: + - env | sort + - cd && sh docker/library-scripts/provide-deps.sh + - sh rpm/build-httpg-nginx-rpm.sh + - mkdir ngx-artifacts + - cp rpmbuild/SRPMS/* ngx-artifacts/ + - cp rpmbuild/RPMS/x86_64/* ngx-artifacts/ + artifacts: + paths: + - ngx-artifacts/ + +build-voms-rpm: + stage: build-voms + image: centos:7 + script: + - env | sort + - cd && sh docker/library-scripts/provide-deps.sh + - sh rpm/build-voms-rpm.sh + - mkdir voms-artifacts + - cp rpmbuild/SRPMS/* voms-artifacts/ + - cp rpmbuild/RPMS/x86_64/* voms-artifacts/ + artifacts: + paths: + - voms-artifacts/ + +build-container: + stage: docker-build image: docker:latest services: - name: docker:dind command: ["--tls=false"] + dependencies: + - build-ngx-httpg-rpm + - build-voms-rpm script: - - env | sort - apk add git bash - git clone https://baltig.infn.it/mw-devel/helper-scripts.git helper-scripts - cp helper-scripts/scripts/* /usr/local/bin - - docker login -u gitlab-ci-token -p ${CI_JOB_TOKEN} ${CI_REGISTRY} - - export DOCKER_REGISTRY_HOST=${CI_REGISTRY} - - export DOCKER_REGISTRY_NAMESPACE=${CI_PROJECT_PATH} - - build-docker-image.sh && push-docker-image.sh + - cp ngx-artifacts/* ${CI_PROJECT_DIR}/docker/ + - cp voms-artifacts/* ${CI_PROJECT_DIR}/docker/ diff --git a/ngx-http-voms-module/config b/config similarity index 100% rename from ngx-http-voms-module/config rename to config diff --git a/ngx-http-voms-module/config.make b/config.make similarity index 100% rename from ngx-http-voms-module/config.make rename to config.make diff --git a/Dockerfile b/docker/Dockerfile similarity index 82% rename from Dockerfile rename to docker/Dockerfile index bfdf5115ea7af8e694c989521d8b250a77dde3c9..8fbe82e540a815ffe2e105fabc16225633684b02 100644 --- a/Dockerfile +++ b/docker/Dockerfile @@ -13,13 +13,12 @@ COPY library-scripts/*.sh /tmp/library-scripts/ RUN yum 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 # install nginx with patch for HTTPG and voms module -COPY ngx-http-voms-module /ngx-http-voms-module -COPY sources/* /tmp/sources/ -USER nginx -RUN sh /tmp/library-scripts/provide-ngx-httpg-voms.sh +COPY ngx-artifacts/*.rpm /pkgs/ +COPY voms-artifacts/*.rpm /pkgs/ # import test COPY t /home/nginx/t diff --git a/library-scripts/provide-deps.sh b/docker/library-scripts/provide-deps.sh similarity index 100% rename from library-scripts/provide-deps.sh rename to docker/library-scripts/provide-deps.sh diff --git a/library-scripts/provide-user.sh b/docker/library-scripts/provide-user.sh similarity index 100% rename from library-scripts/provide-user.sh rename to docker/library-scripts/provide-user.sh diff --git a/library-scripts/provide-ngx-httpg-voms.sh b/library-scripts/provide-ngx-httpg-voms.sh deleted file mode 100644 index 167839c0345e8f6df2b4b2b35171c07a0a77f3c3..0000000000000000000000000000000000000000 --- a/library-scripts/provide-ngx-httpg-voms.sh +++ /dev/null @@ -1,38 +0,0 @@ -#!/usr/bin/env bash - -# Copyright 2018-2022 Istituto Nazionale di Fisica Nucleare -# SPDX-License-Identifier: EUPL-1.2 - -set -ex - -ngxVersion=1.22.1 - -# set environment to build rpm -rpmdev-setuptree -cat <<EOF > ${HOME}/.rpmmacros -%_topdir %{getenv:HOME}/rpmbuild -EOF - -# download nginx sources -cd ~/rpmbuild/SOURCES/ -wget http://nginx.org/packages/centos/7/SRPMS/nginx-$ngxVersion-1.el7.ngx.src.rpm -rpm2cpio nginx-$ngxVersion-1.el7.ngx.src.rpm | cpio -idm - -# set modules -wget -O ./ngx-http-echo-module.tar.gz https://github.com/openresty/echo-nginx-module/archive/refs/tags/v0.63.tar.gz -tar xzf ngx-http-echo-module.tar.gz -sudo mv /ngx-http-voms-module . - -# use nginx spec file with the httpg patch and static modules -cp /tmp/sources/nginx-httpg_no_delegation.patch ${HOME}/rpmbuild/SOURCES/ -cp /tmp/sources/nginx.spec ~/rpmbuild/SPECS - -# build and install rpm -rpmlint ~/rpmbuild/SPECS/nginx.spec -rpmbuild -ba ~/rpmbuild/SPECS/nginx.spec -sudo rpm -ivh ~/rpmbuild/RPMS/x86_64/nginx-$ngxVersion-1.el7.ngx.x86_64.rpm -nginx -v - -sudo chown -R nginx:nginx /var/cache/nginx -sudo chown -R nginx:nginx /var/log/nginx -sudo chown -R nginx:nginx /etc/nginx/ \ No newline at end of file diff --git a/sources/nginx-httpg_no_delegation.patch b/nginx-httpg_no_delegation.patch similarity index 100% rename from sources/nginx-httpg_no_delegation.patch rename to nginx-httpg_no_delegation.patch diff --git a/rpm/build-httpg-nginx-rpm.sh b/rpm/build-httpg-nginx-rpm.sh new file mode 100644 index 0000000000000000000000000000000000000000..6377d94aea9727390de68ebb70f40404c19d5dac --- /dev/null +++ b/rpm/build-httpg-nginx-rpm.sh @@ -0,0 +1,27 @@ +#!/usr/bin/env bash + +# Copyright 2018-2022 Istituto Nazionale di Fisica Nucleare +# SPDX-License-Identifier: EUPL-1.2 + +set -ex + +ngxVersion=1.22.1 + +# set environment to build rpm +rpmdev-setuptree +cat <<EOF > ${HOME}/.rpmmacros +%_topdir %{getenv:HOME}/rpmbuild +EOF + +# download nginx sources +cd ~/rpmbuild/SOURCES/ +wget http://nginx.org/packages/centos/7/SRPMS/nginx-$ngxVersion-1.el7.ngx.src.rpm +rpm2cpio nginx-$ngxVersion-1.el7.ngx.src.rpm | cpio -idm + +# set the nginx spec file with the httpg patch +cp ~/nginx-httpg_no_delegation.patch ${HOME}/rpmbuild/SOURCES/ +cp ~/rpm/nginx.spec ~/rpmbuild/SPECS + +# build rpm +rpmlint ~/rpmbuild/SPECS/nginx.spec +rpmbuild -ba ~/rpmbuild/SPECS/nginx.spec diff --git a/rpm/build-voms-rpm.sh b/rpm/build-voms-rpm.sh new file mode 100644 index 0000000000000000000000000000000000000000..28d91726362087e10a906cba33c17172b7e478e8 --- /dev/null +++ b/rpm/build-voms-rpm.sh @@ -0,0 +1,31 @@ +#!/usr/bin/env bash + +# Copyright 2018-2022 Istituto Nazionale di Fisica Nucleare +# SPDX-License-Identifier: EUPL-1.2 + +set -ex + +ngxVersion=1.22.1 + +# set environment to build rpm +rpmdev-setuptree +cat <<EOF > ${HOME}/.rpmmacros +%_topdir %{getenv:HOME}/rpmbuild +EOF + +# set sources +cd ~/rpmbuild/SOURCES +wget -O nginx-$ngxVersion.tar.gz https://nginx.org/download/nginx-$ngxVersion.tar.gz +wget -O ./ngx-http-echo-module.tar.gz https://github.com/openresty/echo-nginx-module/archive/refs/tags/v0.63.tar.gz +tar xzf ngx-http-echo-module.tar.gz + +# set voms modules sources +mkdir ngx-http-voms-module +cp ~/config ngx-http-voms-module/ +cp ~/config.make ngx-http-voms-module/ +cp -r ~/src ngx-http-voms-module/ +cp ~/rpm/nginx-module-http-voms.spec ~/rpmbuild/SPECS + +# build and install rpm +rpmlint ~/rpmbuild/SPECS/nginx-module-http-voms.spec +rpmbuild -ba ~/rpmbuild/SPECS/nginx-module-http-voms.spec diff --git a/rpm/nginx-module-http-voms.spec b/rpm/nginx-module-http-voms.spec new file mode 100644 index 0000000000000000000000000000000000000000..706bcf6ba40b9959fd51a9f0dcd82ecafabb9fbb --- /dev/null +++ b/rpm/nginx-module-http-voms.spec @@ -0,0 +1,90 @@ +%define nginx_user nginx +%define nginx_group nginx +%define base_version 1.22.1 +%define bdir %{_builddir}/%{name}-%{base_version} + +Name: nginx-module-http-voms +Version: 1.22.1 +Release: 1%{?dist} +Summary: nginx http voms dynamic modules + +License: EUPL-1.2 +URL: https://github.com/lauracappelli/nginx-sd-rpm + +Source0: https://nginx.org/download/nginx-%{base_version}.tar.gz +Source1: ngx-http-voms-module +Source2: echo-nginx-module-0.63 + +BuildRequires: gcc, make +BuildRequires: voms-devel +BuildRequires: boost-devel +BuildRequires: openssl-devel +BuildRequires: zlib-devel +BuildRequires: pcre2-devel +Requires: nginx +Requires: zlib +Requires: openssl +Requires: pcre2 +Requires: voms + + +%description +nginx http voms dynamic modules. + + +%prep +%setup -qcTn %{name}-%{base_version} +tar --strip-components=1 -zxf %{SOURCE0} + +%define CONFIG_PATH %(echo "--prefix=/etc/nginx --sbin-path=/usr/sbin/nginx --modules-path=/usr/lib/nginx/modules --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --pid-path=/var/run/nginx.pid --lock-path=/var/run/nginx.lock --http-client-body-temp-path=/var/cache/nginx/client_temp --http-proxy-temp-path=/var/cache/nginx/proxy_temp --http-fastcgi-temp-path=/var/cache/nginx/fastcgi_temp --http-uwsgi-temp-path=/var/cache/nginx/uwsgi_temp --http-scgi-temp-path=/var/cache/nginx/scgi_temp") +%define CONFIG_ARGS %(echo "--user=nginx --group=nginx --with-compat --with-http_ssl_module") +%define MODULE_CONFIG_ARGS %(echo "--add-dynamic-module=%SOURCE1 --add-dynamic-module=%SOURCE2") + + +%build +cd %{bdir} +./configure %{CONFIG_PATH} %{CONFIG_ARGS} %{MODULE_CONFIG_ARGS} +make %{?_smp_mflags} modules + + +%install +cd %{bdir} +%{__rm} -rf $RPM_BUILD_ROOT +%{__mkdir} -p $RPM_BUILD_ROOT%{_libdir}/nginx/modules +for so in `find %{bdir}/objs/ -maxdepth 2 -type f -name "*.so"`; do +%{__install} -m755 $so \ + $RPM_BUILD_ROOT%{_libdir}/nginx/modules/ +done + + +%clean +%{__rm} -rf $RPM_BUILD_ROOT + + +%files +%{_libdir}/nginx/modules/* + + +%post +if [ $1 -eq 1 ]; then +cat <<BANNER +---------------------------------------------------------------------- + +The http voms dynamic modules for nginx have been installed. +To enable these modules, add the following to /etc/nginx/nginx.conf +and reload nginx: + + load_module modules/ngx_http_voms_module.so; + load_module modules/ngx_http_echo_module.so; + +Please refer to the modules documentation for further details: +https://baltig.infn.it/storm2/ngx_http_voms_module + +---------------------------------------------------------------------- +BANNER +fi + + +%changelog +* Fri Nov 18 2022 Laura Cappelli +- nginx http voms module updated to 1.22.1-1.0.0 \ No newline at end of file diff --git a/sources/nginx.spec b/rpm/nginx.spec similarity index 99% rename from sources/nginx.spec rename to rpm/nginx.spec index b00064a20c4e93cb40c1382a5e3ffd8fbfca8b1b..ee0abb1a6e2132acce5881ae2261e0db1fd31ca5 100644 --- a/sources/nginx.spec +++ b/rpm/nginx.spec @@ -72,7 +72,7 @@ Requires(pre): shadow-utils %define WITH_CC_OPT $(echo %{optflags} $(pcre2-config --cflags)) -fPIC %define WITH_LD_OPT -Wl,-z,relro -Wl,-z,now -pie -%define BASE_CONFIGURE_ARGS $(echo "--prefix=%{_sysconfdir}/nginx --sbin-path=%{_sbindir}/nginx --modules-path=%{_libdir}/nginx/modules --conf-path=%{_sysconfdir}/nginx/nginx.conf --error-log-path=%{_localstatedir}/log/nginx/error.log --http-log-path=%{_localstatedir}/log/nginx/access.log --pid-path=%{_localstatedir}/run/nginx.pid --lock-path=%{_localstatedir}/run/nginx.lock --http-client-body-temp-path=%{_localstatedir}/cache/nginx/client_temp --http-proxy-temp-path=%{_localstatedir}/cache/nginx/proxy_temp --http-fastcgi-temp-path=%{_localstatedir}/cache/nginx/fastcgi_temp --http-uwsgi-temp-path=%{_localstatedir}/cache/nginx/uwsgi_temp --http-scgi-temp-path=%{_localstatedir}/cache/nginx/scgi_temp --user=%{nginx_user} --group=%{nginx_group} --with-compat --with-file-aio --with-threads --with-http_addition_module --with-http_auth_request_module --with-http_dav_module --with-http_flv_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_mp4_module --with-http_random_index_module --with-http_realip_module --with-http_secure_link_module --with-http_slice_module --with-http_ssl_module --with-http_stub_status_module --with-http_sub_module --with-http_v2_module --with-mail --with-mail_ssl_module --with-stream --with-stream_realip_module --with-stream_ssl_module --with-stream_ssl_preread_module --add-module=%SOURCE10 --add-module=%SOURCE11") +%define BASE_CONFIGURE_ARGS $(echo "--prefix=%{_sysconfdir}/nginx --sbin-path=%{_sbindir}/nginx --modules-path=%{_libdir}/nginx/modules --conf-path=%{_sysconfdir}/nginx/nginx.conf --error-log-path=%{_localstatedir}/log/nginx/error.log --http-log-path=%{_localstatedir}/log/nginx/access.log --pid-path=%{_localstatedir}/run/nginx.pid --lock-path=%{_localstatedir}/run/nginx.lock --http-client-body-temp-path=%{_localstatedir}/cache/nginx/client_temp --http-proxy-temp-path=%{_localstatedir}/cache/nginx/proxy_temp --http-fastcgi-temp-path=%{_localstatedir}/cache/nginx/fastcgi_temp --http-uwsgi-temp-path=%{_localstatedir}/cache/nginx/uwsgi_temp --http-scgi-temp-path=%{_localstatedir}/cache/nginx/scgi_temp --user=%{nginx_user} --group=%{nginx_group} --with-compat --with-file-aio --with-threads --with-http_addition_module --with-http_auth_request_module --with-http_dav_module --with-http_flv_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_mp4_module --with-http_random_index_module --with-http_realip_module --with-http_secure_link_module --with-http_slice_module --with-http_ssl_module --with-http_stub_status_module --with-http_sub_module --with-http_v2_module --with-mail --with-mail_ssl_module --with-stream --with-stream_realip_module --with-stream_ssl_module --with-stream_ssl_preread_module") Summary: High performance web server Name: nginx @@ -92,8 +92,6 @@ Source6: nginx.suse.logrotate Source7: nginx-debug.service Source8: nginx.copyright Source9: nginx.check-reload.sh -Source10: echo-nginx-module-0.63 -Source11: ngx-http-voms-module Patch0: nginx-httpg_no_delegation.patch diff --git a/ngx-http-voms-module/src/ngx_http_voms_module.cpp b/src/ngx_http_voms_module.cpp similarity index 100% rename from ngx-http-voms-module/src/ngx_http_voms_module.cpp rename to src/ngx_http_voms_module.cpp