此内容没有您所选择的语言版本。
Chapter 4. Reference
4.1. Source-to-Image (S2I) 复制链接链接已复制到粘贴板!
The Red Hat JBoss Web Server for OpenShift image includes S2I scripts and Maven.
A Maven repository holds build artifacts and dependencies, such as the project jars, library jars, plugins or any other project specific artifacts. It also defines locations to download artifacts from while performing the S2I build. Along with using the Maven Central Repository, some organizations also deploy a local custom repository (mirror).
Benefits of using a local mirror are:
- Availability of a synchronized mirror, which is geographically closer and faster.
- Greater control over the repository content.
- Possibility to share artifacts across different teams (developers, CI), without the need to rely on public servers and repositories.
- Improved build times.
A Maven repository manager can serve as local cache to a mirror. Assuming that the repository manager is already deployed and reachable externally at http://10.0.0.1:8080/repository/internal/, the S2I build can use this repository. To use an internal Maven repository, add the MAVEN_MIRROR_URL environment variable to the build configuration of the application.
For a new build configuration, use the --build-env option with oc new-app or oc new-build:
For an existing build configuration:
Identify the build configuration which requires the
MAVEN_MIRROR_URLvariable:oc get bc -o name
$ oc get bc -o name buildconfig/jwsCopy to Clipboard Copied! Toggle word wrap Toggle overflow Add the
MAVEN_MIRROR_URLenvironment variable tobuildconfig/jws:oc env bc/jws MAVEN_MIRROR_URL="http://10.0.0.1:8080/repository/internal/"
$ oc env bc/jws MAVEN_MIRROR_URL="http://10.0.0.1:8080/repository/internal/" buildconfig "jws" updatedCopy to Clipboard Copied! Toggle word wrap Toggle overflow Verify the build configuration has updated:
oc env bc/jws --list buildconfigs jws
$ oc env bc/jws --list # buildconfigs jws MAVEN_MIRROR_URL=http://10.0.0.1:8080/repository/internal/Copy to Clipboard Copied! Toggle word wrap Toggle overflow -
Schedule a new build of the application using
oc start-build
During application build, Maven dependencies are download from the repository manager, instead of the default public repositories. Once the build has finished, the mirror contains all the dependencies retrieved and used during the build.
run- runs Catalina (Tomcat)
assemble-
uses Maven to build the source, create package (
.war) and move it to the$JWS_HOME/webappsdirectory.
The build configuration can be modified by including environment variables to the Source-to-Image build command (see Section 4.1.1, “Using maven artifact repository mirrors with JWS for OpenShift”). The valid environment variables for the Red Hat JBoss Web Server for OpenShift images are:
| Variable Name | Description | Example Value :leveloffset: +3 |
| ARTIFACT_DIR |
| target |
| HTTP_PROXY_HOST | Hostname or IP address of a HTTP proxy for Maven to use. | 192.168.1.1 |
| HTTP_PROXY_PORT | TCP Port of a HTTP proxy for Maven to use. | 8080 |
| HTTP_PROXY_USERNAME |
If supplied with | myusername |
| HTTP_PROXY_PASSWORD |
If supplied with | mypassword |
| HTTP_PROXY_NONPROXYHOSTS | If supplied, a configured HTTP proxy will ignore these hosts (a comma-separated lists of hosts, IP addresses or domains). | *.example.net,some.example.org |
| MAVEN_ARGS | Overrides the arguments supplied to Maven during build. | -e -Popenshift -DskipTests -Dcom.redhat.xpaas.repo.redhatga package |
| MAVEN_ARGS_APPEND | Appends user arguments supplied to Maven during build. | -Dfoo=bar |
| MAVEN_MIRROR_URL | URL of a Maven mirror/repository manager to configure. | http://10.0.0.1:8080/repository/internal/ |
| MAVEN_CLEAR_REPO | Optionally clear the local Maven repository after the build. | true :leveloffset: 3 |
4.2. Valves on JWS for OpenShift 复制链接链接已复制到粘贴板!
You can define the following environment variables to insert the valve component into the request processing pipeline for the associated Catalina container.
| Variable Name | Description | Example Value | Default Value |
|---|---|---|---|
| ENABLE_ACCESS_LOG | Enable the Access Log Valve to log access messages to the standard output channel. | true | false |
4.3. Checking Logs 复制链接链接已复制到粘贴板!
To view the OpenShift logs or the logs provided by a running container’s console:
oc logs -f <pod_name> <container_name>
$ oc logs -f <pod_name> <container_name>
Access logs are stored in /opt/webserver/logs/.