mirror of
https://github.com/google/nomulus
synced 2026-01-03 11:45:39 +00:00
Set up a unified registry servlet for Jetty (#2338)
This PR creates a unified RegistryServlet that will serve all
non-console traffic. It also creates a jetty subproject that allows one
to run Nomulus on top of a standard Jetty 12 runtime.
`./gradlew :jetty:stage` will create a jetty base folder at
`jetty/build/jetty-base` where one is able spin up a local Nomulus server
by running the following command inside the folder:
```bash
java -jar ${JETTY_HOME}/start.jar
```
`JETTY_HOME` is a folder where the [Jetty runtime](https://repo1.maven.org/maven2/org/eclipse/jetty/jetty-home/12.0.6/jetty-home-12.0.6.zip) is located.
This PR also adds a Gradle task to create a Nomulus image based on the
official Jetty image:
```bash
./gradlew :jetty:buildNomulusImage
```
This commit is contained in:
7
jetty/Dockerfile
Normal file
7
jetty/Dockerfile
Normal file
@@ -0,0 +1,7 @@
|
||||
FROM jetty:12-jdk17
|
||||
ADD --chown=jetty:jetty build/jetty-base /jetty-base
|
||||
ENV JETTY_BASE=/jetty-base
|
||||
WORKDIR "$JETTY_BASE"
|
||||
EXPOSE 8080
|
||||
ENTRYPOINT ["java", "-jar", "/usr/local/jetty/start.jar"]
|
||||
|
||||
52
jetty/build.gradle
Normal file
52
jetty/build.gradle
Normal file
@@ -0,0 +1,52 @@
|
||||
// Copyright 2024 The Nomulus Authors. All Rights Reserved.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
apply plugin: 'war'
|
||||
|
||||
tasks.register('copyJettyBase', Copy) {
|
||||
from(layout.projectDirectory.dir('src/main')) {
|
||||
include 'jetty-base/**'
|
||||
}
|
||||
into layout.buildDirectory
|
||||
}
|
||||
|
||||
war {
|
||||
setArchiveBaseName("root")
|
||||
setDestinationDirectory(layout.buildDirectory.dir('jetty-base/webapps'))
|
||||
dependsOn(tasks.named('copyJettyBase'))
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation project(':core')
|
||||
}
|
||||
|
||||
tasks.register('copyConsole', Copy) {
|
||||
from("${rootDir}/console-webapp/dist/console-webapp") {
|
||||
include "**/*"
|
||||
}
|
||||
into layout.buildDirectory.dir('jetty-base/webapps/console')
|
||||
dependsOn(':console-webapp:buildConsoleWebappProd')
|
||||
}
|
||||
|
||||
tasks.register('stage') {
|
||||
dependsOn(tasks.named('war'))
|
||||
dependsOn(tasks.named('copyConsole'))
|
||||
}
|
||||
|
||||
tasks.register('buildNomulusImage', Exec) {
|
||||
commandLine 'docker', 'build', '-t', 'nomulus', '.'
|
||||
dependsOn(tasks.named('stage'))
|
||||
}
|
||||
|
||||
project.build.dependsOn(tasks.named('buildNomulusImage'))
|
||||
10
jetty/src/main/jetty-base/resources/jetty-logging.properties
Normal file
10
jetty/src/main/jetty-base/resources/jetty-logging.properties
Normal file
@@ -0,0 +1,10 @@
|
||||
## Set logging levels from: ALL, TRACE, DEBUG, INFO, WARN, ERROR, OFF
|
||||
org.eclipse.jetty.LEVEL=INFO
|
||||
## Configure a level for an arbitrary logger tree
|
||||
#com.example.LEVEL=INFO
|
||||
## Configure a level for specific logger
|
||||
#com.example.MyComponent.LEVEL=INFO
|
||||
## Configure JMX Context Name
|
||||
# org.eclipse.jetty.logging.jmx.context=JettyServer
|
||||
## Hide stacks traces in an arbitrary logger tree
|
||||
#com.example.STACKS=false
|
||||
36
jetty/src/main/jetty-base/start.d/ee8-deploy.ini
Normal file
36
jetty/src/main/jetty-base/start.d/ee8-deploy.ini
Normal file
@@ -0,0 +1,36 @@
|
||||
# ---------------------------------------
|
||||
# Module: ee8-deploy
|
||||
# This module enables webapp deployment from the `$JETTY_BASE/webapps` directory.
|
||||
# ---------------------------------------
|
||||
--modules=ee8-deploy
|
||||
|
||||
## Monitored directory name (relative to $jetty.base)
|
||||
# jetty.deploy.monitoredDir=webapps
|
||||
|
||||
## Defaults Descriptor for all deployed webapps
|
||||
# jetty.deploy.defaultsDescriptorPath=${jetty.base}/etc/webdefault-ee8.xml
|
||||
|
||||
## Monitored directory scan period (seconds)
|
||||
jetty.deploy.scanInterval=1
|
||||
|
||||
## Whether to extract *.war files
|
||||
# jetty.deploy.extractWars=true
|
||||
|
||||
## Whether to give the parent classloader priority
|
||||
# jetty.deploy.parentLoaderPriority=true
|
||||
|
||||
## Comma separated list of configuration classes to set.
|
||||
# jetty.deploy.configurationClasses=
|
||||
|
||||
## Pattern to select jars from the container classloader to be scanned (or null to scan no jars)
|
||||
# jetty.deploy.containerScanJarPattern=.*/jetty-servlet-api-[^/]*\.jar$|.*/javax.servlet.jsp.jstl-.*\.jar$
|
||||
|
||||
## Pattern to select jars from the container classloader to be scanned (or null to scan all jars).
|
||||
# jetty.deploy.webInfScanJarPattern=
|
||||
|
||||
## Pattern to exclude discovered ServletContainerInitializers
|
||||
# jetty.deploy.servletContainerInitializerExclusionPattern=
|
||||
|
||||
## Order of discovered ServletContainerInitializers
|
||||
# jetty.deploy.servletContainerInitializerOrder=
|
||||
|
||||
47
jetty/src/main/jetty-base/start.d/http.ini
Normal file
47
jetty/src/main/jetty-base/start.d/http.ini
Normal file
@@ -0,0 +1,47 @@
|
||||
# ---------------------------------------
|
||||
# Module: http
|
||||
# Enables a clear-text HTTP connector.
|
||||
# By default clear-text HTTP/1.1 is enabled, and clear-text HTTP/2 may be added by enabling the "http2c" module.
|
||||
# ---------------------------------------
|
||||
--modules=http
|
||||
|
||||
### Clear-Text HTTP Connector Configuration
|
||||
|
||||
## The host/address to bind the connector to.
|
||||
jetty.http.host=0.0.0.0
|
||||
|
||||
## The port the connector listens on.
|
||||
# jetty.http.port=8080
|
||||
|
||||
## The connector idle timeout, in milliseconds.
|
||||
# jetty.http.idleTimeout=30000
|
||||
|
||||
## The number of acceptors (-1 picks a default value based on number of cores).
|
||||
# jetty.http.acceptors=1
|
||||
|
||||
## The number of selectors (-1 picks a default value based on number of cores).
|
||||
# jetty.http.selectors=-1
|
||||
|
||||
## The ServerSocketChannel accept queue backlog (0 picks the platform default).
|
||||
# jetty.http.acceptQueueSize=0
|
||||
|
||||
## The thread priority delta to give to acceptor threads.
|
||||
# jetty.http.acceptorPriorityDelta=0
|
||||
|
||||
## Whether to enable the SO_REUSEADDR socket option.
|
||||
# jetty.http.reuseAddress=true
|
||||
|
||||
## Whether to enable the SO_REUSEPORT socket option.
|
||||
# jetty.http.reusePort=false
|
||||
|
||||
## Whether to enable the TCP_NODELAY socket option on accepted sockets.
|
||||
# jetty.http.acceptedTcpNoDelay=true
|
||||
|
||||
## The SO_RCVBUF socket option to set on accepted sockets.
|
||||
## A value of -1 indicates that the platform default is used.
|
||||
# jetty.http.acceptedReceiveBufferSize=-1
|
||||
|
||||
## The SO_SNDBUF socket option to set on accepted sockets.
|
||||
## A value of -1 indicates that the platform default is used.
|
||||
# jetty.http.acceptedSendBufferSize=-1
|
||||
|
||||
100
jetty/src/main/jetty-base/start.d/server.ini
Normal file
100
jetty/src/main/jetty-base/start.d/server.ini
Normal file
@@ -0,0 +1,100 @@
|
||||
# ---------------------------------------
|
||||
# Module: server
|
||||
# Enables and configures the Jetty server.
|
||||
# This module does not enable any network protocol support.
|
||||
# To enable a specific network protocol such as HTTP/1.1, you must enable the correspondent Jetty module.
|
||||
# ---------------------------------------
|
||||
--modules=server
|
||||
|
||||
### Common HTTP configuration
|
||||
## Scheme to use to build URIs for secure redirects
|
||||
# jetty.httpConfig.secureScheme=https
|
||||
|
||||
## Port to use to build URIs for secure redirects
|
||||
# jetty.httpConfig.securePort=8443
|
||||
|
||||
## Response content buffer size (in bytes)
|
||||
# jetty.httpConfig.outputBufferSize=32768
|
||||
|
||||
## Max response content write length that is buffered (in bytes)
|
||||
# jetty.httpConfig.outputAggregationSize=8192
|
||||
|
||||
## If HTTP/1.x persistent connections should be enabled
|
||||
# jetty.httpConfig.persistentConnectionsEnabled=true
|
||||
|
||||
## Max request headers size (in bytes)
|
||||
# jetty.httpConfig.requestHeaderSize=8192
|
||||
|
||||
## Max response headers size (in bytes)
|
||||
# jetty.httpConfig.responseHeaderSize=8192
|
||||
|
||||
## Whether to send the Server: header
|
||||
# jetty.httpConfig.sendServerVersion=true
|
||||
|
||||
## Whether to send the Date: header
|
||||
# jetty.httpConfig.sendDateHeader=false
|
||||
|
||||
## Max per-connection header cache size (in nodes)
|
||||
# jetty.httpConfig.headerCacheSize=1024
|
||||
|
||||
## Whether, for requests with content, delay dispatch until some content has arrived
|
||||
# jetty.httpConfig.delayDispatchUntilContent=true
|
||||
|
||||
## Maximum number of error dispatches to prevent looping
|
||||
# jetty.httpConfig.maxErrorDispatches=10
|
||||
|
||||
## Relative Redirect Locations allowed
|
||||
# jetty.httpConfig.relativeRedirectAllowed=true
|
||||
|
||||
## Whether to use direct ByteBuffers for reading or writing
|
||||
# jetty.httpConfig.useInputDirectByteBuffers=true
|
||||
# jetty.httpConfig.useOutputDirectByteBuffers=true
|
||||
|
||||
## HTTP Compliance: RFC7230, RFC7230_LEGACY, RFC2616, RFC2616_LEGACY, LEGACY
|
||||
# jetty.httpConfig.compliance=RFC7230
|
||||
|
||||
## URI Compliance: DEFAULT, LEGACY, RFC3986, RFC3986_UNAMBIGUOUS, UNSAFE
|
||||
# jetty.httpConfig.uriCompliance=DEFAULT
|
||||
|
||||
## Cookie compliance mode for parsing request Cookie headers: RFC6265_STRICT, RFC6265, RFC6265_LEGACY, RFC2965, RFC2965_LEGACY
|
||||
# jetty.httpConfig.requestCookieCompliance=RFC6265
|
||||
|
||||
## Cookie compliance mode for generating response Set-Cookie: RFC2965, RFC6265
|
||||
# jetty.httpConfig.responseCookieCompliance=RFC6265
|
||||
|
||||
### Server configuration
|
||||
## Whether ctrl+c on the console gracefully stops the Jetty server
|
||||
# jetty.server.stopAtShutdown=true
|
||||
|
||||
## Timeout in ms to apply when stopping the server gracefully
|
||||
# jetty.server.stopTimeout=5000
|
||||
|
||||
## Dump the state of the Jetty server, components, and webapps after startup
|
||||
# jetty.server.dumpAfterStart=false
|
||||
|
||||
## The temporary directory used by the Jetty server and as a root for its contexts
|
||||
# jetty.server.tempDirectory=
|
||||
|
||||
## Dump the state of the Jetty server, components, and webapps before shutdown
|
||||
# jetty.server.dumpBeforeStop=false
|
||||
|
||||
### Server Scheduler Configuration
|
||||
## The scheduler thread name, defaults to "Scheduler-{hashCode()}" if blank.
|
||||
# jetty.scheduler.name=
|
||||
|
||||
## Whether the server scheduler threads are daemon.
|
||||
# jetty.scheduler.daemon=false
|
||||
|
||||
## The number of server scheduler threads.
|
||||
# jetty.scheduler.threads=1
|
||||
|
||||
## Whether the handlers of the ContextHandlerCollection can be updated once the server is started
|
||||
## If set to false, then eeN-deploy module jetty.deploy.scanInterval should also be set to 0.
|
||||
# jetty.server.contexts.dynamic=true
|
||||
|
||||
## Should the DefaultHandler serve the jetty favicon.ico from the root.
|
||||
# jetty.server.default.serveFavIcon=true
|
||||
|
||||
## Should the DefaultHandler show a list of known contexts in a root 404 response.
|
||||
# jetty.server.default.showContexts=true
|
||||
|
||||
20
jetty/src/main/webapp/WEB-INF/web.xml
Normal file
20
jetty/src/main/webapp/WEB-INF/web.xml
Normal file
@@ -0,0 +1,20 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<web-app xmlns="http://java.sun.com/xml/ns/javaee" version="2.5"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
|
||||
http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
|
||||
<!-- Servlets -->
|
||||
|
||||
<!-- Servlet for injected frontend actions -->
|
||||
<servlet>
|
||||
<servlet-name>registry</servlet-name>
|
||||
<servlet-class>google.registry.module.RegistryServlet</servlet-class>
|
||||
<load-on-startup>1</load-on-startup>
|
||||
</servlet>
|
||||
|
||||
<!-- The Nomulus registry servlet. -->
|
||||
<servlet-mapping>
|
||||
<servlet-name>registry</servlet-name>
|
||||
<url-pattern>/*</url-pattern>
|
||||
</servlet-mapping>
|
||||
</web-app>
|
||||
Reference in New Issue
Block a user