Compare commits
No commits in common. "f26" and "master" have entirely different histories.
11 changed files with 30 additions and 404 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
|
@ -1 +0,0 @@
|
||||||
*.py[oc]
|
|
||||||
23
Dockerfile
23
Dockerfile
|
|
@ -1,23 +0,0 @@
|
||||||
FROM asamalik/module-nginx-master
|
|
||||||
|
|
||||||
# Labels
|
|
||||||
LABEL name="nginx" \
|
|
||||||
summary="Nginx is a web server." \
|
|
||||||
description="Nginx is a web server, which can also be used as a reverse proxy, load balancer and HTTP cache." \
|
|
||||||
version="0" \
|
|
||||||
release="1" \
|
|
||||||
atomic.has_install_files="true"
|
|
||||||
|
|
||||||
# Add neccessary configuration files
|
|
||||||
COPY files/nginx.conf /etc/nginx/nginx.conf
|
|
||||||
COPY files/service.template /exports/hostfs/usr/lib/systemd/system/nginx-container.service
|
|
||||||
|
|
||||||
RUN mkdir -p /exports/hostfs/{usr/share,etc} && \
|
|
||||||
cp -ar /usr/share/nginx /exports/hostfs/usr/share/ && \
|
|
||||||
cp -ar /etc/nginx /exports/hostfs/etc
|
|
||||||
|
|
||||||
# Export port for nginx frontend
|
|
||||||
EXPOSE 80
|
|
||||||
|
|
||||||
# Start nginx
|
|
||||||
CMD ["/usr/sbin/nginx"]
|
|
||||||
|
|
@ -1,94 +0,0 @@
|
||||||
# For more information on configuration, see:
|
|
||||||
# * Official English Documentation: http://nginx.org/en/docs/
|
|
||||||
# * Official Russian Documentation: http://nginx.org/ru/docs/
|
|
||||||
|
|
||||||
user nginx;
|
|
||||||
worker_processes auto;
|
|
||||||
pid /run/nginx.pid;
|
|
||||||
|
|
||||||
# Keep these settings to ensure the container runs correctly
|
|
||||||
error_log stderr;
|
|
||||||
daemon off;
|
|
||||||
|
|
||||||
# Load dynamic modules. See /usr/share/nginx/README.dynamic.
|
|
||||||
include /usr/share/nginx/modules/*.conf;
|
|
||||||
|
|
||||||
events {
|
|
||||||
worker_connections 1024;
|
|
||||||
}
|
|
||||||
|
|
||||||
http {
|
|
||||||
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
|
|
||||||
'$status $body_bytes_sent "$http_referer" '
|
|
||||||
'"$http_user_agent" "$http_x_forwarded_for"';
|
|
||||||
|
|
||||||
access_log /var/log/nginx/access.log main;
|
|
||||||
|
|
||||||
sendfile on;
|
|
||||||
tcp_nopush on;
|
|
||||||
tcp_nodelay on;
|
|
||||||
keepalive_timeout 65;
|
|
||||||
types_hash_max_size 4096;
|
|
||||||
|
|
||||||
include /etc/nginx/mime.types;
|
|
||||||
default_type application/octet-stream;
|
|
||||||
|
|
||||||
# Load modular configuration files from the /etc/nginx/conf.d directory.
|
|
||||||
# See http://nginx.org/en/docs/ngx_core_module.html#include
|
|
||||||
# for more information.
|
|
||||||
include /etc/nginx/conf.d/*.conf;
|
|
||||||
|
|
||||||
server {
|
|
||||||
listen 80 default_server;
|
|
||||||
listen [::]:80 default_server;
|
|
||||||
server_name _;
|
|
||||||
root /usr/share/nginx/html;
|
|
||||||
|
|
||||||
# Load configuration files for the default server block.
|
|
||||||
include /etc/nginx/default.d/*.conf;
|
|
||||||
|
|
||||||
location / {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
error_page 404 /404.html;
|
|
||||||
location = /40x.html {
|
|
||||||
}
|
|
||||||
|
|
||||||
error_page 500 502 503 504 /50x.html;
|
|
||||||
location = /50x.html {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
# Settings for a TLS enabled server.
|
|
||||||
#
|
|
||||||
# server {
|
|
||||||
# listen 443 ssl http2 default_server;
|
|
||||||
# listen [::]:443 ssl http2 default_server;
|
|
||||||
# server_name _;
|
|
||||||
# root /usr/share/nginx/html;
|
|
||||||
#
|
|
||||||
# ssl_certificate "/etc/pki/nginx/server.crt";
|
|
||||||
# ssl_certificate_key "/etc/pki/nginx/private/server.key";
|
|
||||||
# ssl_session_cache shared:SSL:1m;
|
|
||||||
# ssl_session_timeout 10m;
|
|
||||||
# ssl_ciphers HIGH:!aNULL:!MD5;
|
|
||||||
# ssl_prefer_server_ciphers on;
|
|
||||||
#
|
|
||||||
# # Load configuration files for the default server block.
|
|
||||||
# include /etc/nginx/default.d/*.conf;
|
|
||||||
#
|
|
||||||
# location / {
|
|
||||||
# }
|
|
||||||
#
|
|
||||||
# error_page 404 /404.html;
|
|
||||||
# location = /40x.html {
|
|
||||||
# }
|
|
||||||
#
|
|
||||||
# error_page 500 502 503 504 /50x.html;
|
|
||||||
# location = /50x.html {
|
|
||||||
# }
|
|
||||||
# }
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
@ -1,11 +0,0 @@
|
||||||
[Unit]
|
|
||||||
Description="Standalone container version of NGINX webserver."
|
|
||||||
|
|
||||||
[Service]
|
|
||||||
ExecStartPre=/usr/bin/docker create -t -i -v /etc/nginx:/etc/nginx/:ro --net=host -v /usr/share/nginx:/usr/share/nginx/:ro --name nginx-container modularitycontainers/nginx
|
|
||||||
ExecStart=/usr/bin/docker start -a nginx-container
|
|
||||||
ExecStop=/usr/bin/docker stop nginx-container
|
|
||||||
ExecStopPost=/usr/bin/docker rm -f nginx-container
|
|
||||||
|
|
||||||
[Install]
|
|
||||||
WantedBy=multi-user.target
|
|
||||||
31
nginx.yaml
31
nginx.yaml
|
|
@ -2,18 +2,18 @@ document: modulemd
|
||||||
version: 1
|
version: 1
|
||||||
data:
|
data:
|
||||||
summary: nginx webserver
|
summary: nginx webserver
|
||||||
description: An initial version of the nginx webserver module
|
description: an initial version of the nginx webserver module
|
||||||
license:
|
license:
|
||||||
module: [ MIT ]
|
module: [ MIT ]
|
||||||
dependencies:
|
dependencies:
|
||||||
buildrequires:
|
buildrequires:
|
||||||
bootstrap: f26
|
base-runtime: master
|
||||||
requires:
|
requires:
|
||||||
bootstrap: f26
|
base-runtime: master
|
||||||
references:
|
references:
|
||||||
community: https://docs.pagure.org/modularity/
|
community: https://docs.pagure.org/modularity/
|
||||||
documentation: https://github.com/modularity-modules/nginx
|
documentation: https://github.com/container-images/nginx
|
||||||
tracker: https://github.com/modularity-modules/nginx
|
tracker: https://github.com/container-images/nginx
|
||||||
profiles:
|
profiles:
|
||||||
default:
|
default:
|
||||||
rpms:
|
rpms:
|
||||||
|
|
@ -21,18 +21,27 @@ data:
|
||||||
api:
|
api:
|
||||||
rpms:
|
rpms:
|
||||||
- nginx
|
- nginx
|
||||||
|
|
||||||
filter:
|
|
||||||
rpms:
|
|
||||||
- nginx-all-modules
|
|
||||||
- nginx-mod-http-image-filter
|
|
||||||
|
|
||||||
components:
|
components:
|
||||||
rpms:
|
rpms:
|
||||||
nginx:
|
nginx:
|
||||||
rationale: Provides API for this module.
|
rationale: Provides API for this module.
|
||||||
ref: f26
|
ref: f26
|
||||||
|
|
||||||
|
gperftools:
|
||||||
|
rationale: dependency
|
||||||
|
ref: f26
|
||||||
|
libmnl:
|
||||||
|
rationale: dependency
|
||||||
|
ref: f26
|
||||||
|
libnetfilter_conntrack:
|
||||||
|
rationale: dependency
|
||||||
|
ref: f26
|
||||||
|
libnfnetlink:
|
||||||
|
rationale: dependency
|
||||||
|
ref: f26
|
||||||
|
libunwind:
|
||||||
|
rationale: dependency
|
||||||
|
ref: f26
|
||||||
libxkbcommon:
|
libxkbcommon:
|
||||||
rationale: dependency
|
rationale: dependency
|
||||||
ref: f26
|
ref: f26
|
||||||
|
|
|
||||||
|
|
@ -3,4 +3,5 @@ CMD=python -m avocado run --filter-by-tags=-WIP $(MODULE_LINT) *.py
|
||||||
|
|
||||||
#
|
#
|
||||||
all:
|
all:
|
||||||
|
generator
|
||||||
$(CMD)
|
$(CMD)
|
||||||
|
|
|
||||||
|
|
@ -12,12 +12,18 @@ testdependecies:
|
||||||
- curl
|
- curl
|
||||||
module:
|
module:
|
||||||
docker:
|
docker:
|
||||||
start: "docker run -it -p 80:80 -p 443:443"
|
start: "docker run --rm -p 80:80 nginx"
|
||||||
source: https://github.com/container-images/nginx.git
|
source: https://github.com/container-images/nginx.git
|
||||||
container: nginx
|
container: docker.io/modularitycontainers/nginx
|
||||||
rpm:
|
rpm:
|
||||||
start: systemctl start nginx
|
start: systemctl start nginx
|
||||||
stop: systemctl stop nginx
|
stop: systemctl stop nginx
|
||||||
status: systemctl status nginx
|
status: systemctl status nginx
|
||||||
repos:
|
repos:
|
||||||
- http://mirror.vutbr.cz/fedora/releases/26/Everything/x86_64/os/
|
- http://mirror.vutbr.cz/fedora/releases/25/Everything/x86_64/os/
|
||||||
|
test:
|
||||||
|
processrunning:
|
||||||
|
- 'ls /proc/*/exe -alh | grep nginx'
|
||||||
|
testhost:
|
||||||
|
basic:
|
||||||
|
- 'curl localhost | grep "Welcome to nginx!"'
|
||||||
|
|
|
||||||
|
|
@ -1,62 +0,0 @@
|
||||||
#!/usr/bin/python
|
|
||||||
# -*- coding: utf-8 -*-
|
|
||||||
#
|
|
||||||
# This Modularity Testing Framework helps you to write tests for modules
|
|
||||||
# Copyright (C) 2017 Red Hat, Inc.
|
|
||||||
#
|
|
||||||
# This program is free software; you can redistribute it and/or modify
|
|
||||||
# it under the terms of the GNU General Public License as published by
|
|
||||||
# he Free Software Foundation; either version 2 of the License, or
|
|
||||||
# (at your option) any later version.
|
|
||||||
#
|
|
||||||
# This program is distributed in the hope that it will be useful,
|
|
||||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
# GNU General Public License for more details.
|
|
||||||
#
|
|
||||||
# You should have received a copy of the GNU General Public License along
|
|
||||||
# with this program; if not, write to the Free Software Foundation, Inc.,
|
|
||||||
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
||||||
#
|
|
||||||
# Authors: Rado Pitonak <rpitonak@redhat.com>
|
|
||||||
#
|
|
||||||
|
|
||||||
from avocado import main
|
|
||||||
import time
|
|
||||||
from avocado.core import exceptions
|
|
||||||
from moduleframework import module_framework
|
|
||||||
|
|
||||||
|
|
||||||
class ConfigurationCheck(module_framework.AvocadoTest):
|
|
||||||
"""
|
|
||||||
:avocado: enable
|
|
||||||
"""
|
|
||||||
|
|
||||||
def testConfChange(self):
|
|
||||||
"""
|
|
||||||
Test change the root directory in the configuration file of running nginx.
|
|
||||||
Then nginx is reloaded and should load website from new root directory.
|
|
||||||
"""
|
|
||||||
|
|
||||||
self.start()
|
|
||||||
conf_path = "/etc/nginx/nginx.conf"
|
|
||||||
|
|
||||||
content = "<html><body><h1>Nginx is running in container!</h1></body></html>"
|
|
||||||
root = "/tmp/app-root"
|
|
||||||
|
|
||||||
# create website for testing
|
|
||||||
self.run("mkdir {}".format(root))
|
|
||||||
self.run("echo '{}' >> {}/index.html".format(content, root))
|
|
||||||
|
|
||||||
# change the root directory inside conf file
|
|
||||||
self.run("sed -i 's/root.*$/root \/tmp\/app-root\/;/g' {}".format(conf_path))
|
|
||||||
self.run("nginx -s reload")
|
|
||||||
|
|
||||||
time.sleep(5)
|
|
||||||
|
|
||||||
# request content from host
|
|
||||||
self.assertIn('{}\n'.format(content), self.runHost("curl 127.0.0.1:80").stdout)
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
|
||||||
main()
|
|
||||||
|
|
@ -1,56 +0,0 @@
|
||||||
#!/usr/bin/python
|
|
||||||
# -*- coding: utf-8 -*-
|
|
||||||
#
|
|
||||||
# This Modularity Testing Framework helps you to write tests for modules
|
|
||||||
# Copyright (C) 2017 Red Hat, Inc.
|
|
||||||
#
|
|
||||||
# This program is free software; you can redistribute it and/or modify
|
|
||||||
# it under the terms of the GNU General Public License as published by
|
|
||||||
# he Free Software Foundation; either version 2 of the License, or
|
|
||||||
# (at your option) any later version.
|
|
||||||
#
|
|
||||||
# This program is distributed in the hope that it will be useful,
|
|
||||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
# GNU General Public License for more details.
|
|
||||||
#
|
|
||||||
# You should have received a copy of the GNU General Public License along
|
|
||||||
# with this program; if not, write to the Free Software Foundation, Inc.,
|
|
||||||
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
||||||
#
|
|
||||||
# Authors: Jan Scotka <jscotka@redhat.com>
|
|
||||||
#
|
|
||||||
|
|
||||||
from avocado import main
|
|
||||||
from moduleframework import module_framework
|
|
||||||
|
|
||||||
|
|
||||||
class ExampleRpmValidation(module_framework.AvocadoTest):
|
|
||||||
"""
|
|
||||||
:avocado: enable
|
|
||||||
"""
|
|
||||||
fhs_base_paths = [
|
|
||||||
'/bin',
|
|
||||||
'/boot',
|
|
||||||
'/dev',
|
|
||||||
'/etc',
|
|
||||||
'/home',
|
|
||||||
'/lib',
|
|
||||||
'/lib64',
|
|
||||||
'/media',
|
|
||||||
'/mnt',
|
|
||||||
'/opt',
|
|
||||||
'/proc',
|
|
||||||
'/root',
|
|
||||||
'/run',
|
|
||||||
'/sbin',
|
|
||||||
'/sys',
|
|
||||||
'/srv',
|
|
||||||
'/tmp',
|
|
||||||
'/usr/bin'
|
|
||||||
]
|
|
||||||
|
|
||||||
def testPaths(self):
|
|
||||||
self.start()
|
|
||||||
for directory in self.fhs_base_paths:
|
|
||||||
self.run("test -d %s" % directory)
|
|
||||||
|
|
@ -1,63 +0,0 @@
|
||||||
#!/usr/bin/python
|
|
||||||
# -*- coding: utf-8 -*-
|
|
||||||
#
|
|
||||||
# This Modularity Testing Framework helps you to write tests for modules
|
|
||||||
# Copyright (C) 2017 Red Hat, Inc.
|
|
||||||
#
|
|
||||||
# This program is free software; you can redistribute it and/or modify
|
|
||||||
# it under the terms of the GNU General Public License as published by
|
|
||||||
# he Free Software Foundation; either version 2 of the License, or
|
|
||||||
# (at your option) any later version.
|
|
||||||
#
|
|
||||||
# This program is distributed in the hope that it will be useful,
|
|
||||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
# GNU General Public License for more details.
|
|
||||||
#
|
|
||||||
# You should have received a copy of the GNU General Public License along
|
|
||||||
# with this program; if not, write to the Free Software Foundation, Inc.,
|
|
||||||
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
||||||
#
|
|
||||||
# Authors: Rado Pitonak <rpitonak@redhat.com>
|
|
||||||
#
|
|
||||||
|
|
||||||
from avocado import main
|
|
||||||
from avocado.core import exceptions
|
|
||||||
from moduleframework import module_framework
|
|
||||||
|
|
||||||
|
|
||||||
class SanityCheck1(module_framework.AvocadoTest):
|
|
||||||
"""
|
|
||||||
:avocado: enable
|
|
||||||
"""
|
|
||||||
|
|
||||||
def test1(self):
|
|
||||||
"""
|
|
||||||
Simple sanity test
|
|
||||||
"""
|
|
||||||
|
|
||||||
self.start()
|
|
||||||
self.run("ls / | grep bin")
|
|
||||||
|
|
||||||
def test2Version(self):
|
|
||||||
"""
|
|
||||||
Check if nginx is installed in correct version
|
|
||||||
"""
|
|
||||||
|
|
||||||
version = "1."
|
|
||||||
self.start()
|
|
||||||
|
|
||||||
# For some reason, nginx -v spits out the version number to stderr
|
|
||||||
self.run("nginx -v 2>&1 | grep {}".format(version))
|
|
||||||
|
|
||||||
def test3ServiceRunning(self):
|
|
||||||
"""
|
|
||||||
Check if nginx is running
|
|
||||||
"""
|
|
||||||
|
|
||||||
self.start()
|
|
||||||
self.run('ls /proc/*/exe -alh | grep nginx')
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
|
||||||
main()
|
|
||||||
|
|
@ -1,80 +0,0 @@
|
||||||
#!/usr/bin/python
|
|
||||||
# -*- coding: utf-8 -*-
|
|
||||||
#
|
|
||||||
# This Modularity Testing Framework helps you to write tests for modules
|
|
||||||
# Copyright (C) 2017 Red Hat, Inc.
|
|
||||||
#
|
|
||||||
# This program is free software; you can redistribute it and/or modify
|
|
||||||
# it under the terms of the GNU General Public License as published by
|
|
||||||
# he Free Software Foundation; either version 2 of the License, or
|
|
||||||
# (at your option) any later version.
|
|
||||||
#
|
|
||||||
# This program is distributed in the hope that it will be useful,
|
|
||||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
# GNU General Public License for more details.
|
|
||||||
#
|
|
||||||
# You should have received a copy of the GNU General Public License along
|
|
||||||
# with this program; if not, write to the Free Software Foundation, Inc.,
|
|
||||||
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
||||||
#
|
|
||||||
# Authors: Rado Pitonak <rpitonak@redhat.com>
|
|
||||||
#
|
|
||||||
|
|
||||||
from avocado import main
|
|
||||||
from avocado.core import exceptions
|
|
||||||
from moduleframework import module_framework
|
|
||||||
import time
|
|
||||||
|
|
||||||
|
|
||||||
class SanityCheck2(module_framework.AvocadoTest):
|
|
||||||
"""
|
|
||||||
:avocado: enable
|
|
||||||
"""
|
|
||||||
|
|
||||||
def test1Port80(self):
|
|
||||||
"""
|
|
||||||
Request to localhost inside the container to make sure that server running on port 80
|
|
||||||
"""
|
|
||||||
|
|
||||||
self.start()
|
|
||||||
time.sleep(2)
|
|
||||||
self.run("curl 127.0.0.1:80")
|
|
||||||
|
|
||||||
def test2WebsiteContent(self):
|
|
||||||
"""
|
|
||||||
Check if nginx display correct content
|
|
||||||
"""
|
|
||||||
|
|
||||||
content = "<html><body><h1>Nginx is running in container!</h1></body></html>"
|
|
||||||
root = "/usr/share/nginx/"
|
|
||||||
|
|
||||||
self.start()
|
|
||||||
|
|
||||||
# create simple static website inside the container
|
|
||||||
self.run("touch {}/html/index.html".format(root))
|
|
||||||
self.run("echo '{}' >> {}/html/index.html".format(content, root))
|
|
||||||
|
|
||||||
# compare content returned by request from host with original content
|
|
||||||
self.assertIn('{}\n'.format(content), self.runHost("curl 127.0.0.1:80").stdout)
|
|
||||||
|
|
||||||
def test3Port443(self):
|
|
||||||
"""
|
|
||||||
Test configure server to listen also on port 443 and make request from host.
|
|
||||||
"""
|
|
||||||
|
|
||||||
conf_path = "/etc/nginx/nginx.conf"
|
|
||||||
self.start()
|
|
||||||
time.sleep(2)
|
|
||||||
|
|
||||||
# Make the server listen on port 443.
|
|
||||||
self.run("sed -i 's/server {}$/ server {} listen 443;/g' {}".format("{", "{", conf_path))
|
|
||||||
# reload nginx to apply changes
|
|
||||||
self.run("nginx -s reload")
|
|
||||||
time.sleep(5)
|
|
||||||
|
|
||||||
self.runHost("curl 127.0.0.1:443")
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
|
||||||
main()
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue