perl/README.md
Jan Koscielniak c4b68b0a77 Initial commit
2017-04-20 14:17:35 +02:00

124 lines
No EOL
5.2 KiB
Markdown

# Perl S2I
This repository contains the sources for S2I builder image for perl 5.24 as well as some sample applications. This is a port to Fedora of software collections Perl located [here](https://github.com/sclorg/s2i-perl-container). Please note that this solution uses httpd 2.4 to display results.
# Usage
## Docker
First you need to build the builder image. After you have the builder image, you can use it for a S2I build. You can build and run the sample app like this:
```
$ docker build --tag=koscicz/perl .
$ s2i build https://github.com/container-images/perl.git --context-dir=test/sample-test-app/ koscicz/perl perl-sample-app
$ docker run -p 8080:8080 perl-sample-app
```
This will build and run you application on 127.0.0.1:8080. You can also build the builder image by running `make`. This will also tag your image as koscicz/perl.
## Openshift
You can use the `openshift-template.yml` in this repository to run your application in Openshift. You can either use web interface, in which case you'll just have to fill out a form, requiring a source repository for your app and name of this app. In case you want to use cli, you can do it like this, after you login:
```
$ oc new-project perl-test
$ oc new-app https://raw.githubusercontent.com/container-images/perl/master/openshift-template.yml -p APP_NAME="perl-example" -p SOURCE_REPOSITORY="https://github.com/kosciCZ/perl-example"
```
These commands will build the sample application on your Openshift platform.
# Testing
This repository contains a `test` folder with some tests to ensure proper functionality. You can run test by using Makefile. You have two options:
* `make all` This will build, tag and test the image
* `make test` This will run the test on the image, that is defined in the Makefile. By default it is koscicz/perl
Or you can execute the test script directly, as described below in [Repository organization](#repository-organization)
Repository organization
------------------------
* **Dockerfile**
Fedora based Dockerfile.
* **`s2i/bin/`**
This folder contains scripts that are run by [S2I](https://github.com/openshift/source-to-image):
* **assemble**
Used to install the sources into a location where the application
will be run and prepare the application for deployment (eg. installing
modules, etc.).
In order to install application dependencies, the application must contain a
`cpanfile` file, in which the user specifies the modules and their versions.
An example of a [cpanfile](https://github.com/container-images/perl/blob/master/test/sample-test-app/cpanfile) is available within our test application.
All files with `.cgi` and `.pl` extension are handled by mod_perl.
If exactly one file with `.psgi` extension exists in the top-level
directory, the mod_perl will be autoconfigured to execute the PSGI
application for any request URI path with Plack's mod_perl adaptor.
* **run**
This script is responsible for running the application, using the
Apache web server.
* **usage***
This script prints the usage of this image.
* **`contrib/`**
This folder contains a file with commonly used modules.
* **`test/`**
This folder contains some sample applications you can use to test you image.
* **`sample-test-app/`**
A simple Perl application used for testing purposes by the [S2I](https://github.com/openshift/source-to-image) test framework.
* **run**
This is a script that runs a test suite on the builder image, to ensure it has all the necessary functionality.
Run it by `./run IMAGE`, where `IMAGE` is your builder image.
Environment variables
---------------------
To set environment variables, you can place them as a key value pair into a `.sti/environment`
file inside your source code repository.
* **ENABLE_CPAN_TEST**
Allow the installation of all specified cpan packages and the running of their tests. The default value is `false`.
* **CPAN_MIRROR**
This variable specifies a mirror URL which will used by cpanminus to install dependencies.
By default the URL is not specified.
* **PERL_APACHE2_RELOAD**
Set this to "true" to enable automatic reloading of modified Perl modules.
* **HTTPD_START_SERVERS**
The [StartServers](https://httpd.apache.org/docs/2.4/mod/mpm_common.html#startservers)
directive sets the number of child server processes created on startup. Default is 8.
* **HTTPD_MAX_REQUEST_WORKERS**
Number of simultaneous requests that will be handled by Apache. The default
is 256, but it will be automatically lowered if memory is limited.
* **PSGI_FILE**
Override PSGI application detection.
If the PSGI_FILE variable is set to empty value, no PSGI application will
be detected and mod_perl not be reconfigured.
If the PSGI_FILE variable is set and non-empty, it will define path to
the PSGI application file. No detection will be used.
If the PSGI_FILE variable does not exist, autodetection will be used:
If exactly one ./*.psgi file exists, mod_perl will be configured to
execute that file.
* **PSGI_URI_PATH**
This variable overrides location URI path that is handled path the PSGI
application. Default value is "/".